Skip to content

Commit

Permalink
Create AnnotationReader if not available (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzmg authored Aug 14, 2024
1 parent ced91e7 commit 2cb75fa
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/DependencyInjection/Compiler/ServiceAnnotationPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Terminal42\ServiceAnnotationBundle\DependencyInjection\Compiler;

use Doctrine\Common\Annotations\AnnotationException;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\Reader;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand All @@ -27,11 +28,7 @@ class ServiceAnnotationPass implements CompilerPassInterface

public function process(ContainerBuilder $container): void
{
if (!$container->has('annotation_reader')) {
return;
}

$this->annotationReader = $container->get('annotation_reader');
$this->annotationReader = $container->get('annotation_reader', ContainerBuilder::NULL_ON_INVALID_REFERENCE) ?? new AnnotationReader();

foreach ($container->getDefinitions() as $id => $definition) {
if ($definition->isAbstract() || $definition->isSynthetic()) {
Expand Down

0 comments on commit 2cb75fa

Please sign in to comment.