literat /
srazvs
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 | namespace App\Presenters; |
||
| 4 | |||
| 5 | use Nette, |
||
| 6 | App\Model; |
||
| 7 | use Nette\Utils\ArrayHash; |
||
| 8 | use Nette\Utils\Strings; |
||
| 9 | use Nette\Http\Request; |
||
| 10 | use App\Models\SunlightModel; |
||
| 11 | use Nette\Caching\Cache; |
||
| 12 | use App\Traits\Loggable; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Base presenter for all application presenters. |
||
| 16 | */ |
||
| 17 | abstract class BasePresenter extends Nette\Application\UI\Presenter |
||
| 18 | { |
||
| 19 | |||
| 20 | use Loggable; |
||
| 21 | |||
| 22 | const FLASH_TYPE_OK = 'success'; |
||
| 23 | const FLASH_TYPE_ERROR = 'error'; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var string |
||
| 27 | */ |
||
| 28 | public $backlink = ''; |
||
| 29 | |||
| 30 | /** @var Model */ |
||
| 31 | protected $model; |
||
| 32 | |||
| 33 | /** @var Nette\DI\Container */ |
||
| 34 | protected $container; |
||
| 35 | |||
| 36 | /** @var Latte */ |
||
| 37 | protected $latte; |
||
| 38 | |||
| 39 | /** @var Router */ |
||
| 40 | protected $router; |
||
| 41 | |||
| 42 | /** @var string */ |
||
| 43 | protected $action; |
||
| 44 | |||
| 45 | /** @var Nette\Http\Request */ |
||
| 46 | protected $request; |
||
| 47 | |||
| 48 | /** @var integer */ |
||
| 49 | protected $meetingId; |
||
| 50 | |||
| 51 | protected $days = [ |
||
| 52 | 'pátek' => 'pátek', |
||
| 53 | 'sobota' => 'sobota', |
||
| 54 | 'neděle' => 'neděle', |
||
| 55 | ]; |
||
| 56 | |||
| 57 | protected $hours = [ |
||
| 58 | 0 => "00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23" |
||
| 59 | ]; |
||
| 60 | |||
| 61 | protected $minutes = [ |
||
| 62 | 00 => "00", |
||
| 63 | 05 => "05", |
||
| 64 | 10 => "10", |
||
| 65 | 15 => "15", |
||
| 66 | 20 => "20", |
||
| 67 | 25 => "25", |
||
| 68 | 30 => "30", |
||
| 69 | 35 => "35", |
||
| 70 | 40 => "40", |
||
| 71 | 45 => "45", |
||
| 72 | 50 => "50", |
||
| 73 | 55 => "55", |
||
| 74 | ]; |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Startup |
||
| 78 | */ |
||
| 79 | protected function startup() |
||
| 80 | { |
||
| 81 | parent::startup(); |
||
| 82 | |||
| 83 | $meetingId = $this->getHttpRequest()->getQuery('mid', ''); |
||
| 84 | |||
| 85 | $backlink = $this->getHttpRequest()->getQuery('backlink'); |
||
| 86 | if(!empty($backlink)) { |
||
| 87 | $this->setBacklink($backlink); |
||
| 88 | } |
||
| 89 | |||
| 90 | if($meetingId){ |
||
| 91 | $_SESSION['meetingID'] = $meetingId; |
||
| 92 | } elseif(!isset($_SESSION['meetingID'])) { |
||
| 93 | $meeting = $this->getContainer()->getService('meeting'); |
||
| 94 | $_SESSION['meetingID'] = $meeting->getLastMeetingId(); |
||
| 95 | } |
||
| 96 | |||
| 97 | $this->setMeetingId($_SESSION['meetingID']); |
||
| 98 | |||
| 99 | $model = $this->getModel(); |
||
| 100 | if($model) { |
||
| 101 | $model->setMeetingId($_SESSION['meetingID']); |
||
| 102 | } |
||
| 103 | |||
| 104 | $this->debugMode = $this->getContainer()->getParameters()['debugMode']; |
||
| 105 | } |
||
| 106 | |||
| 107 | |||
| 108 | /** |
||
| 109 | * Before render |
||
| 110 | * Prepare variables for template |
||
| 111 | */ |
||
| 112 | public function beforeRender() |
||
| 113 | { |
||
| 114 | parent::beforeRender(); |
||
| 115 | |||
| 116 | $template = $this->getTemplate(); |
||
| 117 | $meeting = $this->getContainer()->getService('meeting'); |
||
| 118 | |||
| 119 | $template->baseDir = ROOT_DIR; |
||
|
0 ignored issues
–
show
|
|||
| 120 | $template->wwwDir = HTTP_DIR; |
||
|
0 ignored issues
–
show
Accessing
wwwDir on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
| 121 | $template->cssDir = CSS_DIR; |
||
|
0 ignored issues
–
show
Accessing
cssDir on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
| 122 | $template->jsDir = JS_DIR; |
||
|
0 ignored issues
–
show
Accessing
jsDir on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
| 123 | $template->imgDir = IMG_DIR; |
||
|
0 ignored issues
–
show
Accessing
imgDir on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
| 124 | $template->catDir = CAT_DIR; |
||
|
0 ignored issues
–
show
Accessing
catDir on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
| 125 | $template->blockDir = BLOCK_DIR; |
||
|
0 ignored issues
–
show
Accessing
blockDir on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
| 126 | $template->progDir = PROG_DIR; |
||
|
0 ignored issues
–
show
Accessing
progDir on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
| 127 | $template->visitDir = VISIT_DIR; |
||
|
0 ignored issues
–
show
Accessing
visitDir on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
| 128 | $template->expDir = EXP_DIR; |
||
|
0 ignored issues
–
show
Accessing
expDir on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
| 129 | $template->meetDir = MEET_DIR; |
||
|
0 ignored issues
–
show
Accessing
meetDir on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
| 130 | |||
| 131 | $template->categories = $this->remember('categories:all', 10, function () { |
||
|
0 ignored issues
–
show
Accessing
categories on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
| 132 | return $this->getContainer()->getService('category')->all(); |
||
| 133 | }); |
||
| 134 | |||
| 135 | if(isset($_SESSION[SESSION_PREFIX.'user'])) { |
||
| 136 | $template->user = $this->getSunlight()->findUser($_SESSION[SESSION_PREFIX.'user']); |
||
|
0 ignored issues
–
show
Accessing
user on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
| 137 | } |
||
| 138 | $template->meeting = $meeting->getPlaceAndYear($_SESSION['meetingID']); |
||
|
0 ignored issues
–
show
Accessing
meeting on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
| 139 | $template->menuItems = $meeting->getMenuItems(); |
||
|
0 ignored issues
–
show
Accessing
menuItems on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
| 140 | $template->meeting_heading = $meeting->getRegHeading(); |
||
|
0 ignored issues
–
show
Accessing
meeting_heading on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
| 141 | $template->meetingId = $this->getMeetingId(); |
||
|
0 ignored issues
–
show
Accessing
meetingId on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
| 142 | $template->backlinkUrl = $this->getBacklinkUrl(); |
||
|
0 ignored issues
–
show
Accessing
backlinkUrl on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
| 143 | $template->backlink = $this->getBacklink(); |
||
|
0 ignored issues
–
show
Accessing
backlink on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
| 144 | //$this->template->backlink = $this->getParameter("backlink"); |
||
| 145 | |||
| 146 | //$this->template->production = $this->context->parameters['environment'] === 'production' ? 1 : 0; |
||
| 147 | //$this->template->version = $this->context->parameters['site']['version']; |
||
| 148 | } |
||
| 149 | |||
| 150 | /** |
||
| 151 | * template |
||
| 152 | * @var string |
||
| 153 | */ |
||
| 154 | protected $template = 'listing'; |
||
| 155 | |||
| 156 | /** |
||
| 157 | * template directory |
||
| 158 | * @var string |
||
| 159 | */ |
||
| 160 | protected $templateDir = ''; |
||
| 161 | |||
| 162 | /** |
||
| 163 | * category ID |
||
| 164 | * @var integer |
||
| 165 | */ |
||
| 166 | protected $itemId = NULL; |
||
| 167 | |||
| 168 | /** |
||
| 169 | * action what to do |
||
| 170 | * @var string |
||
| 171 | */ |
||
| 172 | protected $cms = ''; |
||
| 173 | |||
| 174 | /** |
||
| 175 | * page where to return |
||
| 176 | * @var string |
||
| 177 | */ |
||
| 178 | protected $page = ''; |
||
| 179 | |||
| 180 | /** |
||
| 181 | * heading tetxt |
||
| 182 | * @var string |
||
| 183 | */ |
||
| 184 | protected $heading = ''; |
||
| 185 | |||
| 186 | /** |
||
| 187 | * action what to do next |
||
| 188 | * @var string |
||
| 189 | */ |
||
| 190 | protected $todo = ''; |
||
| 191 | |||
| 192 | /** |
||
| 193 | * data |
||
| 194 | * @var array |
||
| 195 | */ |
||
| 196 | protected $data = array(); |
||
| 197 | |||
| 198 | /** |
||
| 199 | * error handler |
||
| 200 | * @var string |
||
| 201 | */ |
||
| 202 | protected $error = ''; |
||
| 203 | |||
| 204 | /** |
||
| 205 | * database connection |
||
| 206 | * @var string |
||
| 207 | */ |
||
| 208 | protected $database = NULL; |
||
| 209 | |||
| 210 | /** |
||
| 211 | * debug mode |
||
| 212 | * @var boolean |
||
| 213 | */ |
||
| 214 | protected $debugMode = false; |
||
| 215 | |||
| 216 | protected $sunlight; |
||
| 217 | |||
| 218 | /** |
||
| 219 | * Render check box |
||
| 220 | * |
||
| 221 | * @param string name |
||
| 222 | * @param mixed value |
||
| 223 | * @param var variable that match with value |
||
| 224 | * @return string html of chceck box |
||
| 225 | */ |
||
| 226 | protected function renderHtmlCheckBox($name, $value, $checked_variable) |
||
| 227 | { |
||
| 228 | if($checked_variable == $value) { |
||
| 229 | $checked = 'checked'; |
||
| 230 | } else { |
||
| 231 | $checked = ''; |
||
| 232 | } |
||
| 233 | $html_checkbox = "<input name='".$name."' type='checkbox' value='".$value."' ".$checked." />"; |
||
| 234 | |||
| 235 | return $html_checkbox; |
||
| 236 | } |
||
| 237 | |||
| 238 | protected function parseTutorEmail($item) |
||
| 239 | { |
||
| 240 | $mails = explode(',', $item->email); |
||
| 241 | $names = explode(',', $item->tutor); |
||
| 242 | |||
| 243 | $i = 0; |
||
| 244 | foreach ($mails as $mail) { |
||
| 245 | $mail = trim($mail); |
||
| 246 | $name = trim($names[$i]); |
||
| 247 | |||
| 248 | $recipient[$mail] = ($name) ? $name : ''; |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$recipient was never initialized. Although not strictly required by PHP, it is generally a good practice to add $recipient = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. Loading history...
|
|||
| 249 | } |
||
| 250 | |||
| 251 | return $recipient; |
||
|
0 ignored issues
–
show
The variable
$recipient does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
Loading history...
|
|||
| 252 | } |
||
| 253 | |||
| 254 | // zaheshovane udaje, aby se nedali jen tak ziskat data z databaze |
||
| 255 | protected function formKeyHash($id, $meetingId) |
||
| 256 | { |
||
| 257 | return ((int)$id . $meetingId) * 116 + 39147; |
||
| 258 | } |
||
| 259 | |||
| 260 | /** |
||
| 261 | * @return Model |
||
| 262 | */ |
||
| 263 | protected function getModel() |
||
| 264 | { |
||
| 265 | return $this->model; |
||
| 266 | } |
||
| 267 | |||
| 268 | /** |
||
| 269 | * @param Model $model |
||
| 270 | * @return $this |
||
| 271 | */ |
||
| 272 | protected function setModel($model) |
||
| 273 | { |
||
| 274 | $this->model = $model; |
||
| 275 | return $this; |
||
| 276 | } |
||
| 277 | |||
| 278 | /** |
||
| 279 | * @return Container |
||
| 280 | */ |
||
| 281 | protected function getContainer() |
||
| 282 | { |
||
| 283 | return $this->context; |
||
|
0 ignored issues
–
show
The property
$context is declared private in Nette\Application\UI\Presenter. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 284 | } |
||
| 285 | |||
| 286 | /** |
||
| 287 | * @param Container $container |
||
| 288 | * @return $this |
||
| 289 | */ |
||
| 290 | protected function setContainer($container) |
||
| 291 | { |
||
| 292 | $this->context = $container; |
||
|
0 ignored issues
–
show
The property
$context is declared private in Nette\Application\UI\Presenter. Since you implemented __set(), maybe consider adding a @property or @property-write annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
It seems like
$container of type object<App\Presenters\Container> is incompatible with the declared type object<Nette\DI\Container> of property $context.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
|
|||
| 293 | return $this; |
||
| 294 | } |
||
| 295 | |||
| 296 | /** |
||
| 297 | * @return Router |
||
| 298 | */ |
||
| 299 | protected function getRouter() |
||
| 300 | { |
||
| 301 | return $this->router; |
||
| 302 | } |
||
| 303 | |||
| 304 | /** |
||
| 305 | * @param Router $router |
||
| 306 | * @return $this |
||
| 307 | */ |
||
| 308 | protected function setRouter($router) |
||
| 309 | { |
||
| 310 | $this->router = $router; |
||
| 311 | return $this; |
||
| 312 | } |
||
| 313 | |||
| 314 | /** |
||
| 315 | * @return Latte |
||
| 316 | */ |
||
| 317 | protected function getLatte() |
||
| 318 | { |
||
| 319 | return $this->latte; |
||
| 320 | } |
||
| 321 | |||
| 322 | /** |
||
| 323 | * @param Latte $latte |
||
| 324 | * @return $this |
||
| 325 | */ |
||
| 326 | protected function setLatte($latte) |
||
| 327 | { |
||
| 328 | $this->latte = $latte; |
||
| 329 | return $this; |
||
| 330 | } |
||
| 331 | |||
| 332 | /** |
||
| 333 | * @return string |
||
| 334 | */ |
||
| 335 | public function getAction($fullyQualified = false) |
||
| 336 | { |
||
| 337 | return $this->action; |
||
| 338 | } |
||
| 339 | |||
| 340 | /** |
||
| 341 | * @param string $action |
||
| 342 | * @return $this |
||
| 343 | */ |
||
| 344 | public function setAction($action) |
||
| 345 | { |
||
| 346 | $this->action = $action; |
||
| 347 | return $this; |
||
| 348 | } |
||
| 349 | |||
| 350 | /** |
||
| 351 | * @return SunlightModel |
||
| 352 | */ |
||
| 353 | public function getSunlight() |
||
| 354 | { |
||
| 355 | if(empty($this->sunlight)) { |
||
| 356 | $this->setSunlight($this->getContainer()->getService('sunlight')); |
||
| 357 | } |
||
| 358 | |||
| 359 | return $this->sunlight; |
||
| 360 | } |
||
| 361 | |||
| 362 | /** |
||
| 363 | * @param SunlightModel $sunlight |
||
| 364 | * @return $this |
||
| 365 | */ |
||
| 366 | public function setSunlight(SunlightModel $sunlight) |
||
| 367 | { |
||
| 368 | $this->sunlight = $sunlight; |
||
| 369 | return $this; |
||
| 370 | } |
||
| 371 | |||
| 372 | /** |
||
| 373 | * @return integer |
||
| 374 | */ |
||
| 375 | protected function getMeetingId() |
||
| 376 | { |
||
| 377 | return $this->meetingId; |
||
| 378 | } |
||
| 379 | |||
| 380 | /** |
||
| 381 | * @param integer $meetingId |
||
| 382 | * @return $this |
||
| 383 | */ |
||
| 384 | protected function setMeetingId($meetingId) |
||
| 385 | { |
||
| 386 | $this->meetingId = $meetingId; |
||
| 387 | return $this; |
||
| 388 | } |
||
| 389 | |||
| 390 | /** |
||
| 391 | * @param string $guid |
||
| 392 | * @param array $data |
||
| 393 | * @return ActiveRow |
||
| 394 | */ |
||
| 395 | protected function updateByGuid($guid, array $data) |
||
| 396 | { |
||
| 397 | return $this->getModel()->updateBy('guid', $guid, $data); |
||
| 398 | } |
||
| 399 | |||
| 400 | public function remember($key, $minutes, \Closure $callback) |
||
| 401 | { |
||
| 402 | // If the item exists in the cache we will just return this immediately |
||
| 403 | // otherwise we will execute the given Closure and cache the result |
||
| 404 | // of that execution for the given number of minutes in storage. |
||
| 405 | if (! is_null($data = $this->getCache()->load($key))) { |
||
| 406 | $items = []; |
||
| 407 | |||
| 408 | foreach($data as $item) { |
||
| 409 | $object = new \stdClass(); |
||
| 410 | foreach ($item as $key => $value) { |
||
| 411 | $object->$key = $value; |
||
| 412 | } |
||
| 413 | $items[] = $object; |
||
| 414 | } |
||
| 415 | |||
| 416 | return $items; |
||
| 417 | } |
||
| 418 | |||
| 419 | $data = $callback(); |
||
| 420 | $serialized = []; |
||
| 421 | foreach ($data as $item) { |
||
| 422 | $serialized[] = $item->toArray(); |
||
| 423 | } |
||
| 424 | |||
| 425 | $this->getCache()->save( |
||
| 426 | $key, |
||
| 427 | $serialized, |
||
| 428 | [ |
||
| 429 | Cache::EXPIRE => $minutes . ' minutes', |
||
| 430 | ] |
||
| 431 | ); |
||
| 432 | |||
| 433 | return $data; |
||
| 434 | } |
||
| 435 | |||
| 436 | protected function getCache() |
||
| 437 | { |
||
| 438 | return $this->getContainer()->getService('cache'); |
||
| 439 | } |
||
| 440 | |||
| 441 | /** |
||
| 442 | * @return string |
||
| 443 | */ |
||
| 444 | protected function getDebugMode() |
||
| 445 | { |
||
| 446 | return $this->debugMode; |
||
| 447 | } |
||
| 448 | |||
| 449 | /** |
||
| 450 | * @return string |
||
| 451 | */ |
||
| 452 | protected function getBacklink() |
||
| 453 | { |
||
| 454 | return $this->backlink; |
||
| 455 | } |
||
| 456 | |||
| 457 | /** |
||
| 458 | * @param string $backlink |
||
| 459 | * @return $this |
||
| 460 | */ |
||
| 461 | protected function setBacklink($backlink) |
||
| 462 | { |
||
| 463 | $this->backlink = $backlink; |
||
| 464 | |||
| 465 | return $this; |
||
| 466 | } |
||
| 467 | |||
| 468 | /** |
||
| 469 | * @return string |
||
| 470 | */ |
||
| 471 | protected function getBacklinkUrl() |
||
| 472 | { |
||
| 473 | if($this->getBacklink()) { |
||
| 474 | return $this->link( |
||
| 475 | $this->getBacklink(), |
||
| 476 | [ |
||
| 477 | 'backlink' => null |
||
| 478 | ] |
||
| 479 | ); |
||
| 480 | } |
||
| 481 | } |
||
| 482 | |||
| 483 | /** |
||
| 484 | * @param Nette\Utils\ArrayHash $array |
||
| 485 | * @return self |
||
| 486 | */ |
||
| 487 | protected function setBacklinkFromArray(ArrayHash $array): self |
||
| 488 | { |
||
| 489 | if(array_key_exists('backlink', $array) && !empty($array['backlink'])) { |
||
| 490 | $this->setBacklink($array['backlink']); |
||
| 491 | unset($array['backlink']); |
||
| 492 | } |
||
| 493 | |||
| 494 | return $this; |
||
| 495 | } |
||
| 496 | |||
| 497 | /** |
||
| 498 | * Flashes success message |
||
| 499 | * |
||
| 500 | * @param string $message Message |
||
| 501 | */ |
||
| 502 | protected function flashSuccess(string $message = '') |
||
| 503 | { |
||
| 504 | $this->flashMessage($message, self::FLASH_TYPE_OK); |
||
| 505 | } |
||
| 506 | |||
| 507 | /** |
||
| 508 | * Flashes failure message |
||
| 509 | * |
||
| 510 | * @param string $message Message |
||
| 511 | */ |
||
| 512 | protected function flashFailure(string $message = '') |
||
| 513 | { |
||
| 514 | $this->flashMessage($message, self::FLASH_TYPE_ERROR); |
||
| 515 | } |
||
| 516 | |||
| 517 | /** |
||
| 518 | * Flashes error message |
||
| 519 | * |
||
| 520 | * @param string $message Message |
||
| 521 | */ |
||
| 522 | protected function flashError(string $message = '') |
||
| 523 | { |
||
| 524 | $this->flashMessage($message, self::FLASH_TYPE_ERROR); |
||
| 525 | } |
||
| 526 | |||
| 527 | } |
||
| 528 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: