I have a file / class :: method, (HelperAdmin.php / HelperAdmin :: menuItem ()) retrieving data from the database for generating the main menu and subsections. In order not to execute the query to the database twice, I created a static array in its class. For some reason, after executing this method (when the menu is really formed and I see it) I cannot get this static array. It looks like this:
class HelperAdmin { static $arrMenuItems; ... public static function menuItem() { ....get $items.... self::$arrMenuItems = $items; return $items; } .... }
... i.e., if I call the method again:
$items=HelperAdmin::menuItem();
he returns everything to me as it should. If I want to get an array:
$items=HelperAdmin::$arrMenuItems;
returns null. I would like to hear some hypotheses about the reasons for this. If you think that the idea to get data from a static array is not the best from the point of view of Yii architecture - I will be glad to hear your recommendations.