Skip to content

Commit 473ae65

Browse files
authored
Merge pull request #486 from stof/inject_attribute_reader
Inject an AttributeReader when annotations are disabled
2 parents a3ceb54 + 6845226 commit 473ae65

File tree

13 files changed

+40
-11
lines changed

13 files changed

+40
-11
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Stof\DoctrineExtensionsBundle\DependencyInjection\Compiler;
4+
5+
use Gedmo\Mapping\Driver\AttributeReader;
6+
use Symfony\Component\DependencyInjection\Alias;
7+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8+
use Symfony\Component\DependencyInjection\ContainerBuilder;
9+
10+
/**
11+
* @internal
12+
*/
13+
final class ReaderPass implements CompilerPassInterface
14+
{
15+
public function process(ContainerBuilder $container): void
16+
{
17+
if ($container->has('annotation_reader')) {
18+
$container->setAlias('.stof_doctrine_extensions.reader', new Alias('annotation_reader', false));
19+
20+
return;
21+
}
22+
23+
if (\PHP_VERSION_ID >= 80000) {
24+
$container->register('.stof_doctrine_extensions.reader', AttributeReader::class);
25+
}
26+
}
27+
}

src/Resources/config/blameable.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<argument type="service" id="stof_doctrine_extensions.metadata_cache" />
1515
</call>
1616
<call method="setAnnotationReader">
17-
<argument type="service" id="annotation_reader" on-invalid="ignore" />
17+
<argument type="service" id=".stof_doctrine_extensions.reader" on-invalid="ignore" />
1818
</call>
1919
</service>
2020

src/Resources/config/ip_traceable.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<argument type="service" id="stof_doctrine_extensions.metadata_cache" />
1111
</call>
1212
<call method="setAnnotationReader">
13-
<argument type="service" id="annotation_reader" on-invalid="ignore" />
13+
<argument type="service" id=".stof_doctrine_extensions.reader" on-invalid="ignore" />
1414
</call>
1515
</service>
1616

src/Resources/config/loggable.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<argument type="service" id="stof_doctrine_extensions.metadata_cache" />
1515
</call>
1616
<call method="setAnnotationReader">
17-
<argument type="service" id="annotation_reader" on-invalid="ignore" />
17+
<argument type="service" id=".stof_doctrine_extensions.reader" on-invalid="ignore" />
1818
</call>
1919
</service>
2020

src/Resources/config/reference_integrity.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<argument type="service" id="stof_doctrine_extensions.metadata_cache" />
1414
</call>
1515
<call method="setAnnotationReader">
16-
<argument type="service" id="annotation_reader" on-invalid="ignore" />
16+
<argument type="service" id=".stof_doctrine_extensions.reader" on-invalid="ignore" />
1717
</call>
1818
</service>
1919
</services>

src/Resources/config/sluggable.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<argument type="service" id="stof_doctrine_extensions.metadata_cache" />
1414
</call>
1515
<call method="setAnnotationReader">
16-
<argument type="service" id="annotation_reader" on-invalid="ignore" />
16+
<argument type="service" id=".stof_doctrine_extensions.reader" on-invalid="ignore" />
1717
</call>
1818
</service>
1919
</services>

src/Resources/config/softdeleteable.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<argument type="service" id="clock" on-invalid="ignore" />
1717
</call>
1818
<call method="setAnnotationReader">
19-
<argument type="service" id="annotation_reader" on-invalid="ignore" />
19+
<argument type="service" id=".stof_doctrine_extensions.reader" on-invalid="ignore" />
2020
</call>
2121
</service>
2222
</services>

src/Resources/config/sortable.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<argument type="service" id="stof_doctrine_extensions.metadata_cache" />
1414
</call>
1515
<call method="setAnnotationReader">
16-
<argument type="service" id="annotation_reader" on-invalid="ignore" />
16+
<argument type="service" id=".stof_doctrine_extensions.reader" on-invalid="ignore" />
1717
</call>
1818
</service>
1919
</services>

src/Resources/config/timestampable.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<argument type="service" id="clock" on-invalid="ignore" />
1717
</call>
1818
<call method="setAnnotationReader">
19-
<argument type="service" id="annotation_reader" on-invalid="ignore" />
19+
<argument type="service" id=".stof_doctrine_extensions.reader" on-invalid="ignore" />
2020
</call>
2121
</service>
2222
</services>

src/Resources/config/translatable.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<argument type="service" id="stof_doctrine_extensions.metadata_cache" />
1515
</call>
1616
<call method="setAnnotationReader">
17-
<argument type="service" id="annotation_reader" on-invalid="ignore" />
17+
<argument type="service" id=".stof_doctrine_extensions.reader" on-invalid="ignore" />
1818
</call>
1919
<call method="setDefaultLocale">
2020
<argument>%stof_doctrine_extensions.default_locale%</argument>

src/Resources/config/tree.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<argument type="service" id="stof_doctrine_extensions.metadata_cache" />
1414
</call>
1515
<call method="setAnnotationReader">
16-
<argument type="service" id="annotation_reader" on-invalid="ignore" />
16+
<argument type="service" id=".stof_doctrine_extensions.reader" on-invalid="ignore" />
1717
</call>
1818
</service>
1919
</services>

src/Resources/config/uploadable.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<argument type="service" id="stof_doctrine_extensions.metadata_cache" />
2020
</call>
2121
<call method="setAnnotationReader">
22-
<argument type="service" id="annotation_reader" on-invalid="ignore" />
22+
<argument type="service" id=".stof_doctrine_extensions.reader" on-invalid="ignore" />
2323
</call>
2424

2525
<call method="setDefaultFileInfoClass">

src/StofDoctrineExtensionsBundle.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Stof\DoctrineExtensionsBundle;
44

5+
use Stof\DoctrineExtensionsBundle\DependencyInjection\Compiler\ReaderPass;
56
use Stof\DoctrineExtensionsBundle\DependencyInjection\Compiler\ValidateExtensionConfigurationPass;
67
use Symfony\Component\HttpKernel\Bundle\Bundle;
78
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -16,5 +17,6 @@ class StofDoctrineExtensionsBundle extends Bundle
1617
public function build(ContainerBuilder $container)
1718
{
1819
$container->addCompilerPass(new ValidateExtensionConfigurationPass());
20+
$container->addCompilerPass(new ReaderPass());
1921
}
2022
}

0 commit comments

Comments
 (0)