22
33namespace nullref \cms \controllers \admin ;
44
5- use Yii ;
5+ use nullref \ admin \ components \ AdminController ;
66use nullref \cms \models \Block ;
7+ use Yii ;
78use yii \data \ActiveDataProvider ;
8- use nullref \admin \components \AdminController ;
9- use yii \web \NotFoundHttpException ;
109use yii \filters \VerbFilter ;
10+ use yii \web \NotFoundHttpException ;
1111
1212/**
1313 * BlockController implements the CRUD actions for Block model.
@@ -26,32 +26,36 @@ public function behaviors()
2626 ];
2727 }
2828
29- public function actionConfig ()
29+ public function actionConfig ($ id = null )
3030 {
3131 /** @var Block $model */
32- $ model = Yii::$ app ->session ->get ('new-block ' );
33- if (!$ model ) {
34- $ this ->redirect ('create ' );
32+ if ($ id === null ) {
33+ $ model = Yii::$ app ->session ->get ('new-block ' );
34+ if (!$ model ) {
35+ $ this ->redirect ('create ' );
36+ }
37+ } else {
38+ $ model = $ this ->findModel ($ id );
3539 }
3640 /** @var \nullref\cms\components\BlockManager $blockManager */
3741 $ blockManager = Yii::$ app ->getModule ('cms ' )->get ('blockManager ' );
3842
3943 /** @var \nullref\cms\components\Block $block */
4044 $ block = $ blockManager ->getBlock ($ model ->class_name );
4145
42- if (!$ model ->isNewRecord ){
46+ if (!$ model ->isNewRecord ) {
4347 $ block ->setAttributes ($ model ->getData ());
4448 }
4549
46- if ($ block ->load (Yii::$ app ->request ->post ()) && ($ block ->validate ())){
50+ if ($ block ->load (Yii::$ app ->request ->post ()) && ($ block ->validate ())) {
4751 $ model ->setData ($ block );
4852 $ model ->save ();
4953 Yii::$ app ->session ->remove ('new-block ' );
50- return $ this ->redirect (['view ' ,'id ' => $ model ->id ]);
54+ return $ this ->redirect (['view ' , 'id ' => $ model ->id ]);
5155 }
5256
53- return $ this ->render ('config ' ,[
54- 'block ' => $ block ,
57+ return $ this ->render ('config ' , [
58+ 'block ' => $ block ,
5559 ]);
5660 }
5761
0 commit comments