public function setValue($value, $persist = true)
    {
        if ($this->isEmpty($value) && ! $this->flags & Value::CAN_BE_EMPTY) {
            throw FailedToValidate::fromValue($value, $this);
        }

        if (! $this->isEmpty($value)) {
            $value = $this->validate($value);
        }

        if (null === $value) {
            throw FailedToValidate::fromValue($value, $this);
        }

        $this->value = $value;

        if (! $persist ) {
            return $this;
        }

        $repository  = IdentityMap::getInstance()->getRepository($this->key);
        $repository->save($this);

        return $this;
    }
public function setValue($value, $persist = true)
    {
        if ($this->isEmpty($value) && ! $this->flags & Value::CAN_BE_EMPTY) {
            throw FailedToValidate::fromValue($value, $this);
        }

        if (! $this->isEmpty($value)) {
            $value = $this->validate($value);
        }

        if (null === $value) {
            throw FailedToValidate::fromValue($value, $this);
        }

        $this->value = $value;

        if (! $persist ) {
            return $this;
        }

        $repository  = IdentityMap::getInstance()->getRepository($this->key);
        $repository->save($this);

        return $this;
    }
public function setValue ( $ value , $ persist = true ) { if ( $ this -> isEmpty ( $ value ) && ! $ this -> flags & Value :: CAN_BE_EMPTY ) { throw FailedToValidate :: fromValue ( $ value , $ this ) ; } if ( ! $ this -> isEmpty ( $ value ) ) { $ value = $ this -> validate ( $ value ) ; } if ( null === $ value ) { throw FailedToValidate :: fromValue ( $ value , $ this ) ; } $ this -> value = $ value ; if ( ! $ persist ) { return $ this ; } $ repository = IdentityMap :: getInstance ( ) -> getRepository ( $ this -> key ) ; $ repository -> save ( $ this ) ; return $ this ; }
Set the raw value.

@since 0.1.0

@param mixed $value   New raw value.
@param bool  $persist Optional. Whether to immediately persist the value.

@return Option Modified Option object. Can differ from the original one.
Set the raw value .