Beispiel #1
0
 /**
  * {@inheritDoc}
  */
 public function count()
 {
     $criteria = clone $this->criteria;
     $criteria->setFirstResult(null);
     $criteria->setMaxResults(null);
     return count($this->selectable->matching($criteria));
 }
 /**
  * {@inheritdoc}
  */
 public function getSlice($offset, $length)
 {
     $firstResult = $offset;
     $maxResults = $length;
     $criteria = $this->createCriteria($firstResult, $maxResults);
     return $this->selectable->matching($criteria);
 }
 /**
  * {@inheritdoc}
  */
 public function getData(RequestInterface $request)
 {
     $criteria = new Criteria();
     $criteria->setMaxResults($request->getLimit());
     $criteria->setFirstResult($request->getOffset());
     $this->processOrder($criteria, $request);
     $this->processSearch($criteria, $request);
     $this->processGlobalSearch($criteria, $request);
     $result = $this->collection->matching($criteria);
     return $this->processData($result);
 }
 /**
  * {@inheritdoc}
  */
 public function getTotal(RequestInterface $request)
 {
     $criteria = new Criteria();
     $this->processOrder($criteria, $request);
     $this->processSearch($criteria, $request);
     $this->processGlobalSearch($criteria, $request);
     return $this->collection->matching($criteria)->count();
 }
 /**
  * Finds a data entity
  *
  * @param string $key
  *
  * @return object|null
  */
 protected function findData($key)
 {
     $criteria = Criteria::create()->where(Criteria::expr()->eq('key', $key));
     $result = $this->data->matching($criteria);
     if (is_array($result)) {
         $result = reset($result);
         return $result;
     }
 }
 /**
  * @param  int $id
  * @return Post
  */
 public function get($id)
 {
     return $this->posts->matching(Criteria::create()->where(Criteria::expr()->eq('id', $id)))->first();
 }