Source of file ConfigurationEntity.php

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

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

12345678910111213141516171819202122232425262728293031323334353637383940
<?php

namespace NextDom\Model\Entity\Parents;

use NextDom\Helpers\Utils;

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

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

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

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