3   Entities

3.1   About the entities

The entity is a pure PHP object without any heritance.

3.2   Entities and UnitOfWork

However UnitofWork needs to know which data have been changed in the object to persist. Then UnitofWork can update the columns needed.

Your entity need to implement the pattern Observer to notify the UnitofWork about changes.

Ting provides the trait CCMBenchmark\Ting\Entity\NotifyProperty to help you.

use CCMBenchmark\Ting\Entity\NotifyProperty;

class User implements NotifyPropertyInterface
{
    use NotifyProperty;

    /**
     * @var string
     */
    private $name = '';

    /**
     * @param string $name
     */
    public function setIdContentIndexRoot($name)
    {
        $name = (string) $name;
        $this->propertyChanged('name', $this->name, $name);
        $this->name = $name;
    }

    // ...

Each time a property is changed we notify the UnitofWork through the method propertyChanged.