/** * preloads chunks with option preload = 1 * and push it to static array * @return array|void */ public static function preloadChunks() { if (is_null(static::$chunksByKey)) { $dependency = new TagDependency(['tags' => [ActiveRecordHelper::getCommonTag(ContentBlock::className())]]); static::$chunksByKey = ContentBlock::getDb()->cache(function ($db) { $chunks = ContentBlock::find()->where(['preload' => 1])->asArray()->all(); return ArrayHelper::map($chunks, 'key', 'value'); }, 86400, $dependency); } return static::$chunksByKey; }