<?php namespace Doctrine\Bundle\DoctrineBundle; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query\Filter\SQLFilter; /** * Configurator for an EntityManager */ class ManagerConfigurator { /** @var string[] */ private $enabledFilters = []; /** @var string[] */ private $filtersParameters = []; /** * @param string[] $enabledFilters * @param string[] $filtersParameters */ public function __construct(array $enabledFilters, array $filtersParameters) { $this->enabledFilters = $enabledFilters; $this->filtersParameters = $filtersParameters; } /** * Create a connection by name. */ public function configure(EntityManagerInterface $entityManager) { $this->enableFilters($entityManager); } /** * Enables filters for a given entity manager */ private function enableFilters(EntityManagerInterface $entityManager) { if (empty($this->enabledFilters)) { return; } $filterCollection = $entityManager->getFilters(); foreach ($this->enabledFilters as $filter) { $filterObject = $filterCollection->enable($filter); if ($filterObject === null) { continue; } $this->setFilterParameters($filter, $filterObject); } } /** * Sets default parameters for a given filter * * @param string $name Filter name * @param SQLFilter $filter Filter object */ private function setFilterParameters($name, SQLFilter $filter) { if (empty($this->filtersParameters[$name])) { return; } $parameters = $this->filtersParameters[$name]; foreach ($parameters as $paramName => $paramValue) { $filter->setParameter($paramName, $paramValue); } } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
.github | Folder | 0755 |
|
|
Command | Folder | 0755 |
|
|
Controller | Folder | 0755 |
|
|
DataCollector | Folder | 0755 |
|
|
Dbal | Folder | 0755 |
|
|
DependencyInjection | Folder | 0755 |
|
|
Mapping | Folder | 0755 |
|
|
Repository | Folder | 0755 |
|
|
Resources | Folder | 0755 |
|
|
Twig | Folder | 0755 |
|
|
.doctrine-project.json | File | 1.92 KB | 0644 |
|
ConnectionFactory.php | File | 6.09 KB | 0644 |
|
DoctrineBundle.php | File | 5.05 KB | 0644 |
|
LICENSE | File | 1.05 KB | 0644 |
|
ManagerConfigurator.php | File | 1.84 KB | 0644 |
|
README.md | File | 1.31 KB | 0644 |
|
Registry.php | File | 5.78 KB | 0644 |
|
UPGRADE-1.11.md | File | 1.07 KB | 0644 |
|
UPGRADE-1.12.md | File | 2.44 KB | 0644 |
|
UPGRADE-2.0.md | File | 2.94 KB | 0644 |
|
composer.json | File | 2.46 KB | 0644 |
|
phpcs.xml.dist | File | 2.82 KB | 0644 |
|