/**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     // set upload config
     $this->uploadConfig = [$this->crudModelsClass['main'] => []];
     $this->on(self::EVENT_DELETE, function ($event) {
         foreach ($event->extraData['models'] as $model) {
             CmsWidgetService::refreshWidget($model->id);
         }
     });
     $this->on(self::EVENT_SAVE_EDIT, function ($event) {
         CmsWidgetService::refreshWidget($event->extraData['models']['main']->id);
     });
 }
 /**
  * Parse Widget
  * @param string $html Html to parse
  * @return mixed
  */
 protected function parseWidget($html)
 {
     $list = array();
     preg_match_all("#\\<cms_widget id=\"(.*)\">(.*)</cms_widget>#msU", $html, $list, PREG_SET_ORDER);
     $find = [];
     $replace = [];
     foreach ($list as $function) {
         // cache key
         $cacheKey = 'cms_widget_id:' . $function[1];
         // get model from cache
         if (($widgetModel = Yii::$app->commonCache->get($cacheKey)) === false) {
             $widgetModel = CmsWidget::find()->where(['id' => $function[1]])->asArray()->one();
             Yii::$app->commonCache->set($cacheKey, $widgetModel, CmsWidgetService::$cacheDuration, new TagDependency(['tags' => [CmsWidgetService::getCacheTag(), CmsWidgetService::getCacheTag($function[1])]]));
         }
         if ($widgetModel !== null) {
             $arg = json_decode($widgetModel['arg'], true);
             if ($arg === null) {
                 $arg = [];
             }
             $widget = $widgetModel['path'];
             $find[] = '<cms_widget id="' . $function[1] . '">' . $function[2] . '</cms_widget>';
             $replace[] = $widget::widget($arg);
         }
     }
     return str_replace($find, $replace, $html);
 }