yii\behaviors\AttributeBehavior::getValue PHP Method

getValue() protected method

This method is called by AttributeBehavior::evaluateAttributes. Its return value will be assigned to the attributes corresponding to the triggering event.
protected getValue ( Event $event ) : mixed
$event yii\base\Event the event that triggers the current attribute updating.
return mixed the attribute value
    protected function getValue($event)
    {
        if ($this->value instanceof Closure || is_array($this->value) && is_callable($this->value)) {
            return call_user_func($this->value, $event);
        }
        return $this->value;
    }

Usage Example

コード例 #1
0
ファイル: SluggableBehavior.php プロジェクト: arogachev/yii2
 /**
  * @inheritdoc
  */
 protected function getValue($event)
 {
     if ($this->attribute !== null) {
         if ($this->isNewSlugNeeded()) {
             $slugParts = [];
             foreach ((array) $this->attribute as $attribute) {
                 $slugParts[] = $this->owner->{$attribute};
             }
             $slug = $this->generateSlug($slugParts);
         } else {
             return $this->owner->{$this->slugAttribute};
         }
     } else {
         $slug = parent::getValue($event);
     }
     return $this->ensureUnique ? $this->makeUnique($slug) : $slug;
 }
All Usage Examples Of yii\behaviors\AttributeBehavior::getValue