echo ModelHelper::basename($generator->helperModel->getClass(ModelHelper::RK_QUERY)); ?> extends <?php echo ModelHelper::root($generator->helperModel->getParentClass(ModelHelper::RK_QUERY)); ?> { /** * @inheritdoc * @return string */ protected function modelClass() { return <?php echo ModelHelper::basename($generator->helperModel->getClass(ModelHelper::RK_MODEL_CM)); ?> ::className(); } /** * @inheritdoc * @return string */ protected function modelTable() { return <?php echo ModelHelper::basename($generator->helperModel->getClass(ModelHelper::RK_MODEL_CM)); ?> ::tableName(); } }
/** * Retrieves behavior specification * @return array behavior specification */ public function getBehaviorsToGenerate() { $behaviors = []; if ($this->generateMutation) { $modelClassName = ModelHelper::root($this->helperModel->getClass(ModelHelper::RK_MODEL_CM, $this->getClassName($this->mutationJoinTableName))); $db = $this->getDbConnection(); $tableSchema = $db->getTableSchema($this->mutationJoinTableName); $mutationableAttrs = array_diff($tableSchema->columnNames, $tableSchema->primaryKey); $behaviors[Module::BEHAVIOR_NAME_MUTATION] = ['class' => '\\dlds\\rels\\components\\Behavior::className()', 'config' => [sprintf('%s::className()', $modelClassName), sprintf('%s::%s%s', $modelClassName, Module::RELATION_NAME_PREFIX, strtoupper($this->tableName)), sprintf('%s::%s%s', $modelClassName, Module::RELATION_NAME_PREFIX, strtoupper($this->mutationSourceTableName)), sprintf('self::%s%s', Module::RELATION_NAME_PREFIX, Module::RELATION_NAME_MUTATION_CURRENT)], 'attrs' => $mutationableAttrs]; } if ($this->generateGalleryBehavior) { $helperClassName = ModelHelper::basename($this->helperModel->getClass(ModelHelper::RK_HELPER_IMAGE)); $behaviors[Module::BEHAVIOR_NAME_GALLERY_MANAGER] = ['class' => '\\dlds\\galleryManager\\GalleryBehavior::className()', 'type' => sprintf('%s::getType()', $helperClassName), 'directory' => sprintf('%s::getDirectory()', $helperClassName), 'url' => sprintf('%s::getUrl()', $helperClassName), 'versions' => sprintf('%s::getVersions()', $helperClassName), 'extension' => sprintf('%s::getExtension()', $helperClassName), 'tableName' => $this->galleryTableName]; } if ($this->generateTimestampBehavior) { $behaviors[Module::BEHAVIOR_NAME_TIMESTAMP] = ['class' => '\\yii\\behaviors\\TimestampBehavior::className()']; if ($this->timestampCreatedAtAttribute && self::DEFAULT_TIMESTAMP_CREATED_AT_ATTR != $this->timestampCreatedAtAttribute) { $behaviors[Module::BEHAVIOR_NAME_TIMESTAMP]['createdAtAttribute'] = $this->timestampCreatedAtAttribute; } if ($this->timestampUpdatedAtAttribute && self::DEFAULT_TIMESTAMP_UPDATED_AT_ATTR != $this->timestampUpdatedAtAttribute) { $behaviors[Module::BEHAVIOR_NAME_TIMESTAMP]['updatedAtAttribute'] = $this->timestampUpdatedAtAttribute; } } if ($this->generateSortableBehavior) { $behaviors[Module::BEHAVIOR_NAME_SORTABLE] = ['class' => '\\dlds\\sortable\\components\\Behavior::className()']; if ($this->sortableKeyAttribute) { $behaviors[Module::BEHAVIOR_NAME_SORTABLE]['key'] = $this->sortableKeyAttribute; } if ($this->sortableColumnAttribute) { $behaviors[Module::BEHAVIOR_NAME_SORTABLE]['column'] = $this->sortableColumnAttribute; } if ($this->sortableIndexAttribute) { $behaviors[Module::BEHAVIOR_NAME_SORTABLE]['index'] = $this->sortableIndexAttribute; } if ($this->sortableRestrictionsAttribute) { $behaviors[Module::BEHAVIOR_NAME_SORTABLE]['restrictions'] = explode(',', $this->sortableRestrictionsAttribute); } } if ($this->generateSluggableBehavior) { $behaviors[Module::BEHAVIOR_NAME_SLUGGABLE] = ['class' => '\\yii\\behaviors\\SluggableBehavior::className()']; $behaviors[Module::BEHAVIOR_NAME_SLUGGABLE]['attribute'] = explode(',', $this->sluggableBehaviorSourceAttribute); $behaviors[Module::BEHAVIOR_NAME_SLUGGABLE]['slugAttribute'] = $this->sluggableBehaviorTargetAttribute; $behaviors[Module::BEHAVIOR_NAME_SLUGGABLE]['ensureUnique'] = $this->getBooleanQuoted($this->sluggableBehaviorEnsureUnique); $behaviors[Module::BEHAVIOR_NAME_SLUGGABLE]['immutable'] = $this->getBooleanQuoted($this->sluggableBehaviorImutable); } return $behaviors; }