Skip to content

Commit

Permalink
Feat: support of custom annotation loader
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Besir Horáček committed Feb 1, 2024
1 parent cb464d4 commit c41b0c2
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/Core/DI/Plugin/CoreSchemaPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ protected function getConfigSchema(): Schema
'loaders' => Expect::structure([
'annotations' => Expect::structure([
'enable' => Expect::bool(true),
'loader' => Expect::string(),
]),
'neon' => Expect::structure([
'enable' => Expect::bool(false),
Expand Down Expand Up @@ -112,10 +113,21 @@ protected function loadSchema(SchemaBuilder $builder): SchemaBuilder
{
$loaders = $this->config->loaders;

//TODO - resolve limitation - Controller defined by one of loaders cannot be modified by other loaders

if ($loaders->annotations->enable) {
$loader = new DoctrineAnnotationLoader($this->getContainerBuilder());
if ($loaders->annotations->loader) {

Check failure on line 117 in src/Core/DI/Plugin/CoreSchemaPlugin.php

View workflow job for this annotation

GitHub Actions / Codesniffer / Codesniffer (8.2)

Expected 1 line after "if", found 0.

if (!class_exists($loaders->annotations->loader)) {
throw new \RuntimeException(sprintf('Annotation loader class %s does not exist', $loaders->annotations->loader));

Check warning on line 120 in src/Core/DI/Plugin/CoreSchemaPlugin.php

View check run for this annotation

Codecov / codecov/patch

src/Core/DI/Plugin/CoreSchemaPlugin.php#L119-L120

Added lines #L119 - L120 were not covered by tests
}

if (!is_subclass_of($loaders->annotations->loader, DoctrineAnnotationLoader::class)) {
throw new \RuntimeException(sprintf('Annotation loader class %s must be subclass of %s', $loaders->annotations->loader, DoctrineAnnotationLoader::class));

Check warning on line 124 in src/Core/DI/Plugin/CoreSchemaPlugin.php

View check run for this annotation

Codecov / codecov/patch

src/Core/DI/Plugin/CoreSchemaPlugin.php#L123-L124

Added lines #L123 - L124 were not covered by tests
}

$loader = new $loaders->annotations->loader($this->getContainerBuilder());

Check warning on line 127 in src/Core/DI/Plugin/CoreSchemaPlugin.php

View check run for this annotation

Codecov / codecov/patch

src/Core/DI/Plugin/CoreSchemaPlugin.php#L127

Added line #L127 was not covered by tests
} else {
$loader = new DoctrineAnnotationLoader($this->getContainerBuilder());
}
$builder = $loader->load($builder);
}

Expand Down

0 comments on commit c41b0c2

Please sign in to comment.