File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2323 */
2424class Configuration implements ConfigurationInterface
2525{
26+ const ROOT_NODE_NAME = 'xiidea_easy_audit ' ;
27+
2628 /**
2729 * {@inheritdoc}
2830 */
2931 public function getConfigTreeBuilder ()
3032 {
31- $ treeBuilder = new TreeBuilder ();
33+ $ treeBuilder = new TreeBuilder (self :: ROOT_NODE_NAME );
3234
33- $ rootNode = $ treeBuilder -> root ( ' xiidea_easy_audit ' );
35+ $ rootNode = $ this -> getRootNode ( $ treeBuilder );
3436
3537 $ this ->addRequiredConfigs ($ rootNode );
3638 $ this ->addDefaultServices ($ rootNode );
@@ -204,4 +206,17 @@ private function isEmpty()
204206 return empty ($ v );
205207 };
206208 }
209+
210+ /**
211+ * @param TreeBuilder $treeBuilder
212+ * @return ArrayNodeDefinition|\Symfony\Component\Config\Definition\Builder\NodeDefinition
213+ */
214+ protected function getRootNode ($ treeBuilder )
215+ {
216+ if (method_exists ($ treeBuilder , 'getRootNode ' )) {
217+ return $ treeBuilder ->getRootNode ();
218+ }
219+
220+ return $ treeBuilder ->root (self ::ROOT_NODE_NAME );
221+ }
207222}
Original file line number Diff line number Diff line change 1515use Doctrine \Common \Persistence \Event \LifecycleEventArgs ;
1616use Doctrine \Common \Util \ClassUtils ;
1717use Symfony \Component \EventDispatcher \EventDispatcher ;
18+ use Symfony \Component \EventDispatcher \LegacyEventDispatcherProxy ;
1819use Xiidea \EasyAuditBundle \Annotation \SubscribeDoctrineEvents ;
1920use Xiidea \EasyAuditBundle \Events \DoctrineObjectEvent ;
2021use Xiidea \EasyAuditBundle \Events \DoctrineEvents ;
@@ -243,6 +244,10 @@ private function isScheduledForDelete($entity)
243244 */
244245 public function setDispatcher ($ dispatcher )
245246 {
247+ if (class_exists (LegacyEventDispatcherProxy::class)) {
248+ $ dispatcher = LegacyEventDispatcherProxy::decorate ($ dispatcher );
249+ }
250+
246251 $ this ->dispatcher = $ dispatcher ;
247252 }
248253}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Xiidea \EasyAuditBundle \Tests \DependencyInjection ;
4+
5+
6+ use PHPUnit \Framework \TestCase ;
7+ use Xiidea \EasyAuditBundle \DependencyInjection \Configuration ;
8+ use Xiidea \EasyAuditBundle \Tests \Fixtures \Common \TestableConfiguration ;
9+
10+ class TreeBuilderOld {
11+
12+ public function root ()
13+ {
14+ return 'ROOT_METHOD ' ;
15+ }
16+ }
17+
18+ class TreeBuilderNew extends TreeBuilderOld {
19+
20+ public function getRootNode ()
21+ {
22+ return 'GET_ROOT_NODE_METHOD ' ;
23+ }
24+ }
25+
26+ class ConfigurationTest extends TestCase
27+ {
28+
29+ public function testGetRootNodeByCallingGetRootNodeMethodOfBuilder ()
30+ {
31+ $ configuration = new TestableConfiguration ();
32+
33+
34+ $ result = $ configuration ->getRootNodeOfBuilder (new TreeBuilderNew ());
35+
36+ $ this ->assertEquals ('GET_ROOT_NODE_METHOD ' , $ result );
37+
38+ }
39+
40+ public function testGetRootNodeByCallingRootMethodOfBuilder ()
41+ {
42+ $ configuration = new TestableConfiguration ();
43+
44+
45+ $ result = $ configuration ->getRootNodeOfBuilder (new TreeBuilderOld ());
46+
47+ $ this ->assertEquals ('ROOT_METHOD ' , $ result );
48+
49+ }
50+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+
4+ namespace Xiidea \EasyAuditBundle \Tests \Fixtures \Common ;
5+
6+
7+ use Xiidea \EasyAuditBundle \DependencyInjection \Configuration ;
8+
9+ class TestableConfiguration extends Configuration
10+ {
11+ public function getRootNodeOfBuilder ($ builder )
12+ {
13+ return $ this ->getRootNode ($ builder );
14+ }
15+ }
You can’t perform that action at this time.
0 commit comments