From a620dd321dc43a64b3a9a808a316e0c62e4461da Mon Sep 17 00:00:00 2001 From: Maximilian Ruta Date: Wed, 21 May 2014 14:45:54 +0200 Subject: [PATCH] repositiory now implements Doctrine\Common\Persistence\ObjectRepository interface --- lib/HireVoice/Neo4j/Repository.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/HireVoice/Neo4j/Repository.php b/lib/HireVoice/Neo4j/Repository.php index 82d884d..a59671d 100644 --- a/lib/HireVoice/Neo4j/Repository.php +++ b/lib/HireVoice/Neo4j/Repository.php @@ -24,8 +24,9 @@ namespace HireVoice\Neo4j; use Doctrine\Common\Collections\ArrayCollection; use HireVoice\Neo4j\Query\LuceneQueryProcessor; +use Doctrine\Common\Persistence\ObjectRepository; -class Repository +class Repository implements ObjectRepository { /** * @var \HireVoice\Neo4j\Meta\Entity @@ -96,6 +97,7 @@ function getIndex() * Finds one node by a set of criteria * * @param array $criteria An array of search criteria + * @return null|object */ public function findOneBy(array $criteria) { @@ -111,9 +113,17 @@ public function findOneBy(array $criteria) * Finds all node matching the search criteria * * @param array $criteria An array of search criteria + * @param array $orderBy + * @param null $limit + * @param null $offset + * @return \Doctrine\Common\Collections\ArrayCollection */ - public function findBy(array $criteria) + public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) { + if ($orderBy !== null || $limit !== null || $offset !== null) { + throw new \InvalidArgumentException('$orderBy, $limit and $offset are currently not supported'); + } + $query = $this->createQuery($criteria); $collection = new ArrayCollection(); @@ -199,4 +209,14 @@ public function getMeta() { return $this->meta; } + + /** + * Returns the class name of the object managed by the repository. + * + * @return string + */ + public function getClassName() + { + return $this->class; + } }