Source of file OptionsEntity.php

Size: 0,899 Bytes - Last Modified: 2020-10-24T02:46:31+00:00

/home/travis/build/NextDom/nextdom-core/src/Model/Entity/Parents/OptionsEntity.php

12345678910111213141516171819202122232425262728293031323334353637383940
<?php

namespace NextDom\Model\Entity\Parents;

use NextDom\Helpers\Utils;

trait OptionsEntity
{
    abstract public function updateChangeState($oldValue, $newValue);

    /**
     * @var string
     *
     * @ORM\Column(name="options", type="text", length=65535, nullable=true)
     */
    protected $options;

    /**
     * @param string $_key
     * @param string $_default
     * @return array|bool|mixed|null|string
     */
    public function getOptions($_key = '', $_default = '')
    {
        return Utils::getJsonAttr($this->options, $_key, $_default);
    }

    /**
     * @param $_key
     * @param $_value
     * @return $this
     */
    public function setOptions($_key, $_value)
    {
        $options = Utils::setJsonAttr($this->options, $_key, $_value);
        $this->updateChangeState($this->options, $options);
        $this->options = $options;
        return $this;
    }
}