コード例 #1
0
 /**
  * Adds a new entity to the storage.
  *
  * @param Identity $value
  *
  * @return mixed
  */
 public function add(Identity $value)
 {
     $id = (string) $value->id();
     $this->data[$id] = clone $value;
     return clone $value;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function exists(Identity $id) : bool
 {
     $key = $this->cacheNamespaceExists . $id->id();
     $cachedItem = $this->cache->getItem($key);
     if ($cachedItem->isHit() && null !== ($result = $cachedItem->get())) {
         return $result;
     }
     $result = $this->repository->exists($id);
     $this->saveToCache($cachedItem, $result);
     return $result;
 }
コード例 #3
0
 /**
  * Retrieves an entity by its id.
  *
  * @param Identity    $id
  * @param Fields|null $fields
  *
  * @return array
  */
 public function find(Identity $id, Fields $fields = null)
 {
     $result = $this->selectOneQuery($id->id(), $fields ? $this->getColumns($fields) : $fields);
     return $result ? $result : [];
 }
コード例 #4
0
 /**
  * Removes the entity with the given id.
  *
  * @param $id
  */
 public function remove(Identity $id)
 {
     $query = $this->queryBuilder();
     $query->delete($this->mapping->name())->where($query->expr()->eq($this->mapping->identity(), ':id'))->setParameter(':id', $id->id())->execute();
 }
コード例 #5
0
 /**
  * Returns whether an entity with the given id exists.
  *
  * @param $id
  *
  * @return bool
  */
 public function exists(Identity $id)
 {
     $model = self::$instance;
     $filter = new DomainFilter();
     $filter->must()->equal($model->getKeyName(), $id->id());
     return $this->count($filter) > 0;
 }