Example #1
0
 /**
  * Check if the given attribute on the given model is dirty.
  *
  * @param  \TYPO3\CMS\Extbase\DomainObject\AbstractEntity  $entity  Entity
  * @param  string  $attr  Lower camel-cased attribute name
  * @return  boolean
  */
 protected function isDirty(AbstractEntity $entity, $attr)
 {
     $attr = (string) $attr;
     if ($entity->_isDirty($attr)) {
         $cls = str_replace('\\', '_', get_class($entity));
         $uid = (string) $entity->getUid();
         $val = $entity->{'get' . ucwords($attr)}();
         if (!isset($this->dirty[$cls])) {
             $this->dirty[$cls] = [];
         }
         if (!isset($this->dirty[$cls][$uid])) {
             $this->dirty[$cls][$uid] = [];
         }
         if (!isset($this->dirty[$cls][$uid][$attr])) {
             $this->dirty[$cls][$uid][$attr] = null;
         }
         if ($this->dirty[$cls][$uid][$attr] !== $val) {
             $this->dirty[$cls][$uid][$attr] = $val;
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }