yii\gii\generators\model\Generator::validateNamespace PHP Method

validateNamespace() public method

Validates the namespace.
public validateNamespace ( string $attribute )
$attribute string Namespace variable.
    public function validateNamespace($attribute)
    {
        $value = $this->{$attribute};
        $value = ltrim($value, '\\');
        $path = Yii::getAlias('@' . str_replace('\\', '/', $value), false);
        if ($path === false) {
            $this->addError($attribute, 'Namespace must be associated with an existing directory.');
        }
    }

Usage Example

示例#1
0
 /**
  * Validates the [[ns]] attribute.
  */
 public function validateNamespace($attribute)
 {
     parent::validateNamespace($attribute);
     $this->ns = ltrim($this->ns, '\\');
     if (false === strpos($this->ns, 'app\\')) {
         $this->addError('ns', '@app namespace must be used.');
     }
 }
All Usage Examples Of yii\gii\generators\model\Generator::validateNamespace