Skip to content

Commit

Permalink
Update Repository.php
Browse files Browse the repository at this point in the history
  • Loading branch information
dezbyte authored Nov 1, 2017
1 parent b6ae6dc commit 83530c7
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions src/Colibri/Core/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ abstract class Repository implements RepositoryInterface
/**
* @var QueryBuilder\Select
*/
protected $filterQuery;
protected $query;

/**
* @var AbstractHydratorEntity
Expand All @@ -83,11 +83,6 @@ abstract class Repository implements RepositoryInterface
*/
protected $queryFactory;

/**
* @var EntityManager
*/
protected $entityManager;

/**
* EntityRepository constructor.
* @param string $entityName
Expand All @@ -99,13 +94,11 @@ public function __construct($entityName)
$this->eventDispatcher = $this->serviceLocator->getDispatcher();
$this->entityName = $entityName;
$this->connection = $this->getServiceLocator()->getConnection($this->getEntityMetadata()->getConnectionName());

$this->entityManager = $this->getServiceLocator()->getEntityManager();

$this->setHydrator(new EntityHydrator($this));
$this->setQueryFactory(new BasicRepositoryQueryFactory($this));

$this->filterQuery = $this->createSelectQuery();
$this->query = $this->createSelectQuery();
}

/**
Expand Down Expand Up @@ -133,9 +126,8 @@ public function __call($name, array $arguments = [])
return $callback->call($arguments);
}

throw new BadCallMethodException('Magic calling method should starts either :names', [
'names' => 'findBy, findOneBy, filterBy, orderBy or groupBy'
]);
throw new BadCallMethodException(sprintf('Trying to call %s::%s(); method. Allowed to call methods which starts with "%s"',
__CLASS__, $name, 'findBy, findOneBy, filterBy, orderBy or groupBy'));
}

/**
Expand Down Expand Up @@ -419,15 +411,15 @@ public function getEntityClassReflection()
*/
public function getEntityMetadata()
{
return $this->getEntityManager()->getMetadataFor($this->getEntityName());
return $this->getServiceLocator()->getMetadataManager()->getMetadataFor($this->getEntityName());
}

/**
* @return QueryBuilder\Select
*/
public function getQuery()
{
return $this->filterQuery;
return $this->query;
}

/**
Expand Down Expand Up @@ -472,7 +464,7 @@ public function cleanupQuery()
*/
public function setQuery(QueryBuilder\Select $filterQuery)
{
$this->filterQuery = $filterQuery;
$this->query = $filterQuery;

return $this;
}
Expand All @@ -484,14 +476,6 @@ public function getClassManager()
{
return $this->getServiceLocator()->getClassManager();
}

/**
* @return EntityManager
*/
public function getEntityManager(): EntityManager
{
return $this->entityManager;
}

/**
* @return ConnectionInterface
Expand Down

0 comments on commit 83530c7

Please sign in to comment.