Source of file BaseEntity.php

Size: 1,196 Bytes - Last Modified: 2020-10-24T02:46:31+00:00

/home/travis/build/NextDom/nextdom-core/src/Model/BaseEntity.php

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
<?php

namespace NextDom\Model;

use NextDom\Helpers\Utils;

abstract class BaseEntity implements \NextDom\Interfaces\EntityInterface
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    protected $id;

    /**
     * @var bool State of changes
     */
    protected $_changed = false;

    /**
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @param $_id
     * @return $this
     */
    public function setId($_id)
    {
        $this->_changed = Utils::attrChanged($this->_changed, $this->id, $_id);
        $this->id = $_id;
        return $this;
    }

    /**
     * Get changed state
     *
     * @return bool True if attribute has changed
     */
    public function getChanged()
    {
        return $this->_changed;
    }

    /**
     * Set changed state
     *
     * @param bool $changed New changed state
     *
     * @return $this
     */
    public function setChanged($changed)
    {
        $this->_changed = $changed;
        return $this;
    }

    abstract function save();
    abstract function remove();
}