Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #127 from bsahlhof/master

Add ability to define SQLFilters within ZF2 configuration
  • Loading branch information...
commit 28eb1c137f5646e7f06be253fdcb449b6cd3418c 2 parents 71b0e01 + 344a4a9
@Ocramius Ocramius authored
View
3  config/module.config.php
@@ -28,7 +28,8 @@
'generate_proxies' => true,
'proxy_dir' => 'data/DoctrineORMModule/Proxy',
- 'proxy_namespace' => 'DoctrineORMModule\Proxy'
+ 'proxy_namespace' => 'DoctrineORMModule\Proxy',
+ 'filters' => array()
)
),
View
26 src/DoctrineORMModule/Options/Configuration.php
@@ -94,6 +94,14 @@ class Configuration extends DBALConfiguration
protected $numericFunctions = array();
/**
+ * Keys must be the name of the custom filter and the value must be
+ * the class name for the custom filter.
+ *
+ * @var array
+ */
+ protected $filters = array();
+
+ /**
* Keys must be the name of the query and values the DQL query string.
*
* @var array
@@ -269,6 +277,24 @@ public function getNumericFunctions()
}
/**
+ *
+ * @param array $filters
+ * @return self
+ */
+ public function setFilters($filters) {
+ $this->filters = $filters;
+ return $this;
+ }
+
+ /**
+ *
+ * @return array
+ */
+ public function getFilters() {
+ return $this->filters;
+ }
+
+ /**
* @param string $proxyDir
* @return self
*/
View
4 src/DoctrineORMModule/Service/ConfigurationFactory.php
@@ -51,6 +51,10 @@ public function createService(ServiceLocatorInterface $serviceLocator)
foreach ($options->getCustomHydrationModes() AS $modeName => $hydrator) {
$config->addCustomHydrationMode($modeName, $hydrator);
}
+
+ foreach ($options->getFilters() as $name => $class) {
+ $config->addFilter($name, $class);
+ }
$config->setMetadataCacheImpl($serviceLocator->get($options->getMetadataCache()));
$config->setQueryCacheImpl($serviceLocator->get($options->getQueryCache()));
Please sign in to comment.
Something went wrong with that request. Please try again.