@@ -23,62 +23,67 @@ public function getOrder()
23
23
}
24
24
25
25
/**
26
- * @param \Doctrine\ODM\PHPCR\DocumentManager $dm
26
+ * @param \Doctrine\ODM\PHPCR\DocumentManager $manager
27
27
*/
28
- public function load (ObjectManager $ dm )
28
+ public function load (ObjectManager $ manager )
29
29
{
30
- $ session = $ dm ->getPhpcrSession ();
30
+ if (!$ manager instanceof DocumentManager) {
31
+ $ class = get_class ($ manager );
32
+ throw new \RuntimeException ("Fixture requires a PHPCR ODM DocumentManager instance, instance of ' $ class' given. " );
33
+ }
34
+
35
+ $ session = $ manager ->getPhpcrSession ();
31
36
32
37
$ basepath = $ this ->container ->getParameter ('cmf_menu.persistence.phpcr.menu_basepath ' );
33
38
$ content_path = $ this ->container ->getParameter ('cmf_content.persistence.phpcr.content_basepath ' );
34
39
35
40
NodeHelper::createPath ($ session , $ basepath );
36
- $ root = $ dm ->find (null , $ basepath );
41
+ $ root = $ manager ->find (null , $ basepath );
37
42
38
43
$ labels = array ('en ' => 'Home ' , 'de ' => 'Start ' , 'fr ' => 'Accueil ' );
39
44
/** @var $main Menu */
40
- $ main = $ this ->createMenuNode ($ dm , $ root , 'main ' , $ labels , $ dm ->find (null , "$ content_path/home " ));
45
+ $ main = $ this ->createMenuNode ($ manager , $ root , 'main ' , $ labels , $ manager ->find (null , "$ content_path/home " ));
41
46
$ main ->setChildrenAttributes (array ("class " => "menu_main " ));
42
47
43
48
if ($ session ->getRepository ()->getDescriptor (RepositoryInterface::QUERY_FULL_TEXT_SEARCH_SUPPORTED )) {
44
- $ this ->createMenuNode ($ dm , $ main , 'search-item ' , 'Search ' , null , null , 'liip_search ' );
49
+ $ this ->createMenuNode ($ manager , $ main , 'search-item ' , 'Search ' , null , null , 'liip_search ' );
45
50
}
46
51
47
- $ this ->createMenuNode ($ dm , $ main , 'admin-item ' , 'Admin ' , null , null , 'sonata_admin_dashboard ' );
52
+ $ this ->createMenuNode ($ manager , $ main , 'admin-item ' , 'Admin ' , null , null , 'sonata_admin_dashboard ' );
48
53
49
- $ projects = $ this ->createMenuNode ($ dm , $ main , 'projects-item ' , array ('en ' => 'Projects ' , 'de ' => 'Projekte ' , 'fr ' => 'Projets ' ), $ dm ->find (null , "$ content_path/projects " ));
50
- $ this ->createMenuNode ($ dm , $ projects , 'cmf-item ' , 'Symfony CMF ' , $ dm ->find (null , "$ content_path/cmf " ));
54
+ $ projects = $ this ->createMenuNode ($ manager , $ main , 'projects-item ' , array ('en ' => 'Projects ' , 'de ' => 'Projekte ' , 'fr ' => 'Projets ' ), $ manager ->find (null , "$ content_path/projects " ));
55
+ $ this ->createMenuNode ($ manager , $ projects , 'cmf-item ' , 'Symfony CMF ' , $ manager ->find (null , "$ content_path/cmf " ));
51
56
52
- $ company = $ this ->createMenuNode ($ dm , $ main , 'company-item ' , array ('en ' => 'Company ' , 'de ' => 'Firma ' , 'fr ' => 'Entreprise ' ), $ dm ->find (null , "$ content_path/company " ));
53
- $ this ->createMenuNode ($ dm , $ company , 'team-item ' , array ('en ' => 'Team ' , 'de ' => 'Team ' , 'fr ' => 'Equipe ' ), $ dm ->find (null , "$ content_path/team " ));
54
- $ this ->createMenuNode ($ dm , $ company , 'more-item ' , array ('en ' => 'More ' , 'de ' => 'Mehr ' , 'fr ' => 'Plus ' ), $ dm ->find (null , "$ content_path/more " ));
57
+ $ company = $ this ->createMenuNode ($ manager , $ main , 'company-item ' , array ('en ' => 'Company ' , 'de ' => 'Firma ' , 'fr ' => 'Entreprise ' ), $ manager ->find (null , "$ content_path/company " ));
58
+ $ this ->createMenuNode ($ manager , $ company , 'team-item ' , array ('en ' => 'Team ' , 'de ' => 'Team ' , 'fr ' => 'Equipe ' ), $ manager ->find (null , "$ content_path/team " ));
59
+ $ this ->createMenuNode ($ manager , $ company , 'more-item ' , array ('en ' => 'More ' , 'de ' => 'Mehr ' , 'fr ' => 'Plus ' ), $ manager ->find (null , "$ content_path/more " ));
55
60
56
- $ demo = $ this ->createMenuNode ($ dm , $ main , 'demo-item ' , 'Demo ' , $ dm ->find (null , "$ content_path/demo " ));
61
+ $ demo = $ this ->createMenuNode ($ manager , $ main , 'demo-item ' , 'Demo ' , $ manager ->find (null , "$ content_path/demo " ));
57
62
//TODO: this should be possible without a content as the controller might not need a content. support directly having the route document as "content" in the menu document?
58
- $ this ->createMenuNode ($ dm , $ demo , 'controller-item ' , 'Explicit controller ' , $ dm ->find (null , "$ content_path/demo_controller " ));
59
- $ this ->createMenuNode ($ dm , $ demo , 'template-item ' , 'Explicit template ' , $ dm ->find (null , "$ content_path/demo_template " ));
60
- $ this ->createMenuNode ($ dm , $ demo , 'type-item ' , 'Route type to controller ' , $ dm ->find (null , "$ content_path/demo_type " ));
61
- $ this ->createMenuNode ($ dm , $ demo , 'class-item ' , 'Class to controller ' , $ dm ->find (null , "$ content_path/demo_class " ));
62
- $ this ->createMenuNode ($ dm , $ demo , 'test-item ' , 'Normal Symfony Route ' , null , null , 'test ' );
63
- $ this ->createMenuNode ($ dm , $ demo , 'external-item ' , 'External Link ' , null , 'http://cmf.symfony.com/ ' );
63
+ $ this ->createMenuNode ($ manager , $ demo , 'controller-item ' , 'Explicit controller ' , $ manager ->find (null , "$ content_path/demo_controller " ));
64
+ $ this ->createMenuNode ($ manager , $ demo , 'template-item ' , 'Explicit template ' , $ manager ->find (null , "$ content_path/demo_template " ));
65
+ $ this ->createMenuNode ($ manager , $ demo , 'type-item ' , 'Route type to controller ' , $ manager ->find (null , "$ content_path/demo_type " ));
66
+ $ this ->createMenuNode ($ manager , $ demo , 'class-item ' , 'Class to controller ' , $ manager ->find (null , "$ content_path/demo_class " ));
67
+ $ this ->createMenuNode ($ manager , $ demo , 'test-item ' , 'Normal Symfony Route ' , null , null , 'test ' );
68
+ $ this ->createMenuNode ($ manager , $ demo , 'external-item ' , 'External Link ' , null , 'http://cmf.symfony.com/ ' );
64
69
65
- $ singlelocale = $ this ->createMenuNode ($ dm , $ main , 'singlelocale-item ' , array ('en ' => 'singlelocale ' ), $ dm ->find (null , "$ content_path/singlelocale " ));
66
- $ this ->createMenuNode ($ dm , $ singlelocale , 'singlelocale-sub-item ' , array ('en ' => 'singlelocale child ' ), $ dm ->find (null , "$ content_path/singlelocale " ));
70
+ $ singlelocale = $ this ->createMenuNode ($ manager , $ main , 'singlelocale-item ' , array ('en ' => 'singlelocale ' ), $ manager ->find (null , "$ content_path/singlelocale " ));
71
+ $ this ->createMenuNode ($ manager , $ singlelocale , 'singlelocale-sub-item ' , array ('en ' => 'singlelocale child ' ), $ manager ->find (null , "$ content_path/singlelocale " ));
67
72
68
- $ seo = $ this ->createMenuNode ($ dm , $ main , 'seo ' , 'SEO ' , $ dm ->find (null , "$ content_path/simple-seo-example " ));
69
- $ this ->createMenuNode ($ dm , $ seo , 'simple-seo-example ' , array ('en ' => 'Seo-Simple-Content ' ), $ dm ->find (null , "$ content_path/simple-seo-example " ));
70
- $ this ->createMenuNode ($ dm , $ seo , 'demo-seo-extractor ' , array ('en ' => 'Seo-Extractor ' ), $ dm ->find (null , "$ content_path/demo-seo-extractor " ));
71
- $ this ->createMenuNode ($ dm , $ seo , 'simple-seo-property ' , array ('en ' => 'Seo-Extra-Properties ' ), $ dm ->find (null , "$ content_path/simple-seo-property " ));
73
+ $ seo = $ this ->createMenuNode ($ manager , $ main , 'seo ' , 'SEO ' , $ manager ->find (null , "$ content_path/simple-seo-example " ));
74
+ $ this ->createMenuNode ($ manager , $ seo , 'simple-seo-example ' , array ('en ' => 'Seo-Simple-Content ' ), $ manager ->find (null , "$ content_path/simple-seo-example " ));
75
+ $ this ->createMenuNode ($ manager , $ seo , 'demo-seo-extractor ' , array ('en ' => 'Seo-Extractor ' ), $ manager ->find (null , "$ content_path/demo-seo-extractor " ));
76
+ $ this ->createMenuNode ($ manager , $ seo , 'simple-seo-property ' , array ('en ' => 'Seo-Extra-Properties ' ), $ manager ->find (null , "$ content_path/simple-seo-property " ));
72
77
73
- $ this ->createMenuNode ($ dm , $ main , 'routing-auto-item ' , array ('en ' => 'Auto routing example ' , 'de ' => 'Auto routing beispiel ' , 'fr ' => 'Auto routing exemple ' ), $ dm ->find (null , "$ content_path/news/RoutingAutoBundle generates routes! " ));
78
+ $ this ->createMenuNode ($ manager , $ main , 'routing-auto-item ' , array ('en ' => 'Auto routing example ' , 'de ' => 'Auto routing beispiel ' , 'fr ' => 'Auto routing exemple ' ), $ manager ->find (null , "$ content_path/news/RoutingAutoBundle generates routes! " ));
74
79
75
- $ dm ->flush ();
80
+ $ manager ->flush ();
76
81
}
77
82
78
83
/**
79
84
* @return MenuNode a Navigation instance with the specified information
80
85
*/
81
- protected function createMenuNode (DocumentManager $ dm , $ parent , $ name , $ label , $ content , $ uri = null , $ route = null )
86
+ protected function createMenuNode (DocumentManager $ manager , $ parent , $ name , $ label , $ content , $ uri = null , $ route = null )
82
87
{
83
88
if (!$ parent instanceof MenuNode && !$ parent instanceof Menu) {
84
89
$ menuNode = new Menu ();
@@ -89,7 +94,7 @@ protected function createMenuNode(DocumentManager $dm, $parent, $name, $label, $
89
94
$ menuNode ->setParentDocument ($ parent );
90
95
$ menuNode ->setName ($ name );
91
96
92
- $ dm ->persist ($ menuNode ); // do persist before binding translation
97
+ $ manager ->persist ($ menuNode ); // do persist before binding translation
93
98
94
99
if (null !== $ content ) {
95
100
$ menuNode ->setContent ($ content );
@@ -102,7 +107,7 @@ protected function createMenuNode(DocumentManager $dm, $parent, $name, $label, $
102
107
if (is_array ($ label )) {
103
108
foreach ($ label as $ locale => $ l ) {
104
109
$ menuNode ->setLabel ($ l );
105
- $ dm ->bindTranslation ($ menuNode , $ locale );
110
+ $ manager ->bindTranslation ($ menuNode , $ locale );
106
111
}
107
112
} else {
108
113
$ menuNode ->setLabel ($ label );
0 commit comments