Skip to content

Commit

Permalink
fix: getting class loader, fixes #51
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Feb 22, 2023
1 parent ab570a0 commit 12fd281
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Component/Generator/Definition/EntityLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use PhpParser\NodeFinder;
use PhpParser\ParserFactory;
use Shopware\Core\Framework\DataAbstractionLayer\DefinitionInstanceRegistry;
use Shopware\Core\Kernel;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Filesystem\Filesystem;

Expand All @@ -25,9 +26,12 @@ class EntityLoader
*/
private $instanceRegistry;

public function __construct(DefinitionInstanceRegistry $instanceRegistry)
private Kernel $kernel;

public function __construct(DefinitionInstanceRegistry $instanceRegistry, Kernel $kernel)
{
$this->instanceRegistry = $instanceRegistry;
$this->kernel = $kernel;
}

public function load(string $class, SymfonyStyle $io): Definition
Expand Down Expand Up @@ -194,8 +198,7 @@ private function normalizeName(string $class): string

private function getNewEntityFolder(string $namespace): string
{
global $classLoader;
$prefixes = $classLoader->getPrefixesPsr4();
$prefixes = $this->kernel->getPluginLoader()->getClassLoader()->getPrefixesPsr4();

$namespaceSplit = explode('\\', $namespace);
unset($namespaceSplit[count($namespaceSplit) -1 ]);
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<defaults>
</defaults>

<service id="Shopware\Core\Kernel" alias="kernel"/>

<instanceof id="Frosh\DevelopmentHelper\Component\Generator\QuestionHandler\QuestionHandlerInterface">
<tag name="frosh_development_helper.question_helper"/>
</instanceof>
Expand Down

0 comments on commit 12fd281

Please sign in to comment.