当前位置: 首页>>代码示例>>PHP>>正文


PHP Generator::load方法代码示例

本文整理汇总了PHP中yii\gii\Generator::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Generator::load方法的具体用法?PHP Generator::load怎么用?PHP Generator::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\gii\Generator的用法示例。


在下文中一共展示了Generator::load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: load

 public function load($data, $formName = null)
 {
     $result = parent::load($data, $formName);
     // TODO: Change the autogenerated stub
     if (isset($data['Generator'])) {
         foreach ($data['Generator'] as $attr => $value) {
             if (is_array($value)) {
                 $this->{$attr} = new BaseModelGenerator(ArrayHelper::merge($value, ['additionName' => 'Generator[' . $attr . ']', 'createForm' => false, 'customBehaviors' => ['trans' => ['title' => 'Multilingual behavior', 'alias' => 'trans', 'checked' => true, 'languageField' => $this->languageField ?: 'language', 'langClassSuffix' => '', 'dynamicLangClass' => false, 'requireTranslations' => false, 'abridge' => false, 'langForeignKey' => '', 'attributesLang' => 'title, body, lang', 'langClassName' => '', 'languages' => null, 'class' => 'omgdef\\multilingual\\MultilingualBehavior']], 'addUseQuery' => $attr == 'baseModel' ? 'use omgdef\\multilingual\\MultilingualTrait;' . PHP_EOL : '', 'addTraitsQuery' => $attr == 'baseModel' ? 'use MultilingualTrait;' . PHP_EOL : '', 'translateGenerator' => $attr == 'baseModel' ? true : false]));
                 $this->{$attr}->tableBuilder = new TableGenerator($value['tableBuilder']);
                 $this->{$attr}->behaviorModels = [];
                 foreach ($value['behaviorModels'] as $_next) {
                     $this->{$attr}->behaviorModels[] = new Behaviors($_next);
                 }
             } else {
                 $this->{$attr} = $value;
             }
         }
         $result = $this->baseModel->validate();
         if (!$result) {
             $this->addError('baseModel', 'Base model error data');
         }
         $result = $this->translateModel->validate();
         if (!$result) {
             $this->addError('translateModel', 'Translate model error data');
         }
         $tblName = $this->baseModel->createTable ? $this->baseModel->tableBuilder->tableName : $this->baseModel->tableName;
         $table_name = preg_replace('/({{%)(\\w+)(}})?/', "\$2", $tblName);
         $db = $this->baseModel->db;
         /** @var Connection $_conn */
         $_conn = Yii::$app->{$db};
         $this->translateModel->addNewField($_conn->schema->getRawTableName($table_name) . '_' . $this->baseModel->tableBuilder->primaryKeyName, Schema::TYPE_INTEGER, 'Origin content', $tblName, $this->baseModel->tableBuilder->primaryKeyName);
     }
     return $result;
 }
开发者ID:infinitydevphp,项目名称:infinity-gii,代码行数:34,代码来源:Generator.php

示例2: loadGenerator

 /**
  * Loads the generator with the specified ID.
  * @param  string                $id the ID of the generator to be loaded.
  * @return \yii\gii\Generator    the loaded generator
  * @throws NotFoundHttpException
  */
 protected function loadGenerator($id)
 {
     if (isset($this->module->generators[$id])) {
         $this->generator = $this->module->generators[$id];
         $this->generator->loadStickyAttributes();
         $this->generator->load($_POST);
         return $this->generator;
     } else {
         throw new NotFoundHttpException("Code generator not found: {$id}");
     }
 }
开发者ID:syedmaaz,项目名称:marxmall-,代码行数:17,代码来源:DefaultController.php

示例3: load

 /**
  * @inheritdoc
  */
 public function load($data, $formName = null)
 {
     if (!parent::load($data, $formName)) {
         return false;
     }
     $this->migrationName = preg_replace('/\\s+/', '_', $this->migrationName);
     $dataFix = ['Table' => [], 'Column' => []];
     if (isset($data['Table'])) {
         foreach ($data['Table'] as $temp) {
             $dataFix['Table'][] = $temp;
         }
     }
     if (isset($data['Column'])) {
         foreach ($data['Column'] as $temp) {
             $columnFix = [];
             foreach ($temp as $colTemp) {
                 $columnFix[] = $colTemp;
             }
             $temp = $columnFix;
             $dataFix['Column'][] = $temp;
         }
     }
     if (isset($data['Index'])) {
         foreach ($data['Index'] as $temp) {
             $dataFix['Index'][] = $temp;
         }
     }
     if (isset($data['ForeignKey'])) {
         foreach ($data['ForeignKey'] as $temp) {
             $dataFix['ForeignKey'][] = $temp;
         }
     }
     $data = $dataFix;
     if (isset($data['Table'])) {
         $this->tables = static::createMultiple(Table::className(), [], $data);
         Table::loadMultiple($this->tables, $data);
         $loadData = [];
         for ($i = 0; $i < count($this->tables); ++$i) {
             $loadData['Column'] = $data['Column'][$i];
             $this->tables[$i]->columns = static::createMultiple(Column::className(), [], $loadData);
             $this->tables[$i]->isNewRecord = false;
             Column::loadMultiple($this->tables[$i]->columns, $loadData);
         }
     } else {
         $this->tables = [new Table()];
     }
     if (isset($data['Index'])) {
         $this->indices = static::createMultiple(Index::className(), [], $data);
         Index::loadMultiple($this->indices, $data);
         foreach ($this->indices as $index) {
             $index->isNewRecord = false;
         }
     } else {
         $this->indices = [new Index()];
     }
     if (isset($data['ForeignKey'])) {
         $this->foreignKeys = static::createMultiple(ForeignKey::className(), [], $data);
         ForeignKey::loadMultiple($this->foreignKeys, $data);
         foreach ($this->foreignKeys as $fKey) {
             $fKey->isNewRecord = false;
         }
     } else {
         $this->foreignKeys = [new ForeignKey()];
     }
     return true;
 }
开发者ID:blumster,项目名称:yii2-gii-migration-designer,代码行数:69,代码来源:Generator.php


注:本文中的yii\gii\Generator::load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。