This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | abstract class Ajde_Document extends Ajde_Object_Standard |
||
4 | { |
||
5 | const CACHE_CONTROL_PUBLIC = 'public'; |
||
6 | const CACHE_CONTROL_PRIVATE = 'private'; |
||
7 | const CACHE_CONTROL_NOCACHE = 'no-cache'; |
||
8 | |||
9 | protected $_cacheControl = self::CACHE_CONTROL_PUBLIC; |
||
10 | protected $_contentType = 'text/html'; |
||
11 | protected $_maxAge = 604800; // 1 week |
||
12 | |||
13 | public function __construct() |
||
14 | { |
||
15 | $this->setFormat(strtolower(str_replace('Ajde_Document_Format_', '', get_class($this)))); |
||
0 ignored issues
–
show
|
|||
16 | } |
||
17 | |||
18 | /** |
||
19 | * @param Ajde_Core_Route $route |
||
20 | * |
||
21 | * @return Ajde_Document |
||
22 | */ |
||
23 | public static function fromRoute(Ajde_Core_Route $route) |
||
24 | { |
||
25 | $format = $route->getFormat(); |
||
26 | $documentClass = 'Ajde_Document_Format_'.ucfirst($format); |
||
27 | if (!class_exists($documentClass)) { |
||
28 | $exception = new Ajde_Core_Exception_Routing("Document format $format not found", |
||
29 | 90009); |
||
30 | Ajde::routingError($exception); |
||
31 | } |
||
32 | |||
33 | return new $documentClass(); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @return Ajde_Layout |
||
38 | */ |
||
39 | public function setLayout(Ajde_Layout $layout) |
||
40 | { |
||
41 | if (!$layout instanceof Ajde_Layout) { |
||
42 | $layout = new Ajde_Layout($layout); |
||
43 | } |
||
44 | $layout->setDocument($this); |
||
45 | |||
46 | return $this->set('layout', $layout); |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * @return Ajde_Layout |
||
51 | */ |
||
52 | public function getLayout() |
||
53 | { |
||
54 | if (!$this->hasLayout()) { |
||
0 ignored issues
–
show
The method
hasLayout does not exist on object<Ajde_Document> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
![]() |
|||
55 | // Load default layout into document |
||
56 | $this->setLayout(new Ajde_Layout(config('layout.frontend'))); |
||
57 | } |
||
58 | |||
59 | return $this->get('layout'); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @param string $contents |
||
64 | */ |
||
65 | public function setBody($contents) |
||
66 | { |
||
67 | $this->set('body', $contents); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @return string |
||
72 | */ |
||
73 | public function getBody() |
||
74 | { |
||
75 | if ($this->has('body')) { |
||
76 | return $this->get('body'); |
||
77 | } else { |
||
78 | return ''; |
||
79 | } |
||
80 | } |
||
81 | |||
82 | public function setTitle($title) |
||
83 | { |
||
84 | $this->set('title', $title); |
||
85 | } |
||
86 | |||
87 | public function getTitle() |
||
88 | { |
||
89 | return $this->has('title') ? $this->get('title') : trans('Untitled page'); |
||
90 | } |
||
91 | |||
92 | public function getFullTitle() |
||
93 | { |
||
94 | $projectTitle = config('app.title'); |
||
95 | if ($this->has('title')) { |
||
96 | return sprintf(config('layout.titleFormat'), |
||
97 | $projectTitle, |
||
98 | $this->get('title') |
||
99 | ); |
||
100 | } else { |
||
101 | return $projectTitle; |
||
102 | } |
||
103 | } |
||
104 | |||
105 | public function setDescription($description) |
||
106 | { |
||
107 | $this->set('description', $description); |
||
108 | } |
||
109 | |||
110 | public function getDescription() |
||
111 | { |
||
112 | if ($this->has('description')) { |
||
113 | return $this->get('description'); |
||
114 | } else { |
||
115 | return config('app.description'); |
||
116 | } |
||
117 | } |
||
118 | |||
119 | public function setAuthor($author) |
||
120 | { |
||
121 | $this->set('author', $author); |
||
122 | } |
||
123 | |||
124 | public function getAuthor() |
||
125 | { |
||
126 | if ($this->has('author')) { |
||
127 | return $this->get('author'); |
||
128 | } else { |
||
129 | return config('app.author'); |
||
130 | } |
||
131 | } |
||
132 | |||
133 | public function render() |
||
134 | { |
||
135 | return $this->getLayout()->getContents(); |
||
136 | } |
||
137 | |||
138 | public function getCacheControl() |
||
139 | { |
||
140 | return $this->_cacheControl; |
||
141 | } |
||
142 | |||
143 | public function setCacheControl($cacheControl) |
||
144 | { |
||
145 | $this->_cacheControl = $cacheControl; |
||
146 | } |
||
147 | |||
148 | public function getContentType() |
||
149 | { |
||
150 | return $this->_contentType; |
||
151 | } |
||
152 | |||
153 | public function setContentType($mimeType) |
||
154 | { |
||
155 | $this->_contentType = $mimeType; |
||
156 | } |
||
157 | |||
158 | public function getMaxAge() |
||
159 | { |
||
160 | return (int) $this->_maxAge; |
||
161 | } |
||
162 | |||
163 | public function setMaxAge($days) |
||
164 | { |
||
165 | $this->_maxAge = (int) (60 * 60 * 24 * $days); |
||
166 | } |
||
167 | |||
168 | /** |
||
169 | * @param Ajde_Resource $resource |
||
170 | */ |
||
171 | public function addResource(Ajde_Resource $resource) |
||
172 | { |
||
173 | } |
||
174 | |||
175 | public function getResourceTypes() |
||
176 | { |
||
177 | } |
||
178 | |||
179 | // Render helpers |
||
180 | |||
181 | /** |
||
182 | * @deprecated |
||
183 | * |
||
184 | * @throws Ajde_Core_Exception_Deprecated |
||
185 | */ |
||
186 | protected function setContentTypeHeader($contentType = null) |
||
0 ignored issues
–
show
|
|||
187 | { |
||
188 | throw new Ajde_Core_Exception_Deprecated(); |
||
189 | } |
||
190 | |||
191 | /** |
||
192 | * @deprecated |
||
193 | * |
||
194 | * @throws Ajde_Core_Exception_Deprecated |
||
195 | */ |
||
196 | protected function setCacheControlHeader($cacheControl = null) |
||
0 ignored issues
–
show
|
|||
197 | { |
||
198 | throw new Ajde_Core_Exception_Deprecated(); |
||
199 | } |
||
200 | |||
201 | public static function registerDocumentProcessor($format, $registerOn = 'layout') |
||
202 | { |
||
203 | $documentProcessors = config('layout.filters.documentProcessors'); |
||
204 | if (is_array($documentProcessors) && isset($documentProcessors[$format])) { |
||
205 | foreach ($documentProcessors[$format] as $processor) { |
||
206 | $processorClass = 'Ajde_Document_Processor_'.ucfirst($format).'_'.$processor; |
||
207 | if (!class_exists($processorClass)) { |
||
208 | // TODO: |
||
209 | throw new Ajde_Exception('Processor '.$processorClass.' not found', 90022); |
||
210 | } |
||
211 | if ($registerOn == 'layout') { |
||
212 | Ajde_Event::register('Ajde_Layout', 'beforeGetContents', $processorClass.'::preProcess'); |
||
213 | Ajde_Event::register('Ajde_Layout', 'afterGetContents', $processorClass.'::postProcess'); |
||
214 | } elseif ($registerOn == 'compressor') { |
||
215 | Ajde_Event::register('Ajde_Resource_Local_Compressor', 'beforeCompress', |
||
216 | $processorClass.'::preCompress'); |
||
217 | Ajde_Event::register('Ajde_Resource_Local_Compressor', 'afterCompress', |
||
218 | $processorClass.'::postCompress'); |
||
219 | } else { |
||
220 | // TODO: |
||
221 | throw new Ajde_Exception('Document processor must be registered on either \'layout\' or \'compressor\''); |
||
222 | } |
||
223 | } |
||
224 | } |
||
225 | } |
||
226 | } |
||
227 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: