示例#1
0
<div class="module-index">
    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
$form = ActiveForm::begin();
?>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => ['class', 'description', ['attribute' => 'moduleName', 'format' => 'raw', 'value' => function ($data) {
    $form = ActiveForm::begin();
    return $form->field($data, 'moduleName')->label('')->textInput(['name' => "Item[{$data->id}][moduleName]"]);
}], ['attribute' => 'installed', 'format' => 'raw', 'value' => function ($data) {
    /**
     * @var Item $data
     */
    $attributes = ['class' => 'form-control'];
    if ($data->class == \bariew\moduleModule\Module::className()) {
        $attributes['onclick'] = 'if (!confirm("' . Yii::t('modules/module', "This module is critically important") . '")){return false;} ';
    }
    return ($data->isInstalled() ? Html::a('<span class="glyphicon glyphicon-wrench"></span>', ['params', 'id' => $data->id], ['class' => 'pull-right']) : "") . Html::checkbox("Item[{$data->id}][installed]", $data->installed, $attributes);
}]]]);
?>
    <?php 
echo Html::submitButton(Yii::t('modules/module', "Save"), ['class' => 'btn btn-primary']);
?>
    <?php 
ActiveForm::end();
?>
</div>
示例#2
0
 public static function migrate($actions)
 {
     if (!$actions) {
         return true;
     }
     /**
      * @var MigrateController $controller
      */
     $controller = new ModuleMigrateController('migrate', self::getModuleByClassName(Module::className()));
     $controller->interactive = false;
     ob_start();
     defined('STDOUT') or define('STDOUT', 'php://stdout');
     foreach ($actions as $action) {
         $controller->runAction($action[0], $action[1]);
     }
     ob_clean();
     Yii::$app->cache->flush();
     return true;
 }