Exemplo n.º 1
0
 /**
  * {@inheritDoc}
  * @see \Fixin\Model\Repository\RepositoryInterface::save($entity)
  */
 public function save(EntityInterface $entity) : EntityIdInterface
 {
     $set = $entity->collectSaveData();
     if ($oldId = $entity->getEntityId()) {
         $request = $this->createRequest();
         $request->getWhere()->id($oldId);
         $this->getStorage()->update($set, $request);
         $id = array_replace($oldId->getArrayCopy(), Arrays::intersectByKeys($set, $this->primaryKey));
         if ($id === $oldId->getArrayCopy()) {
             return $oldId;
         }
         $this->getEntityCache()->remove($entity);
         return $this->createIdWithArray($id);
     }
     return $this->insert($set);
 }
Exemplo n.º 2
0
 /**
  * {@inheritDoc}
  * @see \Fixin\Model\Entity\Cache\CacheInterface::update($entity)
  */
 public function update(EntityInterface $entity) : CacheInterface
 {
     $key = (string) $entity->getEntityId();
     unset($this->invalidEntities[$key]);
     $this->entities[$key] = $entity;
     return $this;
 }