1 | <?php |
||
25 | class PageManager extends TrackingManager |
||
26 | { |
||
27 | /** |
||
28 | * A reference to the collections available to this website |
||
29 | * |
||
30 | * @var ContentItem[][] |
||
31 | */ |
||
32 | private $collections; |
||
33 | |||
34 | /** |
||
35 | * A place to store a reference to static PageViews with titles |
||
36 | * |
||
37 | * @var PageView[] |
||
38 | */ |
||
39 | private $staticPages; |
||
40 | |||
41 | /** |
||
42 | * PageManager constructor |
||
43 | */ |
||
44 | 7 | public function __construct() |
|
51 | |||
52 | /** |
||
53 | * Give this manager the collections we'll be using for dynamic PageViews |
||
54 | * |
||
55 | * @param ContentItem[][] $collections |
||
56 | * @since 0.1.0 |
||
57 | */ |
||
58 | 4 | public function setCollections (&$collections) |
|
62 | |||
63 | /** |
||
64 | * Get all of the PageViews tracked by this manager |
||
65 | * |
||
66 | * @since 0.1.0 |
||
67 | * @return PageView[][] |
||
68 | */ |
||
69 | 5 | public function getAllPageViews () |
|
73 | |||
74 | /** |
||
75 | * Get the static PageViews tracked by this manager indexed by their title |
||
76 | * |
||
77 | * @since 0.1.0 |
||
78 | * @return PageView[] |
||
79 | */ |
||
80 | 1 | public function getStaticPageViews () |
|
84 | |||
85 | /** |
||
86 | * Get the jailed version of the static PageViews indexed by their title |
||
87 | * |
||
88 | * @since 0.1.0 |
||
89 | * @return JailObject[] |
||
90 | */ |
||
91 | 1 | public function getJailedStaticPageViews () |
|
92 | { |
||
93 | 1 | $jailedObjects = array(); |
|
94 | |||
95 | 1 | foreach ($this->staticPages as $key => $value) |
|
96 | { |
||
97 | 1 | $jailedObjects[$key] = $value->createJail(); |
|
98 | 1 | } |
|
99 | |||
100 | 1 | return $jailedObjects; |
|
101 | } |
||
102 | |||
103 | /** |
||
104 | * Go through all of the PageView directories and create a respective PageView for each and classify them as a |
||
105 | * dynamic or static PageView. |
||
106 | * |
||
107 | * @param string[] $pageViewFolders |
||
108 | * @since 0.1.0 |
||
109 | */ |
||
110 | 7 | public function parsePageViews ($pageViewFolders) |
|
111 | { |
||
112 | 7 | if (empty($pageViewFolders)) { return; } |
|
113 | |||
114 | 7 | foreach ($pageViewFolders as $pageViewFolderName) |
|
115 | { |
||
116 | /** @var string $pageViewFolderPath */ |
||
117 | 7 | $pageViewFolderPath = $this->fs->absolutePath($pageViewFolderName); |
|
118 | |||
119 | 7 | if (!$this->fs->exists($pageViewFolderPath)) |
|
120 | 7 | { |
|
121 | 1 | $this->output->warning("The '$pageViewFolderName' folder could not be found"); |
|
122 | 1 | continue; |
|
123 | } |
||
124 | |||
125 | 6 | $this->scanTrackableItems($pageViewFolderPath, array( |
|
126 | 'fileExplorer' => FileExplorer::INCLUDE_ONLY_FILES |
||
127 | 6 | ), array('/.html$/', '/.twig$/')); |
|
128 | 6 | } |
|
129 | 6 | } |
|
130 | |||
131 | /** |
||
132 | * Add a new ContentItem to the respective parent PageView of the ContentItem |
||
133 | * |
||
134 | * @param ContentItem $contentItem |
||
135 | * @since 0.1.0 |
||
136 | */ |
||
137 | 1 | public function trackNewContentItem (&$contentItem) |
|
138 | { |
||
139 | 1 | $collection = $contentItem->getCollection(); |
|
140 | 1 | $this->trackedItems[PageView::DYNAMIC_TYPE][$collection]->addContentItem($contentItem); |
|
141 | 1 | } |
|
142 | |||
143 | /** |
||
144 | * {@inheritdoc} |
||
145 | */ |
||
146 | 6 | protected function handleTrackableItem ($filePath, $options = array()) |
|
169 | |||
170 | /** |
||
171 | * Handle special behavior and treatment for static PageViews while we're iterating through them |
||
172 | * |
||
173 | * @param PageView $pageView |
||
174 | * @since 0.1.0 |
||
175 | */ |
||
176 | 2 | private function handleTrackableStaticPageView (&$pageView) |
|
182 | |||
183 | /** |
||
184 | * Handle special behavior and treatment for dynamic PageViews while we're iterating through them |
||
185 | * |
||
186 | * @param DynamicPageView $pageView |
||
187 | * @since 0.1.0 |
||
188 | */ |
||
189 | 4 | private function handleTrackableDynamicPageView (&$pageView) |
|
205 | } |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.