55use nullref \cms \models \Block as BlockModel ;
66use yii \base \Component ;
77use yii \base \InvalidConfigException ;
8+ use yii \caching \TagDependency ;
89use yii \helpers \ArrayHelper ;
910use Yii ;
1011
@@ -39,14 +40,14 @@ public function register($id, $namespace)
3940 * @param $id
4041 * @param $config
4142 * @return \nullref\cms\components\Widget
42- * @throws \yii\base\InvalidConfigException
43+ * @throws \yii\base\InvalidConfigException | \Exception
4344 */
4445 public function getWidget ($ id , $ config = [])
4546 {
4647 /** @var BlockModel $block */
4748 $ block = BlockModel::getDb ()->cache (function () use ($ id ) {
4849 return BlockModel::find ()->where (['id ' => $ id ])->one ();
49- });
50+ }, null , new TagDependency ([ ' tags ' => ' cms.block. ' . $ id ]) );
5051 if ($ block ) {
5152 $ config = ArrayHelper::merge ($ config , $ block ->getData ());
5253 $ config ['class ' ] = $ this ->getList ()[$ block ->class_name ] . self ::CLASS_WIDGET ;
@@ -56,6 +57,7 @@ public function getWidget($id, $config = [])
5657 'id ' => $ id ,
5758 ];
5859 }
60+ /** @var \nullref\cms\components\Widget $widget */
5961 $ widget = Yii::createObject ($ config );
6062 if (method_exists ($ widget , 'setBlock ' )) {
6163 /** @var Block $blockObj */
@@ -67,6 +69,9 @@ public function getWidget($id, $config = [])
6769 return $ widget ;
6870 }
6971
72+ /**
73+ * @return array
74+ */
7075 public function getList ()
7176 {
7277 return array_merge ($ this ->blocks , $ this ->_blocks , [
@@ -81,11 +86,13 @@ public function getList()
8186
8287 /**
8388 * @param $id
84- * @return \nullref\cms\components\Block
89+ * @param array $params
90+ * @return Block
8591 * @throws \yii\base\InvalidConfigException
8692 */
8793 public function getBlock ($ id , $ params = [])
8894 {
95+ /** @var \nullref\cms\components\Block $object */
8996 $ object = Yii::createObject ($ this ->getList ()[$ id ] . self ::CLASS_BLOCK );
9097 Yii::configure ($ object , $ params );
9198 return $ object ;
0 commit comments