Final Class Yiisoft\Yii\Gii\Generator\ActiveRecord\Command
| Inheritance | Yiisoft\Yii\Gii\Generator\ActiveRecord\Command » Yiisoft\Yii\Gii\Generator\AbstractGeneratorCommand |
|---|---|
| Implements | Yiisoft\Yii\Gii\GeneratorCommandInterface |
Protected Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $template | string | Yiisoft\Yii\Gii\Generator\ActiveRecord\Command |
Public Methods
Property Details
Method Details
| public __construct( string $namespace = 'App\\Model', string $tableName = 'user', string $baseClass = ActiveRecord::class, string $template = 'default' ): mixed | ||
| $namespace | string | |
| $tableName | string | |
| $baseClass | string | |
| $template | string | |
public function __construct(
#[Required]
#[Regex(
pattern: '/^(?:[a-z][a-z0-9]*)(?:\\\\[a-z][a-z0-9]*)*$/i',
message: 'Invalid namespace'
)]
private readonly string $namespace = 'App\\Model',
#[Required]
#[Regex(
pattern: '/^[\w\-.]+$/i',
message: 'Invalid table name'
)]
#[TableExistsRule]
private readonly string $tableName = 'user',
#[Regex(
pattern: '/^[a-z\\\\]*$/i',
message: 'Only word characters and backslashes are allowed.',
skipOnEmpty: true,
)]
#[ClassExistsRule]
private readonly string $baseClass = ActiveRecord::class,
#[Required(message: 'A code template must be selected.')]
#[TemplateRule]
protected string $template = 'default',
) {
parent::__construct($template);
}
| public static getAttributeLabels( ): array |
public static function getAttributeLabels(): array
{
return [
'namespace' => 'Model namespace',
'baseClass' => 'Base class',
'tableName' => 'Table name',
'template' => 'Template',
];
}
| public static getAttributes( ): array |
public static function getAttributes(): array
{
return [
'namespace',
'tableName',
'baseClass',
'template',
];
}
| public static getHints( ): array |
public static function getHints(): array
{
return [
'namespace' => 'Namespace for the model class to store it in the related directory.',
'baseClass' => 'Parent class for the new model class.',
'tableName' => 'Corresponded table name for the model class.',
];
}
| public getModelName( ): string |
public function getModelName(): string
{
return (new Inflector())->tableToClass($this->tableName);
}
| public getTemplate( ): string |
public function getTemplate(): string
{
return $this->template;
}
Signup or Login in order to comment.