Skip to content

Commit 81252c2

Browse files
authored
Merge pull request #2 from igrybkov/fix-command-registration
Module do not work out of the box without excessive dependencies
2 parents f92f159 + f21d9f3 commit 81252c2

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

functions.php

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
/**
4+
* Magento 2 autoloader calls \Magento\Framework\Code\Generator
5+
* which is supposed to generate missing classes, e.g. Factories, Proxies, Interceptors.
6+
* For some reason, it throws \RuntimeException in \Magento\Framework\Code\Generator::tryToLoadSourceClass
7+
* when it finds out that the class for which a factory supposed to exist is also missing.
8+
* It's the case which we have in \Enqueue\Magento2\Model\EnqueueManager where, for example,
9+
* for missing \Enqueue\Stomp\StompConnectionFactory Magento tries to generate a factory
10+
* based on Enqueue\Stomp\StompConnection, but this class is also missing and this leads to the exception.
11+
*
12+
* To prevent such behavior from Magento, we could handle this exception.
13+
*/
14+
namespace Enqueue\SimpleClient {
15+
16+
if (!\function_exists('\Enqueue\SimpleClient\class_exists')) {
17+
function class_exists($class_name, $autoload = true)
18+
{
19+
try {
20+
return \class_exists($class_name, $autoload);
21+
} catch (\RuntimeException $exception) {
22+
return false;
23+
}
24+
}
25+
}
26+
}

registration.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@
66
\Magento\Framework\Component\ComponentRegistrar::MODULE,
77
'Enqueue_Enqueue',
88
__DIR__
9-
);
9+
);
10+
11+
require_once __DIR__ . '/functions.php';

0 commit comments

Comments
 (0)