php if in_array controller blog index category search categories this-

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<?php
if(in_array($controller, ['blog', 'index', 'category', 'search'])){
$categories = $this->cached->get('categories.cache');
if ($categories === null) {
$categories = Categories::find();
$this->cached->save('categories.cache', $categories);
}
$this->view->setVar(
'categories', $categories
);
}