1 | <?php |
||
18 | class PageView extends FrontMatterDocument |
||
19 | { |
||
20 | const REPEATER_TYPE = 'repeater'; |
||
21 | const DYNAMIC_TYPE = 'dynamic'; |
||
22 | const STATIC_TYPE = 'static'; |
||
23 | |||
24 | /** |
||
25 | * @var Filesystem |
||
26 | */ |
||
27 | private static $fileSys; |
||
28 | |||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $type; |
||
33 | |||
34 | /** |
||
35 | * @var PageView[] |
||
36 | */ |
||
37 | private $children; |
||
38 | |||
39 | /** |
||
40 | * @var JailedDocument |
||
41 | */ |
||
42 | private $jailInstance; |
||
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | 32 | public function __construct($filePath) |
|
54 | |||
55 | /** |
||
56 | * {@inheritdoc} |
||
57 | */ |
||
58 | 16 | public function getObjectName() |
|
62 | |||
63 | // |
||
64 | // Twig Jail |
||
65 | // ========= |
||
66 | |||
67 | /** |
||
68 | * {@inheritdoc} |
||
69 | */ |
||
70 | 24 | public function createJail() |
|
71 | { |
||
72 | 24 | if (is_null($this->jailInstance)) |
|
73 | { |
||
74 | 24 | $this->jailInstance = (new JailedDocument($this, array_merge(self::$whiteListFunctions, array( |
|
75 | 24 | 'getUrl', |
|
76 | 24 | )), array('getChildren' => 'getJailedChildren'))); |
|
77 | } |
||
78 | |||
79 | 24 | return $this->jailInstance; |
|
80 | } |
||
81 | |||
82 | 3 | public function getJailedChildren() |
|
83 | { |
||
84 | 3 | $children = $this->children; |
|
85 | |||
86 | 3 | foreach ($children as &$child) |
|
87 | { |
||
88 | 3 | $child = $child->createJail(); |
|
89 | } |
||
90 | |||
91 | 3 | return $children; |
|
92 | } |
||
93 | |||
94 | // |
||
95 | // Getters |
||
96 | // ======= |
||
97 | |||
98 | /** |
||
99 | * Get child PageViews. |
||
100 | * |
||
101 | * A child is defined as a static PageView whose URL has a parent. For example, a PageView with a URL of |
||
102 | * `/gallery/france/` would have the PageView whose URL is `/gallery` as a parent. |
||
103 | * |
||
104 | * @return PageView[] |
||
105 | */ |
||
106 | 3 | public function &getChildren() |
|
110 | |||
111 | /** |
||
112 | * @return string Twig body |
||
113 | */ |
||
114 | 14 | public function getContent() |
|
118 | |||
119 | /** |
||
120 | * Returns the type of the PageView. |
||
121 | * |
||
122 | * @return string |
||
123 | */ |
||
124 | 20 | public function getType() |
|
128 | |||
129 | /** |
||
130 | * A fallback for the site menus that use the `url` field. |
||
131 | * |
||
132 | * @deprecated 0.1.0 |
||
133 | * |
||
134 | * @todo Remove this in the next major release |
||
135 | */ |
||
136 | public function getUrl() |
||
140 | |||
141 | // |
||
142 | // Factory |
||
143 | // ======= |
||
144 | |||
145 | /** |
||
146 | * Create the appropriate object type when parsing a PageView. |
||
147 | * |
||
148 | * @param string $filePath The path to the file that will be parsed into a PageView |
||
149 | * |
||
150 | * @return DynamicPageView|PageView|RepeaterPageView |
||
151 | */ |
||
152 | 6 | public static function create($filePath) |
|
171 | |||
172 | // |
||
173 | // Virtual PageViews |
||
174 | // ================= |
||
175 | |||
176 | /** |
||
177 | * Create a virtual PageView. |
||
178 | * |
||
179 | * @param array $frontMatter The Front Matter that this virtual PageView will have |
||
180 | * @param string $body The body of the virtual PageView |
||
181 | * |
||
182 | * @return PageView |
||
183 | */ |
||
184 | 4 | public static function createVirtual($frontMatter, $body) |
|
204 | |||
205 | /** |
||
206 | * Create a virtual PageView to create redirect files. |
||
207 | * |
||
208 | * @param string $redirectFrom The URL that will be redirecting to the target location |
||
209 | * @param string $redirectTo The URL of the destination |
||
210 | * @param string|bool $redirectTemplate The path to the template |
||
211 | * |
||
212 | * @return PageView A virtual PageView with the redirection template |
||
213 | */ |
||
214 | 4 | public static function createRedirect($redirectFrom, $redirectTo, $redirectTemplate = false) |
|
238 | } |
||
239 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: