本文整理匯總了PHP中Doctrine\ORM\Configuration::setQuoteStrategy方法的典型用法代碼示例。如果您正苦於以下問題:PHP Configuration::setQuoteStrategy方法的具體用法?PHP Configuration::setQuoteStrategy怎麽用?PHP Configuration::setQuoteStrategy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\ORM\Configuration
的用法示例。
在下文中一共展示了Configuration::setQuoteStrategy方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testSetGetQuoteStrategy
public function testSetGetQuoteStrategy()
{
$this->assertInstanceOf('Doctrine\\ORM\\Mapping\\QuoteStrategy', $this->configuration->getQuoteStrategy());
$quoteStrategy = $this->getMock('Doctrine\\ORM\\Mapping\\QuoteStrategy');
$this->configuration->setQuoteStrategy($quoteStrategy);
$this->assertSame($quoteStrategy, $this->configuration->getQuoteStrategy());
}
示例2: register
public function register(Container $c)
{
parent::register($c);
$c['orm.options'] = array();
$c['orm.types'] = array();
$c['orm.proxies_dir'] = sys_get_temp_dir();
$c['orm.proxies_namespace'] = 'DoctrineProxy';
$c['orm.auto_generate_proxies'] = $c->factory(function ($c) {
return $c['debug'];
});
$c['orm.custom.functions.string'] = array();
$c['orm.custom.functions.numeric'] = array();
$c['orm.custom.functions.datetime'] = array();
$c['orm.custom.hydration_modes'] = array();
$c['orm.class_metadata_factory_name'] = 'Doctrine\\ORM\\Mapping\\ClassMetadataFactory';
$c['orm.default_repository_class'] = 'Doctrine\\ORM\\EntityRepository';
$c['orm.initialize'] = $c->protect(function () use($c) {
static $initialized = false;
if ($initialized) {
return;
}
$initialized = true;
if (!isset($c['orm.options'])) {
$c['orm.options'] = array('default' => array());
} elseif (!is_array(reset($c['orm.options']))) {
// Se o primeiro elemento do array de opções não for um array,
// muito provavelmente o usuário está colocando as options de
// uma única conexão, então usar como default
$c['orm.options'] = array('default' => $c['orm.options']);
}
$tmp = $c['orm.options'];
foreach ($tmp as $name => &$options) {
if (!isset($options['connection'])) {
throw new \LogicException("Missing 'connection' param in Doctrine ORM in {$name}.");
}
if (is_string($options['connection'])) {
$options['connection'] = $c['dbal.options'][$options['connection']];
} elseif (!is_array($options['connection']) && !$options['connection'] instanceof Connection) {
throw new \LogicException("Param 'connection' in {$name} must be a string, array or a Connection instance.");
}
}
$c['orm.options'] = $tmp;
$c['orm.defaultName'] = key($c['orm.options']);
});
$c['orm.ems'] = function ($c) {
$c['orm.initialize']();
$ems = new Container();
foreach ($c['orm.options'] as $name => $options) {
$config = $c['orm.configs'][$name];
$connection = $options['connection'];
$ems[$name] = function ($ems) use($connection, $config) {
return EntityManager::create($connection, $config);
};
}
return $ems;
};
$c['orm.configs'] = function ($c) {
$c['orm.initialize']();
$configs = new Container();
foreach ($c['orm.options'] as $name => $options) {
$configs[$name] = $config = new Configuration();
$config->setProxyDir($c['orm.proxies_dir']);
$config->setProxyNamespace($c['orm.proxies_namespace']);
$config->setAutoGenerateProxyClasses($c['orm.auto_generate_proxies']);
$config->setCustomStringFunctions($c['orm.custom.functions.string']);
$config->setCustomNumericFunctions($c['orm.custom.functions.numeric']);
$config->setCustomDatetimeFunctions($c['orm.custom.functions.datetime']);
$config->setCustomHydrationModes($c['orm.custom.hydration_modes']);
$config->setClassMetadataFactoryName($c['orm.class_metadata_factory_name']);
$config->setDefaultRepositoryClassName($c['orm.default_repository_class']);
$config->setEntityListenerResolver($c['orm.entity_listener_resolver']);
$config->setRepositoryFactory($c['orm.repository_factory']);
$config->setNamingStrategy($c['orm.strategy.naming']);
$config->setQuoteStrategy($c['orm.strategy.quote']);
$chain = new MappingDriverChain();
$config->setMetadataDriverImpl($chain);
foreach ((array) $options['mappings'] as $entity) {
if (!is_array($entity)) {
throw new \InvalidArgumentException("The 'orm.options' option 'mappings' should be an array of arrays.");
}
if (isset($entity['alias'])) {
$config->addEntityNamespace($entity['alias'], $entity['namespace']);
}
switch ($entity['type']) {
case 'annotation':
if (isset($c['annotation.reader'])) {
$driver = new AnnotationDriver($c['annotation.reader'], (array) $entity['path']);
} else {
$simple = isset($entity['use_simple_annotation_reader']) ? $entity['use_simple_annotation_reader'] : true;
$driver = $config->newDefaultAnnotationDriver((array) $entity['path'], $simple);
}
break;
case 'yml':
$driver = new YamlDriver($entity['path']);
break;
case 'simple_yml':
$driver = new SimplifiedYamlDriver(array($entity['path'] => $entity['namespace']));
break;
case 'xml':
$driver = new XmlDriver($entity['path']);
//.........這裏部分代碼省略.........
示例3: __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;
}
示例4: setupQuoteStrategy
/**
* Setup quote strategy.
*
* @param \Doctrine\ORM\Configuration $config
* @param array $options
*
* @throws \InvalidArgumentException
*/
protected static function setupQuoteStrategy(Configuration &$config, array $options)
{
$quoteStrategy = $options['quote_strategy'] ?: new DefaultQuoteStrategy();
if (!$quoteStrategy instanceof QuoteStrategy) {
throw new \InvalidArgumentException('Quote strategy provided is not valid');
}
$config->setQuoteStrategy($quoteStrategy);
}