本文整理汇总了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;
}
示例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}");
}
}
示例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;
}