本文整理汇总了PHP中Doctrine\ORM\Configuration::addFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP Configuration::addFilter方法的具体用法?PHP Configuration::addFilter怎么用?PHP Configuration::addFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Configuration
的用法示例。
在下文中一共展示了Configuration::addFilter方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bootExtension
/**
* @param Extension $extension
*/
public function bootExtension(Extension $extension)
{
$extension->addSubscribers($this->evm, $this->em, $this->reader);
if (is_array($extension->getFilters())) {
foreach ($extension->getFilters() as $name => $filter) {
$this->metadata->addFilter($name, $filter);
$this->em->getFilters()->enable($name);
}
}
}
示例2: createService
public function createService(ServiceLocatorInterface $serviceLocator)
{
/** @var $options \DoctrineORMModule\Options\Configuration */
$options = $this->getOptions($serviceLocator);
$config = new Configuration();
$config->setAutoGenerateProxyClasses($options->getGenerateProxies());
$config->setProxyDir($options->getProxyDir());
$config->setProxyNamespace($options->getProxyNamespace());
$config->setEntityNamespaces($options->getEntityNamespaces());
$config->setCustomDatetimeFunctions($options->getDatetimeFunctions());
$config->setCustomStringFunctions($options->getStringFunctions());
$config->setCustomNumericFunctions($options->getNumericFunctions());
$config->setClassMetadataFactoryName($options->getClassMetadataFactoryName());
foreach ($options->getNamedQueries() as $name => $query) {
$config->addNamedQuery($name, $query);
}
foreach ($options->getNamedNativeQueries() as $name => $query) {
$config->addNamedNativeQuery($name, $query['sql'], new $query['rsm']());
}
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()));
$config->setResultCacheImpl($serviceLocator->get($options->getResultCache()));
$config->setHydrationCacheImpl($serviceLocator->get($options->getHydrationCache()));
$config->setMetadataDriverImpl($serviceLocator->get($options->getDriver()));
if ($namingStrategy = $options->getNamingStrategy()) {
if (is_string($namingStrategy)) {
if (!$serviceLocator->has($namingStrategy)) {
throw new InvalidArgumentException(sprintf('Naming strategy "%s" not found', $namingStrategy));
}
$config->setNamingStrategy($serviceLocator->get($namingStrategy));
} else {
$config->setNamingStrategy($namingStrategy);
}
}
if ($repositoryFactory = $options->getRepositoryFactory()) {
if (is_string($repositoryFactory)) {
if (!$serviceLocator->has($repositoryFactory)) {
throw new InvalidArgumentException(sprintf('Repository factory "%s" not found', $repositoryFactory));
}
$config->setRepositoryFactory($serviceLocator->get($repositoryFactory));
} else {
$config->setRepositoryFactory($repositoryFactory);
}
}
if ($entityListenerResolver = $options->getEntityListenerResolver()) {
if ($entityListenerResolver instanceof EntityListenerResolver) {
$config->setEntityListenerResolver($entityListenerResolver);
} else {
$config->setEntityListenerResolver($serviceLocator->get($entityListenerResolver));
}
}
$this->setupDBALConfiguration($serviceLocator, $config);
return $config;
}
示例3: bootExtension
/**
* @param $connection
* @param Extension $extension
* @param EntityManagerInterface $em
* @param EventManager $evm
* @param Configuration $configuration
*/
protected function bootExtension($connection, Extension $extension, EntityManagerInterface $em, EventManager $evm, Configuration $configuration)
{
$extension->addSubscribers($evm, $em, $configuration->getMetadataDriverImpl()->getReader());
if (is_array($extension->getFilters())) {
foreach ($extension->getFilters() as $name => $filter) {
$configuration->addFilter($name, $filter);
$em->getFilters()->enable($name);
}
}
$this->markAsBooted($connection, $extension);
}
示例4: bootExtension
/**
* @param Extension $extension
*/
public function bootExtension(Extension $extension)
{
$hash = spl_object_hash($this->em);
if (isset($this->subscribedExtensions[$hash][get_class($extension)])) {
//This extension is already subscribed to this entity manager.
return;
}
$extension->addSubscribers($this->evm, $this->em, $this->reader);
if (is_array($extension->getFilters())) {
foreach ($extension->getFilters() as $name => $filter) {
$this->metadata->addFilter($name, $filter);
$this->em->getFilters()->enable($name);
}
}
$this->subscribedExtensions[$hash][get_class($extension)] = true;
}
示例5: testAddGetFilters
public function testAddGetFilters()
{
$this->assertSame(null, $this->configuration->getFilterClassName('NonExistingFilter'));
$this->configuration->addFilter('FilterName', __CLASS__);
$this->assertSame(__CLASS__, $this->configuration->getFilterClassName('FilterName'));
}
示例6: setFilters
/**
* @param Configuration $config
*/
private function setFilters(Configuration $config)
{
if (isset($this->configuration['filters']) && is_array($this->configuration['filters'])) {
foreach ($this->configuration['filters'] as $name => $filter) {
$config->addFilter($name, $filter);
}
}
}
示例7: registerFilters
/**
* @param array $settings
* @param Configuration $configuration
* @param EntityManagerInterface $manager
*/
protected function registerFilters(array $settings = [], Configuration $configuration, EntityManagerInterface $manager)
{
if (isset($settings['filters'])) {
foreach ($settings['filters'] as $name => $filter) {
$configuration->addFilter($name, $filter);
$manager->getFilters()->enable($name);
}
}
}
示例8: __invoke
/**
* {@inheritDoc}
*
* @return Configuration
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
/** @var $options \DoctrineORMModule\Options\Configuration */
$options = $this->getOptions($container);
$config = new Configuration();
$config->setAutoGenerateProxyClasses($options->getGenerateProxies());
$config->setProxyDir($options->getProxyDir());
$config->setProxyNamespace($options->getProxyNamespace());
$config->setEntityNamespaces($options->getEntityNamespaces());
$config->setCustomDatetimeFunctions($options->getDatetimeFunctions());
$config->setCustomStringFunctions($options->getStringFunctions());
$config->setCustomNumericFunctions($options->getNumericFunctions());
$config->setClassMetadataFactoryName($options->getClassMetadataFactoryName());
foreach ($options->getNamedQueries() as $name => $query) {
$config->addNamedQuery($name, $query);
}
foreach ($options->getNamedNativeQueries() as $name => $query) {
$config->addNamedNativeQuery($name, $query['sql'], new $query['rsm']());
}
foreach ($options->getCustomHydrationModes() as $modeName => $hydrator) {
$config->addCustomHydrationMode($modeName, $hydrator);
}
foreach ($options->getFilters() as $name => $class) {
$config->addFilter($name, $class);
}
$config->setMetadataCacheImpl($container->get($options->getMetadataCache()));
$config->setQueryCacheImpl($container->get($options->getQueryCache()));
$config->setResultCacheImpl($container->get($options->getResultCache()));
$config->setHydrationCacheImpl($container->get($options->getHydrationCache()));
$config->setMetadataDriverImpl($container->get($options->getDriver()));
if ($namingStrategy = $options->getNamingStrategy()) {
if (is_string($namingStrategy)) {
if (!$container->has($namingStrategy)) {
throw new InvalidArgumentException(sprintf('Naming strategy "%s" not found', $namingStrategy));
}
$config->setNamingStrategy($container->get($namingStrategy));
} else {
$config->setNamingStrategy($namingStrategy);
}
}
if ($quoteStrategy = $options->getQuoteStrategy()) {
if (is_string($quoteStrategy)) {
if (!$container->has($quoteStrategy)) {
throw new InvalidArgumentException(sprintf('Quote strategy "%s" not found', $quoteStrategy));
}
$config->setQuoteStrategy($container->get($quoteStrategy));
} else {
$config->setQuoteStrategy($quoteStrategy);
}
}
if ($repositoryFactory = $options->getRepositoryFactory()) {
if (is_string($repositoryFactory)) {
if (!$container->has($repositoryFactory)) {
throw new InvalidArgumentException(sprintf('Repository factory "%s" not found', $repositoryFactory));
}
$config->setRepositoryFactory($container->get($repositoryFactory));
} else {
$config->setRepositoryFactory($repositoryFactory);
}
}
if ($entityListenerResolver = $options->getEntityListenerResolver()) {
if ($entityListenerResolver instanceof EntityListenerResolver) {
$config->setEntityListenerResolver($entityListenerResolver);
} else {
$config->setEntityListenerResolver($container->get($entityListenerResolver));
}
}
$secondLevelCache = $options->getSecondLevelCache();
if ($secondLevelCache->isEnabled()) {
$regionsConfig = new RegionsConfiguration($secondLevelCache->getDefaultLifetime(), $secondLevelCache->getDefaultLockLifetime());
foreach ($secondLevelCache->getRegions() as $regionName => $regionConfig) {
if (isset($regionConfig['lifetime'])) {
$regionsConfig->setLifetime($regionName, $regionConfig['lifetime']);
}
if (isset($regionConfig['lock_lifetime'])) {
$regionsConfig->setLockLifetime($regionName, $regionConfig['lock_lifetime']);
}
}
// As Second Level Cache caches queries results, we reuse the result cache impl
$cacheFactory = new DefaultCacheFactory($regionsConfig, $config->getResultCacheImpl());
$cacheFactory->setFileLockRegionDirectory($secondLevelCache->getFileLockRegionDirectory());
$cacheConfiguration = new CacheConfiguration();
$cacheConfiguration->setCacheFactory($cacheFactory);
$cacheConfiguration->setRegionsConfiguration($regionsConfig);
$config->setSecondLevelCacheEnabled();
$config->setSecondLevelCacheConfiguration($cacheConfiguration);
}
if ($className = $options->getDefaultRepositoryClassName()) {
$config->setDefaultRepositoryClassName($className);
}
$this->setupDBALConfiguration($container, $config);
return $config;
}
示例9: configureMetadataConfiguration
/**
* Configures the metadata configuration instance.
*
* @param Configuration $configuration
* @param array $doctrineConfig
*
* @throws ORMException
*/
protected function configureMetadataConfiguration(Configuration $configuration, array $doctrineConfig)
{
if (isset($doctrineConfig['filters'])) {
foreach ($doctrineConfig['filters'] as $name => $filter) {
$configuration->addFilter($name, $filter['class']);
}
}
if (isset($doctrineConfig['logger'])) {
$configuration->setSQLLogger($doctrineConfig['logger']);
}
if (isset($doctrineConfig['proxy']) && isset($doctrineConfig['proxy']['auto_generate'])) {
$configuration->setAutoGenerateProxyClasses($doctrineConfig['proxy']['auto_generate']);
}
if (isset($doctrineConfig['proxy']) && isset($doctrineConfig['proxy']['namespace'])) {
$configuration->setProxyNamespace($doctrineConfig['proxy']['namespace']);
}
if (isset($doctrineConfig['repository'])) {
$configuration->setDefaultRepositoryClassName($doctrineConfig['repository']);
}
$namingStrategy = array_get($doctrineConfig, 'naming_strategy', 'Nord\\Lumen\\Doctrine\\ORM\\NamingStrategy');
$configuration->setNamingStrategy(new $namingStrategy());
}
示例10: createWithConfig
/**
* {@inheritdoc}
*/
protected function createWithConfig(ContainerInterface $container, $configKey)
{
$config = $this->retrieveConfig($container, $configKey, 'configuration');
$configuration = new Configuration();
$configuration->setProxyDir($config['proxy_dir']);
$configuration->setProxyNamespace($config['proxy_namespace']);
$configuration->setAutoGenerateProxyClasses($config['auto_generate_proxy_classes']);
$configuration->setEntityNamespaces($config['entity_namespaces']);
$configuration->setCustomDatetimeFunctions($config['datetime_functions']);
$configuration->setCustomStringFunctions($config['string_functions']);
$configuration->setCustomNumericFunctions($config['numeric_functions']);
$configuration->setCustomHydrationModes($config['custom_hydration_modes']);
$configuration->setClassMetadataFactoryName($config['class_metadata_factory_name']);
foreach ($config['named_queries'] as $name => $dql) {
$configuration->addNamedQuery($name, $dql);
}
foreach ($config['named_native_queries'] as $name => $query) {
$configuration->addNamedNativeQuery($name, $query['sql'], $query['rsm']);
}
foreach ($config['filters'] as $name => $className) {
$configuration->addFilter($name, $className);
}
$configuration->setMetadataCacheImpl($this->retrieveDependency($container, $config['metadata_cache'], 'cache', CacheFactory::class));
$configuration->setQueryCacheImpl($this->retrieveDependency($container, $config['query_cache'], 'cache', CacheFactory::class));
$configuration->setResultCacheImpl($this->retrieveDependency($container, $config['result_cache'], 'cache', CacheFactory::class));
$configuration->setHydrationCacheImpl($this->retrieveDependency($container, $config['hydration_cache'], 'cache', CacheFactory::class));
$configuration->setMetadataDriverImpl($this->retrieveDependency($container, $config['driver'], 'driver', DriverFactory::class));
if (is_string($config['naming_strategy'])) {
$configuration->setNamingStrategy($container->get($config['naming_strategy']));
} elseif (null !== $config['naming_strategy']) {
$configuration->setNamingStrategy($config['naming_strategy']);
}
if (is_string($config['repository_factory'])) {
$configuration->setRepositoryFactory($container->get($config['repository_factory']));
} elseif (null !== $config['repository_factory']) {
$configuration->setRepositoryFactory($config['repository_factory']);
}
if (is_string($config['entity_listener_resolver'])) {
$configuration->setEntityListenerResolver($container->get($config['entity_listener_resolver']));
} elseif (null !== $config['entity_listener_resolver']) {
$configuration->setEntityListenerResolver($config['entity_listener_resolver']);
}
if (null !== $config['default_repository_class_name']) {
$configuration->setDefaultRepositoryClassName($config['default_repository_class_name']);
}
if ($config['second_level_cache']['enabled']) {
$regionsConfig = new RegionsConfiguration($config['second_level_cache']['default_lifetime'], $config['second_level_cache']['default_lock_lifetime']);
foreach ($config['second_level_cache']['regions'] as $regionName => $regionConfig) {
if (array_key_exists('lifetime', $regionConfig)) {
$regionsConfig->setLifetime($regionName, $regionConfig['lifetime']);
}
if (array_key_exists('lock_lifetime', $regionConfig)) {
$regionsConfig->setLockLifetime($regionName, $regionConfig['lock_lifetime']);
}
}
$cacheFactory = new DefaultCacheFactory($regionsConfig, $configuration->getResultCacheImpl());
$cacheFactory->setFileLockRegionDirectory($config['second_level_cache']['file_lock_region_directory']);
$cacheConfiguration = new CacheConfiguration();
$cacheConfiguration->setCacheFactory($cacheFactory);
$cacheConfiguration->setRegionsConfiguration($regionsConfig);
$configuration->setSecondLevelCacheEnabled(true);
$configuration->setSecondLevelCacheConfiguration($cacheConfiguration);
}
if (is_string($config['sql_logger'])) {
$configuration->setSQLLogger($container->get($config['sql_logger']));
} elseif (null !== $config['sql_logger']) {
$configuration->setSQLLogger($config['sql_logger']);
}
return $configuration;
}
示例11: setupCustomFunctions
protected function setupCustomFunctions(Configuration $config, $spec)
{
foreach ($spec['custom_hydration_modes'] as $name => $classname) {
$config->addCustomHydrationMode($name, $classname);
}
foreach ($spec['custom_datetime_functions'] as $name => $classname) {
$config->addCustomDatetimeFunction($name, $classname);
}
foreach ($spec['custom_numeric_functions'] as $name => $classname) {
$config->addCustomNumericFunction($name, $classname);
}
foreach ($spec['custom_string_functions'] as $name => $classname) {
$config->addCustomStringFunction($name, $classname);
}
foreach ($spec['filters'] as $name => $classname) {
$config->addFilter($name, $classname);
}
}