Webiny\Component\Entity\Attribute\AbstractAttribute::setValue PHP Method

setValue() public method

Set attribute value
public setValue ( null $value = null, boolean $fromDb = false )
$value null Attribute value
$fromDb boolean Is value coming from DB?
    public function setValue($value = null, $fromDb = false)
    {
        if ($fromDb) {
            $this->value = $this->processFromDbValue($value);
            return $this;
        }
        if (!$this->canAssign()) {
            return $this;
        }
        $value = $this->processSetValue($value);
        $this->validate($value);
        $this->value = $value;
        return $this;
    }

Usage Example

Example #1
0
 public function setValue($value = null, $fromDb = false)
 {
     if ($this->isNull($value)) {
         $value = new ArrayObject();
     }
     if ($fromDb && $value instanceof BSONArray) {
         $value = $this->convertToArray($value->getArrayCopy());
     }
     parent::setValue($value, $fromDb);
     $this->value = $this->arr($this->value);
     return $this;
 }
All Usage Examples Of Webiny\Component\Entity\Attribute\AbstractAttribute::setValue