src/models/StructureTranslation.php
public function validateUrl($attribute, $params)
    {
        $parentParentId = (null === $this->structure) ? 0 : (int)$this->structure->parent_id;
        $parentContextId = (null === $this->structure) ? 0 : (int)$this->structure->context_id;
        if (
            $this->slug != $this->oldSlug
            || $this->parentParentId !== $parentParentId
            || $this->parentContextId !== $parentContextId
        ) {
            $url = $this->compileUrl();
            $query = self::find()
                ->select('url')
                ->innerJoin(
                    BaseStructure::tableName(),
                    'model_id = ' . BaseStructure::tableName() . '.id'
                )
                ->where([
                    'language_id' => $this->language_id,
                    'context_id' => $this->parentContextId,
                    'url' => $url
                ]);
            if (false === $this->isNewRecord) {
                $query->andWhere(['not', ['model_id' => $this->model_id]]);
            }
            $isset = $query->scalar();
            if (false !== $isset) {
                $this->addError('slug', Yii::t(
                    'dotplant.entity.structure',
                    'Value \'{value}\' already in use, please, choose another!',
                    ['value' => $this->slug]
                ));
            }
            $this->url = $url;
        }
    }
public function validateUrl($attribute, $params)
    {
        $parentParentId = (null === $this->structure) ? 0 : (int)$this->structure->parent_id;
        $parentContextId = (null === $this->structure) ? 0 : (int)$this->structure->context_id;
        if (
            $this->slug != $this->oldSlug
            || $this->parentParentId !== $parentParentId
            || $this->parentContextId !== $parentContextId
        ) {
            $url = $this->compileUrl();
            $query = self::find()
                ->select('url')
                ->innerJoin(
                    BaseStructure::tableName(),
                    'model_id = ' . BaseStructure::tableName() . '.id'
                )
                ->where([
                    'language_id' => $this->language_id,
                    'context_id' => $this->parentContextId,
                    'url' => $url
                ]);
            if (false === $this->isNewRecord) {
                $query->andWhere(['not', ['model_id' => $this->model_id]]);
            }
            $isset = $query->scalar();
            if (false !== $isset) {
                $this->addError('slug', Yii::t(
                    'dotplant.entity.structure',
                    'Value \'{value}\' already in use, please, choose another!',
                    ['value' => $this->slug]
                ));
            }
            $this->url = $url;
        }
    }
public function validateUrl ( $ attribute , $ params ) { $ parentParentId = ( null === $ this -> structure ) ? 0 : ( int ) $ this -> structure -> parent_id ; $ parentContextId = ( null === $ this -> structure ) ? 0 : ( int ) $ this -> structure -> context_id ; if ( $ this -> slug != $ this -> oldSlug || $ this -> parentParentId !== $ parentParentId || $ this -> parentContextId !== $ parentContextId ) { $ url = $ this -> compileUrl ( ) ; $ query = self :: find ( ) -> select ( 'url' ) -> innerJoin ( BaseStructure :: tableName ( ) , 'model_id = ' . BaseStructure :: tableName ( ) . '.id' ) -> where ( [ 'language_id' => $ this -> language_id , 'context_id' => $ this -> parentContextId , 'url' => $ url ] ) ; if ( false === $ this -> isNewRecord ) { $ query -> andWhere ( [ 'not' , [ 'model_id' => $ this -> model_id ] ] ) ; } $ isset = $ query -> scalar ( ) ; if ( false !== $ isset ) { $ this -> addError ( 'slug' , Yii :: t ( 'dotplant.entity.structure' , 'Value \'{value}\' already in use, please, choose another!' , [ 'value' => $ this -> slug ] ) ) ; } $ this -> url = $ url ; } }
Validates url to be unique among other in one context and in one language range

@param $attribute
@param $params
Validates url to be unique among other in one context and in one language range