440c36f537
Conflicts: Command/PopulateCommand.php Command/SearchCommand.php DependencyInjection/Configuration.php Doctrine/AbstractElasticaToModelTransformer.php Doctrine/AbstractListener.php Doctrine/MongoDB/ElasticaToModelTransformer.php Doctrine/ORM/ElasticaToModelTransformer.php Doctrine/RepositoryManager.php Finder/TransformedFinder.php Paginator/PaginatorAdapterInterface.php Paginator/RawPaginatorAdapter.php Persister/ObjectPersister.php Propel/ElasticaToModelTransformer.php Subscriber/PaginateElasticaQuerySubscriber.php Tests/DataCollector/ElasticaDataCollectorTest.php Tests/Doctrine/AbstractProviderTest.php Tests/Doctrine/RepositoryManagerTest.php Tests/Manager/RepositoryManagerTest.php Tests/RepositoryTest.php Transformer/ElasticaToModelTransformerCollection.php composer.json
45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace FOS\ElasticaBundle\Doctrine;
|
|
|
|
use Doctrine\Common\Annotations\Reader;
|
|
use Doctrine\Common\Persistence\ManagerRegistry;
|
|
use FOS\ElasticaBundle\Manager\RepositoryManager as BaseManager;
|
|
|
|
/**
|
|
* @author Richard Miller <info@limethinking.co.uk>
|
|
*
|
|
* Allows retrieval of basic or custom repository for mapped Doctrine
|
|
* entities/documents.
|
|
*/
|
|
class RepositoryManager extends BaseManager
|
|
{
|
|
protected $entities = array();
|
|
protected $repositories = array();
|
|
protected $managerRegistry;
|
|
|
|
public function __construct(ManagerRegistry $managerRegistry, Reader $reader)
|
|
{
|
|
$this->managerRegistry = $managerRegistry;
|
|
parent::__construct($reader);
|
|
}
|
|
|
|
/**
|
|
* Return repository for entity
|
|
*
|
|
* Returns custom repository if one specified otherwise
|
|
* returns a basic respository.
|
|
*/
|
|
public function getRepository($entityName)
|
|
{
|
|
$realEntityName = $entityName;
|
|
if (strpos($entityName, ':') !== false) {
|
|
list($namespaceAlias, $simpleClassName) = explode(':', $entityName);
|
|
$realEntityName = $this->managerRegistry->getAliasNamespace($namespaceAlias) . '\\' . $simpleClassName;
|
|
}
|
|
|
|
return parent::getRepository($realEntityName);
|
|
}
|
|
|
|
}
|