@@ -45,11 +45,21 @@ final class PageAdmin extends AbstractAdmin
45
45
{
46
46
protected $ classnameLabel = 'Page ' ;
47
47
48
- protected ?PageManagerInterface $ pageManager = null ;
48
+ private ?PageManagerInterface $ pageManager = null ;
49
49
50
- protected ?SiteManagerInterface $ siteManager = null ;
50
+ private ?SiteManagerInterface $ siteManager = null ;
51
51
52
- public function configureRoutes (RouteCollectionInterface $ collection ): void
52
+ public function setPageManager (PageManagerInterface $ pageManager ): void
53
+ {
54
+ $ this ->pageManager = $ pageManager ;
55
+ }
56
+
57
+ public function setSiteManager (SiteManagerInterface $ siteManager ): void
58
+ {
59
+ $ this ->siteManager = $ siteManager ;
60
+ }
61
+
62
+ protected function configureRoutes (RouteCollectionInterface $ collection ): void
53
63
{
54
64
$ collection ->add ('compose ' , '{id}/compose ' , [
55
65
'id ' => null ,
@@ -61,67 +71,16 @@ public function configureRoutes(RouteCollectionInterface $collection): void
61
71
$ collection ->add ('tree ' , 'tree ' );
62
72
}
63
73
64
- public function preUpdate ($ object ): void
74
+ protected function preUpdate ($ object ): void
65
75
{
66
76
$ object ->setEdited (true );
67
77
}
68
78
69
- public function prePersist ($ object ): void
79
+ protected function prePersist ($ object ): void
70
80
{
71
81
$ object ->setEdited (true );
72
82
}
73
83
74
- public function setPageManager (PageManagerInterface $ pageManager ): void
75
- {
76
- $ this ->pageManager = $ pageManager ;
77
- }
78
-
79
- /**
80
- * @throws \RuntimeException
81
- *
82
- * @return SiteInterface|bool
83
- */
84
- public function getSite ()
85
- {
86
- if (!$ this ->hasRequest ()) {
87
- return false ;
88
- }
89
-
90
- $ siteId = null ;
91
-
92
- if ('POST ' === $ this ->getRequest ()->getMethod ()) {
93
- $ values = $ this ->getRequest ()->get ($ this ->getUniqid ());
94
- $ siteId = $ values ['site ' ] ?? null ;
95
- }
96
-
97
- $ siteId ??= $ this ->getRequest ()->get ('siteId ' );
98
-
99
- if ($ siteId ) {
100
- $ site = $ this ->siteManager ->findOneBy (['id ' => $ siteId ]);
101
-
102
- if (!$ site ) {
103
- throw new \RuntimeException ('Unable to find the site with id= ' .$ this ->getRequest ()->get ('siteId ' ));
104
- }
105
-
106
- return $ site ;
107
- }
108
-
109
- return false ;
110
- }
111
-
112
- public function setSiteManager (SiteManagerInterface $ siteManager ): void
113
- {
114
- $ this ->siteManager = $ siteManager ;
115
- }
116
-
117
- /**
118
- * @return SiteInterface[]
119
- */
120
- public function getSites ()
121
- {
122
- return $ this ->siteManager ->findBy ([]);
123
- }
124
-
125
84
protected function getAccessMapping (): array
126
85
{
127
86
return [
@@ -417,4 +376,37 @@ protected function configureTabMenu(ItemInterface $menu, string $action, ?AdminI
417
376
}
418
377
}
419
378
}
379
+
380
+ /**
381
+ * @throws \RuntimeException
382
+ *
383
+ * @return SiteInterface|bool
384
+ */
385
+ private function getSite ()
386
+ {
387
+ if (!$ this ->hasRequest ()) {
388
+ return false ;
389
+ }
390
+
391
+ $ siteId = null ;
392
+
393
+ if ('POST ' === $ this ->getRequest ()->getMethod ()) {
394
+ $ values = $ this ->getRequest ()->get ($ this ->getUniqid ());
395
+ $ siteId = $ values ['site ' ] ?? null ;
396
+ }
397
+
398
+ $ siteId ??= $ this ->getRequest ()->get ('siteId ' );
399
+
400
+ if ($ siteId ) {
401
+ $ site = $ this ->siteManager ->findOneBy (['id ' => $ siteId ]);
402
+
403
+ if (!$ site ) {
404
+ throw new \RuntimeException ('Unable to find the site with id= ' .$ this ->getRequest ()->get ('siteId ' ));
405
+ }
406
+
407
+ return $ site ;
408
+ }
409
+
410
+ return false ;
411
+ }
420
412
}
0 commit comments