Initial commit

This commit is contained in:
2019-11-20 07:44:43 +01:00
commit 5bf49c4a81
41188 changed files with 5459177 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
{
"name": "Doctrine Cache Bundle",
"shortName": "DoctrineCacheBundle",
"slug": "doctrine-cache-bundle",
"versions": [
{
"name": "1.3",
"branchName": "master",
"slug": "1.3",
"current": true
},
{
"name": "1.2",
"branchName": "1.2",
"slug": "1.2",
"maintained": false
}
]
}

View File

@@ -0,0 +1,239 @@
<?php
namespace Doctrine\Bundle\DoctrineCacheBundle\Acl\Model;
use Doctrine\Common\Cache\CacheProvider;
use Symfony\Component\Security\Acl\Model\AclCacheInterface;
use Symfony\Component\Security\Acl\Model\AclInterface;
use Symfony\Component\Security\Acl\Model\ObjectIdentityInterface;
use Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface;
/**
* This class is a wrapper around the actual cache implementation.
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Fabien Potencier <fabien@symfony.com>
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
class AclCache implements AclCacheInterface
{
/**
* @var \Doctrine\Common\Cache\CacheProvider
*/
private $cache;
/**
* @var \Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface
*/
private $permissionGrantingStrategy;
/**
* Constructor
*
* @param \Doctrine\Common\Cache\CacheProvider $cache
* @param \Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface $permissionGrantingStrategy
*/
public function __construct(CacheProvider $cache, PermissionGrantingStrategyInterface $permissionGrantingStrategy)
{
$this->cache = $cache;
$this->permissionGrantingStrategy = $permissionGrantingStrategy;
}
/**
* {@inheritdoc}
*/
public function evictFromCacheById($primaryKey)
{
if ( ! $this->cache->contains($primaryKey)) {
return;
}
$key = $this->cache->fetch($primaryKey);
$this->cache->delete($primaryKey);
$this->evictFromCacheByKey($key);
}
/**
* {@inheritdoc}
*/
public function evictFromCacheByIdentity(ObjectIdentityInterface $oid)
{
$key = $this->createKeyFromIdentity($oid);
$this->evictFromCacheByKey($key);
}
/**
* {@inheritdoc}
*/
public function getFromCacheById($primaryKey)
{
if ( ! $this->cache->contains($primaryKey)) {
return null;
}
$key = $this->cache->fetch($primaryKey);
$acl = $this->getFromCacheByKey($key);
if ( ! $acl) {
$this->cache->delete($primaryKey);
return null;
}
return $acl;
}
/**
* {@inheritdoc}
*/
public function getFromCacheByIdentity(ObjectIdentityInterface $oid)
{
$key = $this->createKeyFromIdentity($oid);
return $this->getFromCacheByKey($key);
}
/**
* {@inheritdoc}
*/
public function putInCache(AclInterface $acl)
{
if (null === $acl->getId()) {
throw new \InvalidArgumentException('Transient ACLs cannot be cached.');
}
$parentAcl = $acl->getParentAcl();
if (null !== $parentAcl) {
$this->putInCache($parentAcl);
}
$key = $this->createKeyFromIdentity($acl->getObjectIdentity());
$this->cache->save($key, serialize($acl));
$this->cache->save($acl->getId(), $key);
}
/**
* {@inheritdoc}
*/
public function clearCache()
{
return $this->cache->deleteAll();
}
/**
* Unserialize a given ACL.
*
* @param string $serialized
*
* @return \Symfony\Component\Security\Acl\Model\AclInterface
*/
private function unserializeAcl($serialized)
{
$acl = unserialize($serialized);
$parentId = $acl->getParentAcl();
if (null !== $parentId) {
$parentAcl = $this->getFromCacheById($parentId);
if (null === $parentAcl) {
return null;
}
$acl->setParentAcl($parentAcl);
}
$reflectionProperty = new \ReflectionProperty($acl, 'permissionGrantingStrategy');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($acl, $this->permissionGrantingStrategy);
$reflectionProperty->setAccessible(false);
$aceAclProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Entry', 'acl');
$aceAclProperty->setAccessible(true);
foreach ($acl->getObjectAces() as $ace) {
$aceAclProperty->setValue($ace, $acl);
}
foreach ($acl->getClassAces() as $ace) {
$aceAclProperty->setValue($ace, $acl);
}
$aceClassFieldProperty = new \ReflectionProperty($acl, 'classFieldAces');
$aceClassFieldProperty->setAccessible(true);
foreach ($aceClassFieldProperty->getValue($acl) as $aces) {
foreach ($aces as $ace) {
$aceAclProperty->setValue($ace, $acl);
}
}
$aceClassFieldProperty->setAccessible(false);
$aceObjectFieldProperty = new \ReflectionProperty($acl, 'objectFieldAces');
$aceObjectFieldProperty->setAccessible(true);
foreach ($aceObjectFieldProperty->getValue($acl) as $aces) {
foreach ($aces as $ace) {
$aceAclProperty->setValue($ace, $acl);
}
}
$aceObjectFieldProperty->setAccessible(false);
$aceAclProperty->setAccessible(false);
return $acl;
}
/**
* Returns the key for the object identity
*
* @param \Symfony\Component\Security\Acl\Model\ObjectIdentityInterface $oid
*
* @return string
*/
private function createKeyFromIdentity(ObjectIdentityInterface $oid)
{
return $oid->getType() . '_' . $oid->getIdentifier();
}
/**
* Removes an ACL from the cache
*
* @param string $key
*/
private function evictFromCacheByKey($key)
{
if ( ! $this->cache->contains($key)) {
return;
}
$this->cache->delete($key);
}
/**
* Retrieves an ACL for the given key from the cache
*
* @param string $key
*
* @return null|\Symfony\Component\Security\Acl\Model\AclInterface
*/
private function getFromCacheByKey($key)
{
if ( ! $this->cache->contains($key)) {
return null;
}
$serialized = $this->cache->fetch($key);
return $this->unserializeAcl($serialized);
}
}

View File

@@ -0,0 +1,65 @@
<?php
namespace Doctrine\Bundle\DoctrineCacheBundle\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Doctrine\Common\Cache\Cache;
/**
* Base cache command.
*
* @author Alan Doucette <dragonwize@gmail.com>
*/
abstract class CacheCommand extends Command implements ContainerAwareInterface
{
/**
* @var ContainerInterface
*/
private $container;
/**
* Get the requested cache provider service.
*
* @param string $cacheName
*
* @return \Doctrine\Common\Cache\Cache
*
* @throws \InvalidArgumentException
*/
protected function getCacheProvider($cacheName)
{
$container = $this->getContainer();
// Try to use user input as cache service alias.
$cacheProvider = $container->get($cacheName, ContainerInterface::NULL_ON_INVALID_REFERENCE);
// If cache provider was not found try the service provider name.
if ( ! $cacheProvider instanceof Cache) {
$cacheProvider = $container->get('doctrine_cache.providers.' . $cacheName, ContainerInterface::NULL_ON_INVALID_REFERENCE);
}
// Cache provider was not found.
if ( ! $cacheProvider instanceof Cache) {
throw new \InvalidArgumentException('Cache provider not found.');
}
return $cacheProvider;
}
/**
* @return \Symfony\Component\DependencyInjection\ContainerInterface
*/
protected function getContainer()
{
return $this->container;
}
/**
* {@inheritdoc}
*/
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
}

View File

@@ -0,0 +1,40 @@
<?php
namespace Doctrine\Bundle\DoctrineCacheBundle\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Check if a cache entry exists.
*
* @author Alan Doucette <dragonwize@gmail.com>
*/
class ContainsCommand extends CacheCommand
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this->setName('doctrine:cache:contains')
->setDescription('Check if a cache entry exists')
->addArgument('cache-name', InputArgument::REQUIRED, 'Which cache provider to use?')
->addArgument('cache-id', InputArgument::REQUIRED, 'Which cache ID to check?');
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$cacheName = $input->getArgument('cache-name');
$cacheProvider = $this->getCacheProvider($cacheName);
$cacheId = $input->getArgument('cache-id');
$message = $cacheProvider->contains($cacheId) ? '<info>TRUE</info>' : '<error>FALSE</error>';
$output->writeln($message);
}
}

View File

@@ -0,0 +1,64 @@
<?php
namespace Doctrine\Bundle\DoctrineCacheBundle\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Delete cache entries.
*
* @author Alan Doucette <dragonwize@gmail.com>
*/
class DeleteCommand extends CacheCommand
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this->setName('doctrine:cache:delete')
->setDescription('Delete a cache entry')
->addArgument('cache-name', InputArgument::REQUIRED, 'Which cache provider to use?')
->addArgument('cache-id', InputArgument::OPTIONAL, 'Which cache ID to delete?')
->addOption('all', 'a', InputOption::VALUE_NONE, 'Delete all cache entries in provider');
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$cacheName = $input->getArgument('cache-name');
$cacheProvider = $this->getCacheProvider($cacheName);
$cacheId = $input->getArgument('cache-id');
$all = $input->getOption('all');
if ($all && ! method_exists($cacheProvider, 'deleteAll')) {
throw new \RuntimeException('Cache provider does not implement a deleteAll method.');
}
if ( ! $all && ! $cacheId) {
throw new \InvalidArgumentException('Missing cache ID');
}
$success = $all ? $cacheProvider->deleteAll() : $cacheProvider->delete($cacheId);
$color = $success ? 'info' : 'error';
$success = $success ? 'succeeded' : 'failed';
$message = null;
if ( ! $all) {
$message = "Deletion of <$color>%s</$color> in <$color>%s</$color> has <$color>%s</$color>";
$message = sprintf($message, $cacheId, $cacheName, $success, true);
}
if ($all) {
$message = "Deletion of <$color>all</$color> entries in <$color>%s</$color> has <$color>%s</$color>";
$message = sprintf($message, $cacheName, $success, true);
}
$output->writeln($message);
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace Doctrine\Bundle\DoctrineCacheBundle\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Flush a cache provider.
*
* @author Alan Doucette <dragonwize@gmail.com>
*/
class FlushCommand extends CacheCommand
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this->setName('doctrine:cache:flush')
->setAliases(array('doctrine:cache:clear'))
->setDescription('Flush a given cache')
->addArgument('cache-name', InputArgument::REQUIRED, 'Which cache provider to flush?');
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$cacheName = $input->getArgument('cache-name');
$cacheProvider = $this->getCacheProvider($cacheName);
if ( ! method_exists($cacheProvider, 'flushAll')) {
throw new \RuntimeException('Cache provider does not implement a flushAll method.');
}
$cacheProviderName = get_class($cacheProvider);
$output->writeln(sprintf('Clearing the cache for the <info>%s</info> provider of type <info>%s</info>', $cacheName, $cacheProviderName, true));
$cacheProvider->flushAll();
}
}

View File

@@ -0,0 +1,53 @@
<?php
namespace Doctrine\Bundle\DoctrineCacheBundle\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Get stats from cache provider.
*
* @author Alan Doucette <dragonwize@gmail.com>
*/
class StatsCommand extends CacheCommand
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this->setName('doctrine:cache:stats')
->setDescription('Get stats on a given cache provider')
->addArgument('cache-name', InputArgument::REQUIRED, 'For which cache provider would you like to get stats?');
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$cacheName = $input->getArgument('cache-name');
$cacheProvider = $this->getCacheProvider($cacheName);
$cacheProviderName = get_class($cacheProvider);
$stats = $cacheProvider->getStats();
if ($stats === null) {
$output->writeln(sprintf('Stats were not provided for the <info>%s</info> provider of type <info>%s</info>', $cacheName, $cacheProviderName, true));
return;
}
$formatter = $this->getHelperSet()->get('formatter');
$lines = array();
foreach ($stats as $key => $stat) {
$lines[] = $formatter->formatSection($key, $stat);
}
$output->writeln(sprintf('Stats for the <info>%s</info> provider of type <info>%s</info>:', $cacheName, $cacheProviderName, true));
$output->writeln($lines);
}
}

View File

@@ -0,0 +1,142 @@
<?php
namespace Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection;
use Doctrine\Common\Inflector\Inflector;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* Cache provider loader
*
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
*/
class CacheProviderLoader
{
/**
* @param string $name
* @param array $config
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
public function loadCacheProvider($name, array $config, ContainerBuilder $container)
{
$serviceId = 'doctrine_cache.providers.' . $name;
$decorator = $this->getProviderDecorator($container, $config);
$service = $container->setDefinition($serviceId, $decorator);
$type = ($config['type'] === 'custom_provider')
? $config['custom_provider']['type']
: $config['type'];
if ($config['namespace']) {
$service->addMethodCall('setNamespace', array($config['namespace']));
}
$service->setPublic(true);
foreach ($config['aliases'] as $alias) {
$container->setAlias($alias, new Alias($serviceId, true));
}
if ($this->definitionClassExists($type, $container)) {
$this->getCacheDefinition($type, $container)->configure($name, $config, $service, $container);
}
}
/**
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
* @param array $config
*
* @return \Symfony\Component\DependencyInjection\DefinitionDecorator
*/
protected function getProviderDecorator(ContainerBuilder $container, array $config)
{
$type = $config['type'];
$id = 'doctrine_cache.abstract.' . $type;
static $childDefinition;
if (null === $childDefinition) {
$childDefinition = class_exists('Symfony\Component\DependencyInjection\ChildDefinition') ? 'Symfony\Component\DependencyInjection\ChildDefinition' : 'Symfony\Component\DependencyInjection\DefinitionDecorator';
}
if ($type === 'custom_provider') {
$type = $config['custom_provider']['type'];
$param = $this->getCustomProviderParameter($type);
if ($container->hasParameter($param)) {
return new $childDefinition($container->getParameter($param));
}
}
if ($container->hasDefinition($id)) {
return new $childDefinition($id);
}
throw new \InvalidArgumentException(sprintf('"%s" is an unrecognized Doctrine cache driver.', $type));
}
/**
* @param string $type
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*
* @return \Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\Definition\CacheDefinition
*/
private function getCacheDefinition($type, ContainerBuilder $container)
{
$class = $this->getDefinitionClass($type, $container);
$object = new $class($type);
return $object;
}
/**
* @param string $type
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*
* @return boolean
*/
private function definitionClassExists($type, ContainerBuilder $container)
{
if ($container->hasParameter($this->getCustomDefinitionClassParameter($type))) {
return true;
}
return class_exists($this->getDefinitionClass($type, $container));
}
/**
* @param string $type
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*
* @return string
*/
protected function getDefinitionClass($type, ContainerBuilder $container)
{
if ($container->hasParameter($this->getCustomDefinitionClassParameter($type))) {
return $container->getParameter($this->getCustomDefinitionClassParameter($type));
}
$name = Inflector::classify($type) . 'Definition';
$class = sprintf('%s\Definition\%s', __NAMESPACE__, $name);
return $class;
}
/**
* @param string $type
*
* @return string
*/
public function getCustomProviderParameter($type)
{
return 'doctrine_cache.custom_provider.' . $type;
}
/**
* @param string $type
*
* @return string
*/
public function getCustomDefinitionClassParameter($type)
{
return 'doctrine_cache.custom_definition_class.' . $type;
}
}

View File

@@ -0,0 +1,556 @@
<?php
namespace Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\NodeInterface;
/**
* Cache Bundle Configuration
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
*/
class Configuration implements ConfigurationInterface
{
/**
* @param array $parameters
*
* @return string
*/
public function getProviderParameters(array $parameters)
{
if (isset($parameters['type'])) {
unset($parameters['type']);
}
if (isset($parameters['aliases'])) {
unset($parameters['aliases']);
}
if (isset($parameters['namespace'])) {
unset($parameters['namespace']);
}
return $parameters;
}
/**
* @param array $parameters
*
* @return string
*/
public function resolveNodeType(array $parameters)
{
$values = $this->getProviderParameters($parameters);
$type = key($values);
return $type;
}
/**
* @param \Symfony\Component\Config\Definition\NodeInterface $tree
*
* @return array
*/
public function getProviderNames(NodeInterface $tree)
{
foreach ($tree->getChildren() as $providers) {
if ($providers->getName() !== 'providers') {
continue;
}
$children = $providers->getPrototype()->getChildren();
$providers = array_diff(array_keys($children), array('type', 'aliases', 'namespace'));
return $providers;
}
return array();
}
/**
* @param string $type
* @param \Symfony\Component\Config\Definition\NodeInterface $tree
*
* @return boolean
*/
public function isCustomProvider($type, NodeInterface $tree)
{
return ( ! in_array($type, $this->getProviderNames($tree)));
}
/**
* {@inheritDoc}
*/
public function getConfigTreeBuilder()
{
$self = $this;
$builder = new TreeBuilder('doctrine_cache');
$node = $this->getRootNode($builder, 'doctrine_cache');
$normalization = function ($conf) use ($self, $builder) {
$conf['type'] = isset($conf['type'])
? $conf['type']
: $self->resolveNodeType($conf);
if ($self->isCustomProvider($conf['type'], $builder->buildTree())) {
$params = $self->getProviderParameters($conf);
$options = reset($params);
$conf = array(
'type' => 'custom_provider',
'namespace' => isset($conf['namespace']) ? $conf['namespace'] : null ,
'custom_provider' => array(
'type' => $conf['type'],
'options' => $options ?: null,
)
);
}
return $conf;
};
$node
->children()
->arrayNode('acl_cache')
->beforeNormalization()
->ifString()
->then(function ($id) {
return array('id' => $id);
})
->end()
->addDefaultsIfNotSet()
->children()
->scalarNode('id')->end()
->end()
->end()
->end()
->fixXmlConfig('custom_provider')
->children()
->arrayNode('custom_providers')
->useAttributeAsKey('type')
->prototype('array')
->children()
->scalarNode('prototype')->isRequired()->cannotBeEmpty()->end()
->scalarNode('definition_class')->defaultNull()->end()
->end()
->end()
->end()
->end()
->fixXmlConfig('alias', 'aliases')
->children()
->arrayNode('aliases')
->useAttributeAsKey('key')
->prototype('scalar')->end()
->end()
->end()
->fixXmlConfig('provider')
->children()
->arrayNode('providers')
->useAttributeAsKey('name')
->prototype('array')
->beforeNormalization()
->ifTrue(function ($v) use ($self, $builder) {
return ( ! isset($v['type']) || ! $self->isCustomProvider($v['type'], $builder->buildTree()));
})
->then($normalization)
->end()
->children()
->scalarNode('namespace')->defaultNull()->end()
->scalarNode('type')->defaultNull()->end()
->append($this->addBasicProviderNode('apc'))
->append($this->addBasicProviderNode('apcu'))
->append($this->addBasicProviderNode('array'))
->append($this->addBasicProviderNode('void'))
->append($this->addBasicProviderNode('wincache'))
->append($this->addBasicProviderNode('xcache'))
->append($this->addBasicProviderNode('zenddata'))
->append($this->addCustomProviderNode())
->append($this->addCouchbaseNode())
->append($this->addChainNode())
->append($this->addMemcachedNode())
->append($this->addMemcacheNode())
->append($this->addFileSystemNode())
->append($this->addPhpFileNode())
->append($this->addMongoNode())
->append($this->addRedisNode())
->append($this->addPredisNode())
->append($this->addRiakNode())
->append($this->addSqlite3Node())
->end()
->fixXmlConfig('alias', 'aliases')
->children()
->arrayNode('aliases')
->prototype('scalar')->end()
->end()
->end()
->end()
->end()
->end()
;
return $builder;
}
/**
* @param string $name
*
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder
*/
private function addBasicProviderNode($name)
{
$builder = new TreeBuilder($name);
$node = $this->getRootNode($builder, $name);
return $node;
}
/**
* Build custom node configuration definition
*
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder
*/
private function addCustomProviderNode()
{
$builder = new TreeBuilder('custom_provider');
$node = $this->getRootNode($builder, 'custom_provider');
$node
->children()
->scalarNode('type')->isRequired()->cannotBeEmpty()->end()
->arrayNode('options')
->useAttributeAsKey('name')
->prototype('scalar')->end()
->end()
->end()
;
return $node;
}
/**
* Build chain node configuration definition
*
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder
*/
private function addChainNode()
{
$builder = new TreeBuilder('chain');
$node = $this->getRootNode($builder, 'chain');
$node
->fixXmlConfig('provider')
->children()
->arrayNode('providers')
->prototype('scalar')->end()
->end()
->end()
;
return $node;
}
/**
* Build memcache node configuration definition
*
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder
*/
private function addMemcacheNode()
{
$builder = new TreeBuilder('memcache');
$node = $this->getRootNode($builder, 'memcache');
$host = '%doctrine_cache.memcache.host%';
$port = '%doctrine_cache.memcache.port%';
$node
->addDefaultsIfNotSet()
->fixXmlConfig('server')
->children()
->scalarNode('connection_id')->defaultNull()->end()
->arrayNode('servers')
->useAttributeAsKey('host')
->normalizeKeys(false)
->prototype('array')
->beforeNormalization()
->ifTrue(function ($v) {
return is_scalar($v);
})
->then(function ($val) {
return array('port' => $val);
})
->end()
->children()
->scalarNode('host')->defaultValue($host)->end()
->scalarNode('port')->defaultValue($port)->end()
->end()
->end()
->defaultValue(array($host => array(
'host' => $host,
'port' => $port
)))
->end()
->end()
;
return $node;
}
/**
* Build memcached node configuration definition
*
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder
*/
private function addMemcachedNode()
{
$builder = new TreeBuilder('memcached');
$node = $this->getRootNode($builder, 'memcached');
$host = '%doctrine_cache.memcached.host%';
$port = '%doctrine_cache.memcached.port%';
$node
->addDefaultsIfNotSet()
->fixXmlConfig('server')
->children()
->scalarNode('connection_id')->defaultNull()->end()
->scalarNode('persistent_id')->defaultNull()->end()
->arrayNode('servers')
->useAttributeAsKey('host')
->normalizeKeys(false)
->prototype('array')
->beforeNormalization()
->ifTrue(function ($v) {
return is_scalar($v);
})
->then(function ($val) {
return array('port' => $val);
})
->end()
->children()
->scalarNode('host')->defaultValue($host)->end()
->scalarNode('port')->defaultValue($port)->end()
->end()
->end()
->defaultValue(array($host => array(
'host' => $host,
'port' => $port
)))
->end()
->end()
;
return $node;
}
/**
* Build redis node configuration definition
*
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder
*/
private function addRedisNode()
{
$builder = new TreeBuilder('redis');
$node = $this->getRootNode($builder, 'redis');
$node
->addDefaultsIfNotSet()
->children()
->scalarNode('connection_id')->defaultNull()->end()
->scalarNode('host')->defaultValue('%doctrine_cache.redis.host%')->end()
->scalarNode('port')->defaultValue('%doctrine_cache.redis.port%')->end()
->scalarNode('password')->defaultNull()->end()
->scalarNode('timeout')->defaultNull()->end()
->scalarNode('database')->defaultNull()->end()
->booleanNode('persistent')->defaultFalse()->end()
->end()
;
return $node;
}
/**
* Build predis node configuration definition
*
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder
*/
private function addPredisNode()
{
$builder = new TreeBuilder('predis');
$node = $this->getRootNode($builder, 'predis');
$node
->addDefaultsIfNotSet()
->children()
->scalarNode('client_id')->defaultNull()->end()
->scalarNode('scheme')->defaultValue('tcp')->end()
->scalarNode('host')->defaultValue('%doctrine_cache.redis.host%')->end()
->scalarNode('port')->defaultValue('%doctrine_cache.redis.port%')->end()
->scalarNode('password')->defaultNull()->end()
->scalarNode('timeout')->defaultNull()->end()
->scalarNode('database')->defaultNull()->end()
->arrayNode('options')
->useAttributeAsKey('name')
->prototype('scalar')->end()
->end()
->end()
;
return $node;
}
/**
* Build riak node configuration definition
*
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder
*/
private function addRiakNode()
{
$builder = new TreeBuilder('riak');
$node = $this->getRootNode($builder, 'riak');
$node
->addDefaultsIfNotSet()
->children()
->scalarNode('host')->defaultValue('%doctrine_cache.riak.host%')->end()
->scalarNode('port')->defaultValue('%doctrine_cache.riak.port%')->end()
->scalarNode('bucket_name')->defaultValue('doctrine_cache')->end()
->scalarNode('connection_id')->defaultNull()->end()
->scalarNode('bucket_id')->defaultNull()->end()
->arrayNode('bucket_property_list')
->children()
->scalarNode('allow_multiple')->defaultNull()->end()
->scalarNode('n_value')->defaultNull()->end()
->end()
->end()
->end()
;
return $node;
}
/**
* Build couchbase node configuration definition
*
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder
*/
private function addCouchbaseNode()
{
$builder = new TreeBuilder('couchbase');
$node = $this->getRootNode($builder, 'couchbase');
$node
->addDefaultsIfNotSet()
->fixXmlConfig('hostname')
->children()
->scalarNode('connection_id')->defaultNull()->end()
->arrayNode('hostnames')
->prototype('scalar')->end()
->defaultValue(array('%doctrine_cache.couchbase.hostnames%'))
->end()
->scalarNode('username')->defaultNull()->end()
->scalarNode('password')->defaultNull()->end()
->scalarNode('bucket_name')->defaultValue('doctrine_cache')->end()
->end()
;
return $node;
}
/**
* Build mongodb node configuration definition
*
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder
*/
private function addMongoNode()
{
$builder = new TreeBuilder('mongodb');
$node = $this->getRootNode($builder, 'mongodb');
$node
->addDefaultsIfNotSet()
->children()
->scalarNode('connection_id')->defaultNull()->end()
->scalarNode('collection_id')->defaultNull()->end()
->scalarNode('database_name')->defaultValue('doctrine_cache')->end()
->scalarNode('collection_name')->defaultValue('doctrine_cache')->end()
->scalarNode('server')->defaultValue('%doctrine_cache.mongodb.server%')->end()
->end()
;
return $node;
}
/**
* Build php_file node configuration definition
*
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder
*/
private function addPhpFileNode()
{
$builder = new TreeBuilder('php_file');
$node = $this->getRootNode($builder, 'php_file');
$node
->addDefaultsIfNotSet()
->children()
->scalarNode('directory')->defaultValue('%kernel.cache_dir%/doctrine/cache/phpfile')->end()
->scalarNode('extension')->defaultNull()->end()
->integerNode('umask')->defaultValue(0002)->end()
->end()
;
return $node;
}
/**
* Build file_system node configuration definition
*
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder
*/
private function addFileSystemNode()
{
$builder = new TreeBuilder('file_system');
$node = $this->getRootNode($builder, 'file_system');
$node
->addDefaultsIfNotSet()
->children()
->scalarNode('directory')->defaultValue('%kernel.cache_dir%/doctrine/cache/file_system')->end()
->scalarNode('extension')->defaultNull()->end()
->integerNode('umask')->defaultValue(0002)->end()
->end()
;
return $node;
}
/**
* Build sqlite3 node configuration definition
*
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder
*/
private function addSqlite3Node()
{
$builder = new TreeBuilder('sqlite3');
$node = $this->getRootNode($builder, 'sqlite3');
$node
->addDefaultsIfNotSet()
->children()
->scalarNode('connection_id')->defaultNull()->end()
->scalarNode('file_name')->defaultNull()->end()
->scalarNode('table_name')->defaultNull()->end()
->end()
;
return $node;
}
private function getRootNode(TreeBuilder $treeBuilder, $name)
{
// BC layer for symfony/config 4.1 and older
if ( ! \method_exists($treeBuilder, 'getRootNode')) {
return $treeBuilder->root($name);
}
return $treeBuilder->getRootNode();
}
}

View File

@@ -0,0 +1,44 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
/**
* Cache Definition.
*
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
*/
abstract class CacheDefinition
{
/**
* @var string
*/
private $type;
/**
* @param string $type
*/
public function __construct($type)
{
$this->type = $type;
}
/**
* @param string $name
* @param array $config
* @param \Symfony\Component\DependencyInjection\Definition $service
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
abstract public function configure($name, array $config, Definition $service, ContainerBuilder $container);
}

View File

@@ -0,0 +1,57 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
/**
* Chain definition.
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
*/
class ChainDefinition extends CacheDefinition
{
/**
* {@inheritDoc}
*/
public function configure($name, array $config, Definition $service, ContainerBuilder $container)
{
$providersConf = $config['chain'];
$providers = $this->getProviders($name, $providersConf, $container);
$service->setArguments(array($providers));
}
/**
* @param string $name
* @param array $config
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*
* @return array
*/
private function getProviders($name, array $config, ContainerBuilder $container)
{
$providers = array();
foreach ($config['providers'] as $provider) {
if (strpos($provider, 'doctrine_cache.providers.') === false) {
$provider = sprintf('doctrine_cache.providers.%s', $provider);
}
$providers[] = new Reference($provider);
}
return $providers;
}
}

View File

@@ -0,0 +1,62 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
/**
* Couchbase definition.
*
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
*/
class CouchbaseDefinition extends CacheDefinition
{
/**
* {@inheritDoc}
*/
public function configure($name, array $config, Definition $service, ContainerBuilder $container)
{
$couchbaseConf = $config['couchbase'];
$connRef = $this->getConnectionReference($name, $couchbaseConf, $container);
$service->addMethodCall('setCouchbase', array($connRef));
}
/**
* @param string $name
* @param array $config
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*
* @return \Symfony\Component\DependencyInjection\Reference
*/
private function getConnectionReference($name, array $config, ContainerBuilder $container)
{
if (isset($config['connection_id'])) {
return new Reference($config['connection_id']);
}
$host = $config['hostnames'];
$user = $config['username'];
$pass = $config['password'];
$bucket = $config['bucket_name'];
$connClass = '%doctrine_cache.couchbase.connection.class%';
$connId = sprintf('doctrine_cache.services.%s_couchbase.connection', $name);
$connDef = new Definition($connClass, array($host, $user, $pass, $bucket));
$connDef->setPublic(false);
$container->setDefinition($connId, $connDef);
return new Reference($connId);
}
}

View File

@@ -0,0 +1,35 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
/**
* FileSystem definition.
*
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
*/
class FileSystemDefinition extends CacheDefinition
{
/**
* {@inheritDoc}
*/
public function configure($name, array $config, Definition $service, ContainerBuilder $container)
{
$service->setArguments(array(
$config['file_system']['directory'],
$config['file_system']['extension'],
$config['file_system']['umask']
));
}
}

View File

@@ -0,0 +1,62 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
/**
* Memcache definition.
*
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
*/
class MemcacheDefinition extends CacheDefinition
{
/**
* {@inheritDoc}
*/
public function configure($name, array $config, Definition $service, ContainerBuilder $container)
{
$memcacheConf = $config['memcache'];
$connRef = $this->getConnectionReference($name, $memcacheConf, $container);
$service->addMethodCall('setMemcache', array($connRef));
}
/**
* @param string $name
* @param array $config
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*
* @return \Symfony\Component\DependencyInjection\Reference
*/
private function getConnectionReference($name, array $config, ContainerBuilder $container)
{
if (isset($config['connection_id'])) {
return new Reference($config['connection_id']);
}
$connClass = '%doctrine_cache.memcache.connection.class%';
$connId = sprintf('doctrine_cache.services.%s.connection', $name);
$connDef = new Definition($connClass);
foreach ($config['servers'] as $host => $server) {
$connDef->addMethodCall('addServer', array($host, $server['port']));
}
$connDef->setPublic(false);
$container->setDefinition($connId, $connDef);
return new Reference($connId);
}
}

View File

@@ -0,0 +1,66 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
/**
* Memcached definition.
*
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
*/
class MemcachedDefinition extends CacheDefinition
{
/**
* {@inheritDoc}
*/
public function configure($name, array $config, Definition $service, ContainerBuilder $container)
{
$memcachedConf = $config['memcached'];
$connRef = $this->getConnectionReference($name, $memcachedConf, $container);
$service->addMethodCall('setMemcached', array($connRef));
}
/**
* @param string $name
* @param array $config
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*
* @return \Symfony\Component\DependencyInjection\Reference
*/
private function getConnectionReference($name, array $config, ContainerBuilder $container)
{
if (isset($config['connection_id'])) {
return new Reference($config['connection_id']);
}
$connClass = '%doctrine_cache.memcached.connection.class%';
$connId = sprintf('doctrine_cache.services.%s.connection', $name);
$connDef = new Definition($connClass);
if (isset($config['persistent_id']) === true) {
$connDef->addArgument($config['persistent_id']);
}
foreach ($config['servers'] as $host => $server) {
$connDef->addMethodCall('addServer', array($host, $server['port']));
}
$connDef->setPublic(false);
$container->setDefinition($connId, $connDef);
return new Reference($connId);
}
}

View File

@@ -0,0 +1,97 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
/**
* MongoDB definition.
*
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
*/
class MongodbDefinition extends CacheDefinition
{
/**
* {@inheritDoc}
*/
public function configure($name, array $config, Definition $service, ContainerBuilder $container)
{
$memcacheConf = $config['mongodb'];
$collRef = $this->getCollectionReference($name, $memcacheConf, $container);
$service->setArguments(array($collRef));
}
/**
* @param string $name
* @param array $config
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*
* @return \Symfony\Component\DependencyInjection\Reference
*/
private function getCollectionReference($name, array $config, ContainerBuilder $container)
{
if (isset($config['collection_id'])) {
return new Reference($config['collection_id']);
}
$databaseName = $config['database_name'];
$collectionName = $config['collection_name'];
$collClass = '%doctrine_cache.mongodb.collection.class%';
$collId = sprintf('doctrine_cache.services.%s.collection', $name);
$collDef = new Definition($collClass, array($databaseName, $collectionName));
$connRef = $this->getConnectionReference($name, $config, $container);
$definition = $container->setDefinition($collId, $collDef)->setPublic(false);
if (method_exists($definition, 'setFactory')) {
$definition->setFactory(array($connRef, 'selectCollection'));
return new Reference($collId);
}
$definition
->setFactoryService($connRef)
->setFactoryMethod('selectCollection')
;
return new Reference($collId);
}
/**
* @param string $name
* @param array $config
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*
* @return \Symfony\Component\DependencyInjection\Reference
*/
private function getConnectionReference($name, array $config, ContainerBuilder $container)
{
if (isset($config['connection_id'])) {
return new Reference($config['connection_id']);
}
$server = $config['server'];
$connClass = '%doctrine_cache.mongodb.connection.class%';
$connId = sprintf('doctrine_cache.services.%s.connection', $name);
$connDef = new Definition($connClass, array($server));
$connDef->setPublic(false);
$connDef->addMethodCall('connect');
$container->setDefinition($connId, $connDef);
return new Reference($connId);
}
}

View File

@@ -0,0 +1,35 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
/**
* PhpFile definition.
*
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
*/
class PhpFileDefinition extends CacheDefinition
{
/**
* {@inheritDoc}
*/
public function configure($name, array $config, Definition $service, ContainerBuilder $container)
{
$service->setArguments(array(
$config['php_file']['directory'],
$config['php_file']['extension'],
$config['php_file']['umask']
));
}
}

View File

@@ -0,0 +1,84 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
/**
* Predis definition.
*
* @author Ivo Bathke <ivo.bathke@gmail.com>
*/
class PredisDefinition extends CacheDefinition
{
/**
* {@inheritDoc}
*/
public function configure($name, array $config, Definition $service, ContainerBuilder $container)
{
$redisConf = $config['predis'];
$connRef = $this->getConnectionReference($name, $redisConf, $container);
$service->addArgument($connRef);
}
/**
* @param string $name
* @param array $config
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*
* @return \Symfony\Component\DependencyInjection\Reference
*/
private function getConnectionReference($name, array $config, ContainerBuilder $container)
{
if (isset($config['client_id'])) {
return new Reference($config['client_id']);
}
$parameters = array(
'scheme' => $config['scheme'],
'host' => $config['host'],
'port' => $config['port'],
);
if ($config['password']) {
$parameters['password'] = $config['password'];
}
if ($config['timeout']) {
$parameters['timeout'] = $config['timeout'];
}
if ($config['database']) {
$parameters['database'] = $config['database'];
}
$options = null;
if (isset($config['options'])) {
$options = $config['options'];
}
$clientClass = '%doctrine_cache.predis.client.class%';
$clientId = sprintf('doctrine_cache.services.%s_predis.client', $name);
$clientDef = new Definition($clientClass);
$clientDef->addArgument($parameters);
$clientDef->addArgument($options);
$clientDef->setPublic(false);
$container->setDefinition($clientId, $clientDef);
return new Reference($clientId);
}
}

View File

@@ -0,0 +1,83 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
/**
* Redis definition.
*
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
*/
class RedisDefinition extends CacheDefinition
{
/**
* {@inheritDoc}
*/
public function configure($name, array $config, Definition $service, ContainerBuilder $container)
{
$redisConf = $config['redis'];
$connRef = $this->getConnectionReference($name, $redisConf, $container);
$service->addMethodCall('setRedis', array($connRef));
}
/**
* @param string $name
* @param array $config
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*
* @return \Symfony\Component\DependencyInjection\Reference
*/
private function getConnectionReference($name, array $config, ContainerBuilder $container)
{
if (isset($config['connection_id'])) {
return new Reference($config['connection_id']);
}
$host = $config['host'];
$port = $config['port'];
$connClass = '%doctrine_cache.redis.connection.class%';
$connId = sprintf('doctrine_cache.services.%s_redis.connection', $name);
$connDef = new Definition($connClass);
$connParams = array($host, $port);
if (isset($config['timeout'])) {
$connParams[] = $config['timeout'];
}
$connMethod = 'connect';
if (isset($config['persistent']) && $config['persistent']) {
$connMethod = 'pconnect';
}
$connDef->setPublic(false);
$connDef->addMethodCall($connMethod, $connParams);
if (isset($config['password'])) {
$password = $config['password'];
$connDef->addMethodCall('auth', array($password));
}
if (isset($config['database'])) {
$database = (int) $config['database'];
$connDef->addMethodCall('select', array($database));
}
$container->setDefinition($connId, $connDef);
return new Reference($connId);
}
}

View File

@@ -0,0 +1,109 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
/**
* Riak definition.
*
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
*/
class RiakDefinition extends CacheDefinition
{
/**
* {@inheritDoc}
*/
public function configure($name, array $config, Definition $service, ContainerBuilder $container)
{
$riakConf = $config['riak'];
$bucketRef = $this->getBucketReference($name, $riakConf, $container);
$service->setArguments(array($bucketRef));
}
/**
* @param string $name
* @param array $config
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*
* @return \Symfony\Component\DependencyInjection\Reference
*/
private function getBucketReference($name, array $config, ContainerBuilder $container)
{
if (isset($config['bucket_id'])) {
return new Reference($config['bucket_id']);
}
$bucketName = $config['bucket_name'];
$bucketClass = '%doctrine_cache.riak.bucket.class%';
$bucketId = sprintf('doctrine_cache.services.%s.bucket', $name);
$connDef = $this->getConnectionReference($name, $config, $container);
$bucketDef = new Definition($bucketClass, array($connDef, $bucketName));
$bucketDef->setPublic(false);
$container->setDefinition($bucketId, $bucketDef);
if ( ! empty($config['bucket_property_list'])) {
$this->configureBucketPropertyList($name, $config['bucket_property_list'], $bucketDef, $container);
}
return new Reference($bucketId);
}
/**
* @param string $name
* @param array $config
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*
* @return \Symfony\Component\DependencyInjection\Reference
*/
private function getConnectionReference($name, array $config, ContainerBuilder $container)
{
if (isset($config['connection_id'])) {
return new Reference($config['connection_id']);
}
$host = $config['host'];
$port = $config['port'];
$connClass = '%doctrine_cache.riak.connection.class%';
$connId = sprintf('doctrine_cache.services.%s.connection', $name);
$connDef = new Definition($connClass, array($host, $port));
$connDef->setPublic(false);
$container->setDefinition($connId, $connDef);
return new Reference($connId);
}
/**
* @param string $name
* @param array $config
* @param \Symfony\Component\DependencyInjection\Definition $bucketDefinition
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
private function configureBucketPropertyList($name, array $config, Definition $bucketDefinition, ContainerBuilder $container)
{
$propertyListClass = '%doctrine_cache.riak.bucket_property_list.class%';
$propertyListServiceId = sprintf('doctrine_cache.services.%s.bucket_property_list', $name);
$propertyListReference = new Reference($propertyListServiceId);
$propertyListDefinition = new Definition($propertyListClass, array(
$config['n_value'],
$config['allow_multiple']
));
$container->setDefinition($propertyListServiceId, $propertyListDefinition);
$bucketDefinition->addMethodCall('setPropertyList', array($propertyListReference));
}
}

View File

@@ -0,0 +1,60 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
/**
* Sqlite3 definition.
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
*/
class Sqlite3Definition extends CacheDefinition
{
/**
* {@inheritDoc}
*/
public function configure($name, array $config, Definition $service, ContainerBuilder $container)
{
$sqlite3Conf = $config['sqlite3'];
$tableName = $sqlite3Conf['table_name'];
$connectionRef = $this->getConnectionReference($name, $sqlite3Conf, $container);
$service->setArguments(array($connectionRef, $tableName));
}
/**
* @param string $name
* @param array $config
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*
* @return \Symfony\Component\DependencyInjection\Reference
*/
private function getConnectionReference($name, array $config, ContainerBuilder $container)
{
if (isset($config['connection_id'])) {
return new Reference($config['connection_id']);
}
$fileName = $config['file_name'];
$connClass = '%doctrine_cache.sqlite3.connection.class%';
$connId = sprintf('doctrine_cache.services.%s.connection', $name);
$connDef = new Definition($connClass, array($fileName, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE));
$connDef->setPublic(false);
$container->setDefinition($connId, $connDef);
return new Reference($connId);
}
}

View File

@@ -0,0 +1,144 @@
<?php
namespace Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
/**
* Cache Bundle Extension
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
* @author Danilo Cabello <danilo.cabello@gmail.com>
*/
class DoctrineCacheExtension extends Extension
{
/**
* @var \Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\CacheProviderLoader
*/
private $loader;
/**
* @param \Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\CacheProviderLoader $loader
*/
public function __construct(CacheProviderLoader $loader = null)
{
$this->loader = $loader ?: new CacheProviderLoader;
}
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$rootConfig = $this->processConfiguration($configuration, $configs);
$locator = new FileLocator(__DIR__ . '/../Resources/config/');
$loader = new XmlFileLoader($container, $locator);
$loader->load('services.xml');
$this->loadAcl($rootConfig, $container);
$this->loadCustomProviders($rootConfig, $container);
$this->loadCacheProviders($rootConfig, $container);
$this->loadCacheAliases($rootConfig, $container);
}
/**
* @param array $rootConfig
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
protected function loadAcl(array $rootConfig, ContainerBuilder $container)
{
if ( ! isset($rootConfig['acl_cache']['id'])) {
return;
}
if ( ! interface_exists('Symfony\Component\Security\Acl\Model\AclInterface')) {
throw new \LogicException('You must install symfony/security-acl in order to use the acl_cache functionality.');
}
$aclCacheDefinition = new Definition(
$container->getParameter('doctrine_cache.security.acl.cache.class'),
array(
new Reference($rootConfig['acl_cache']['id']),
new Reference('security.acl.permission_granting_strategy'),
)
);
$aclCacheDefinition->setPublic(false);
$container->setDefinition('doctrine_cache.security.acl.cache', $aclCacheDefinition);
$container->setAlias('security.acl.cache', 'doctrine_cache.security.acl.cache');
}
/**
* @param array $rootConfig
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
protected function loadCacheProviders(array $rootConfig, ContainerBuilder $container)
{
foreach ($rootConfig['providers'] as $name => $config) {
$this->loader->loadCacheProvider($name, $config, $container);
}
}
/**
* @param array $rootConfig
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
protected function loadCacheAliases(array $rootConfig, ContainerBuilder $container)
{
foreach ($rootConfig['aliases'] as $alias => $name) {
$container->setAlias($alias, new Alias('doctrine_cache.providers.' . $name, true));
}
}
/**
* @param array $rootConfig
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
protected function loadCustomProviders(array $rootConfig, ContainerBuilder $container)
{
foreach ($rootConfig['custom_providers'] as $type => $rootConfig) {
$providerParameterName = $this->loader->getCustomProviderParameter($type);
$definitionParameterName = $this->loader->getCustomDefinitionClassParameter($type);
$container->setParameter($providerParameterName, $rootConfig['prototype']);
if ($rootConfig['definition_class']) {
$container->setParameter($definitionParameterName, $rootConfig['definition_class']);
}
}
}
/**
* {@inheritDoc}
*/
public function getAlias()
{
return 'doctrine_cache';
}
/**
* {@inheritDoc}
*/
public function getXsdValidationBasePath()
{
return __DIR__ . '/../Resources/config/schema';
}
/**
* {@inheritDoc}
**/
public function getNamespace()
{
return 'http://doctrine-project.org/schemas/symfony-dic/cache';
}
}

View File

@@ -0,0 +1,154 @@
<?php
namespace Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\Config\FileLocator;
/**
* Symfony bridge adpter
*
* @author Kinn Coelho Julião <kinncj@php.net>
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
*/
class SymfonyBridgeAdapter
{
/**
* @var \Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\CacheProviderLoader
*/
private $cacheProviderLoader;
/**
* @var string
*/
protected $objectManagerName;
/**
* @var string
*/
protected $mappingResourceName;
/**
* @param \Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\CacheProviderLoader $cacheProviderLoader
* @param string $objectManagerName
* @param string $mappingResourceName
*/
public function __construct(CacheProviderLoader $cacheProviderLoader, $objectManagerName, $mappingResourceName)
{
$this->cacheProviderLoader = $cacheProviderLoader;
$this->objectManagerName = $objectManagerName;
$this->mappingResourceName = $mappingResourceName;
}
/**
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
public function loadServicesConfiguration(ContainerBuilder $container)
{
$locator = new FileLocator(__DIR__ . '/../Resources/config/');
$loader = new XmlFileLoader($container, $locator);
$loader->load('services.xml');
}
/**
* @param string $cacheName
* @param string $objectManagerName
* @param array $cacheDriver
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*
* @return string
*/
public function loadCacheDriver($cacheName, $objectManagerName, array $cacheDriver, ContainerBuilder $container)
{
$id = $this->getObjectManagerElementName($objectManagerName . '_' . $cacheName);
$host = isset($cacheDriver['host']) ? $cacheDriver['host'] : null;
$port = isset($cacheDriver['port']) ? $cacheDriver['port'] : null;
$password = isset($cacheDriver['password']) ? $cacheDriver['password'] : null;
$database = isset($cacheDriver['database']) ? $cacheDriver['database'] : null;
$type = $cacheDriver['type'];
if ($type == 'service') {
$container->setAlias($id, new Alias($cacheDriver['id'], false));
return $id;
}
$config = array(
'aliases' => array($id),
$type => array(),
'type' => $type,
'namespace' => null,
);
if ( ! isset($cacheDriver['namespace'])) {
// generate a unique namespace for the given application
$seed = '_'.$container->getParameter('kernel.root_dir');
if ($container->hasParameter('cache.prefix.seed')) {
$seed = '.'.$container->getParameterBag()->resolveValue($container->getParameter('cache.prefix.seed'));
}
$seed .= '.'.$container->getParameter('kernel.name').'.'.$container->getParameter('kernel.environment');
$hash = hash('sha256', $seed);
$namespace = 'sf_' . $this->mappingResourceName .'_' . $objectManagerName . '_' . $hash;
$cacheDriver['namespace'] = $namespace;
}
$config['namespace'] = $cacheDriver['namespace'];
if (in_array($type, array('memcache', 'memcached'))) {
$host = !empty($host) ? $host : 'localhost';
$config[$type]['servers'][$host] = array(
'host' => $host,
'port' => !empty($port) ? $port : 11211,
);
}
if ($type === 'redis') {
$config[$type] = array(
'host' => !empty($host) ? $host : 'localhost',
'port' => !empty($port) ? $port : 6379,
'password' => !empty($password) ? $password : null,
'database' => !empty($database) ? $database : 0
);
}
if ($type === 'predis') {
$config[$type] = array(
'scheme' => 'tcp',
'host' => !empty($host) ? $host : 'localhost',
'port' => !empty($port) ? $port : 6379,
'password' => !empty($password) ? $password : null,
'database' => !empty($database) ? $database : 0,
'timeout' => null,
);
}
$this->cacheProviderLoader->loadCacheProvider($id, $config, $container);
return $id;
}
/**
* @param array $objectManager
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
* @param string $cacheName
*/
public function loadObjectManagerCacheDriver(array $objectManager, ContainerBuilder $container, $cacheName)
{
$this->loadCacheDriver($cacheName, $objectManager['name'], $objectManager[$cacheName.'_driver'], $container);
}
/**
* @param string $name
*
* @return string
*/
protected function getObjectManagerElementName($name)
{
return $this->objectManagerName . '.' . $name;
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Doctrine\Bundle\DoctrineCacheBundle;
use Symfony\Component\Console\Application;
use Symfony\Component\HttpKernel\Bundle\Bundle;
/**
* Symfony Bundle for Doctrine Cache
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
*/
class DoctrineCacheBundle extends Bundle
{
/**
* {@inheritDoc}
*/
public function registerCommands(Application $application)
{
}
}

View File

@@ -0,0 +1,19 @@
Copyright (c) 2006-2012 Doctrine Project
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,231 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns="http://doctrine-project.org/schemas/symfony-dic/cache"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://doctrine-project.org/schemas/symfony-dic/cache"
elementFormDefault="qualified">
<xsd:element name="doctrine_cache">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="acl_cache" type="acl_cache" minOccurs="0" maxOccurs="1" />
<xsd:element name="alias" type="alias" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="provider" type="provider" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="acl_cache">
<xsd:attribute name="id" type="xsd:string" use="required"/>
</xsd:complexType>
<xsd:complexType name="alias">
<xsd:attribute name="key" type="xsd:string" use="required"/>
</xsd:complexType>
<xsd:complexType name="provider">
<xsd:sequence>
<xsd:element name="type" type="xsd:string"/>
<xsd:element name="namespace" type="xsd:string"/>
<xsd:element name="alias" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
<xsd:choice minOccurs="0" maxOccurs="1">
<xsd:element name="chain" type="chain_provider"/>
<xsd:element name="couchbase" type="couchbase_provider"/>
<xsd:element name="file-system" type="filesystem_provider"/>
<xsd:element name="memcached" type="memcached_provider"/>
<xsd:element name="memcache" type="memcache_provider"/>
<xsd:element name="mongodb" type="mongodb_provider"/>
<xsd:element name="php-file" type="phpfile_provider"/>
<xsd:element name="redis" type="redis_provider"/>
<xsd:element name="predis" type="predis_provider"/>
<xsd:element name="riak" type="riak_provider"/>
<xsd:element name="sqlite3" type="sqlite3_provider"/>
</xsd:choice>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="namespace" type="xsd:string"/>
<xsd:attribute name="type" type="xsd:string" />
</xsd:complexType>
<!-- memcached -->
<xsd:complexType name="memcached_provider">
<xsd:sequence>
<xsd:element name="server" type="memcached_server" minOccurs="1" maxOccurs="unbounded" />
<xsd:element name="connection-id" type="xsd:string" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
<xsd:attribute name="persistent-id" type="xsd:string"/>
<xsd:attribute name="connection-id" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="memcached_server">
<xsd:sequence>
<xsd:element name="host" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="port" type="xsd:string" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
<xsd:attribute name="connection-id" type="xsd:string"/>
<xsd:attribute name="host" type="xsd:string"/>
<xsd:attribute name="port" type="xsd:string"/>
</xsd:complexType>
<!-- memcache -->
<xsd:complexType name="memcache_provider">
<xsd:sequence>
<xsd:element name="server" type="memcached_server" minOccurs="1" maxOccurs="unbounded" />
<xsd:element name="connection-id" type="xsd:string" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
<xsd:attribute name="connection-id" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="memcache_server">
<xsd:sequence>
<xsd:element name="host" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="port" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="connection-id" type="xsd:string" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
<xsd:attribute name="host" type="xsd:string"/>
<xsd:attribute name="port" type="xsd:string"/>
</xsd:complexType>
<!-- redis -->
<xsd:complexType name="redis_provider">
<xsd:sequence>
<xsd:element name="host" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="port" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="password" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="timeout" type="xsd:unsignedInt" minOccurs="0" maxOccurs="1" />
<xsd:element name="database" type="xsd:unsignedInt" minOccurs="0" maxOccurs="1" />
<xsd:element name="connection-id" type="xsd:string" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
<xsd:attribute name="host" type="xsd:string"/>
<xsd:attribute name="port" type="xsd:string"/>
<xsd:attribute name="password" type="xsd:string" />
<xsd:attribute name="timeout" type="xsd:unsignedInt" />
<xsd:attribute name="database" type="xsd:unsignedInt" />
<xsd:attribute name="persistent" type="xsd:boolean" />
</xsd:complexType>
<!-- predis -->
<xsd:complexType name="predis_provider">
<xsd:sequence>
<xsd:element name="scheme" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="host" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="port" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="password" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="timeout" type="xsd:unsignedInt" minOccurs="0" maxOccurs="1" />
<xsd:element name="database" type="xsd:unsignedInt" minOccurs="0" maxOccurs="1" />
<xsd:element name="options" type="predis_options" minOccurs="0" maxOccurs="0" />
</xsd:sequence>
<xsd:attribute name="scheme" type="xsd:string"/>
<xsd:attribute name="host" type="xsd:string"/>
<xsd:attribute name="port" type="xsd:string"/>
<xsd:attribute name="password" type="xsd:string" />
<xsd:attribute name="timeout" type="xsd:unsignedInt" />
<xsd:attribute name="database" type="xsd:unsignedInt" />
</xsd:complexType>
<xsd:complexType name="predis_options">
<xsd:sequence>
<xsd:any minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<!-- couchbase -->
<xsd:complexType name="couchbase_provider">
<xsd:sequence>
<xsd:element name="username" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="password" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="bucket-name" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="hostname" type="couchbase_hostname" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="username" type="xsd:string"/>
<xsd:attribute name="password" type="xsd:string"/>
<xsd:attribute name="bucket-name" type="xsd:string"/>
</xsd:complexType>
<xsd:simpleType name="couchbase_hostname">
<xsd:restriction base="xsd:string" />
</xsd:simpleType>
<!-- riak -->
<xsd:complexType name="riak_provider">
<xsd:sequence>
<xsd:element name="bucket-property-list" type="memcache_bucket_property_list" minOccurs="0" maxOccurs="1" />
<xsd:element name="connection-id" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="bucket-name" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="bucket-id" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="host" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="port" type="xsd:string" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
<xsd:attribute name="connection-id" type="xsd:string"/>
<xsd:attribute name="bucket-name" type="xsd:string"/>
<xsd:attribute name="bucket-id" type="xsd:string"/>
<xsd:attribute name="host" type="xsd:string"/>
<xsd:attribute name="port" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="memcache_bucket_property_list">
<xsd:sequence>
<xsd:element name="allow-multiple" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="n-value" type="xsd:string" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
<xsd:attribute name="allow-multiple" type="xsd:string" />
<xsd:attribute name="n-value" type="xsd:string" />
</xsd:complexType>
<!-- mongodb -->
<xsd:complexType name="mongodb_provider">
<xsd:sequence>
<xsd:element name="server" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="database-name" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="collection-name" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="connection-id" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="collection-id" type="xsd:string" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
<xsd:attribute name="server" type="xsd:string" />
<xsd:attribute name="database-id" type="xsd:string" />
<xsd:attribute name="collection-id" type="xsd:string" />
<xsd:attribute name="database-name" type="xsd:string" />
<xsd:attribute name="collection-name" type="xsd:string" />
</xsd:complexType>
<!-- file-system -->
<xsd:complexType name="filesystem_provider">
<xsd:sequence>
<xsd:element name="extension" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="directory" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="umask" type="xsd:integer" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
<xsd:attribute name="extension" type="xsd:string"/>
<xsd:attribute name="directory" type="xsd:string"/>
<xsd:attribute name="umask" type="xsd:integer"/>
</xsd:complexType>
<!-- php-file -->
<xsd:complexType name="phpfile_provider">
<xsd:sequence>
<xsd:element name="extension" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="directory" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="umask" type="xsd:integer" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
<xsd:attribute name="extension" type="xsd:string"/>
<xsd:attribute name="directory" type="xsd:string"/>
<xsd:attribute name="umask" type="xsd:integer"/>
</xsd:complexType>
<!-- sqlite3 -->
<xsd:complexType name="sqlite3_provider">
<xsd:sequence>
<xsd:element name="file-name" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="table-name" type="xsd:string" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
<xsd:attribute name="file-name" type="xsd:string"/>
<xsd:attribute name="table-name" type="xsd:string"/>
</xsd:complexType>
<!-- chain -->
<xsd:complexType name="chain_provider">
<xsd:sequence>
<xsd:element name="provider" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>

View File

@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="doctrine_cache.apc.class">Doctrine\Common\Cache\ApcCache</parameter>
<parameter key="doctrine_cache.apcu.class">Doctrine\Common\Cache\ApcuCache</parameter>
<parameter key="doctrine_cache.array.class">Doctrine\Common\Cache\ArrayCache</parameter>
<parameter key="doctrine_cache.chain.class">Doctrine\Common\Cache\ChainCache</parameter>
<parameter key="doctrine_cache.couchbase.class">Doctrine\Common\Cache\CouchbaseCache</parameter>
<parameter key="doctrine_cache.couchbase.connection.class">Couchbase</parameter>
<parameter key="doctrine_cache.couchbase.hostnames">localhost:8091</parameter>
<parameter key="doctrine_cache.file_system.class">Doctrine\Common\Cache\FilesystemCache</parameter>
<parameter key="doctrine_cache.php_file.class">Doctrine\Common\Cache\PhpFileCache</parameter>
<parameter key="doctrine_cache.memcache.class">Doctrine\Common\Cache\MemcacheCache</parameter>
<parameter key="doctrine_cache.memcache.connection.class">Memcache</parameter>
<parameter key="doctrine_cache.memcache.host">localhost</parameter>
<parameter key="doctrine_cache.memcache.port">11211</parameter>
<parameter key="doctrine_cache.memcached.class">Doctrine\Common\Cache\MemcachedCache</parameter>
<parameter key="doctrine_cache.memcached.connection.class">Memcached</parameter>
<parameter key="doctrine_cache.memcached.host">localhost</parameter>
<parameter key="doctrine_cache.memcached.port">11211</parameter>
<parameter key="doctrine_cache.mongodb.class">Doctrine\Common\Cache\MongoDBCache</parameter>
<parameter key="doctrine_cache.mongodb.collection.class">MongoCollection</parameter>
<parameter key="doctrine_cache.mongodb.connection.class">MongoClient</parameter>
<parameter key="doctrine_cache.mongodb.server">localhost:27017</parameter>
<parameter key="doctrine_cache.predis.client.class">Predis\Client</parameter>
<parameter key="doctrine_cache.predis.scheme">tcp</parameter>
<parameter key="doctrine_cache.predis.host">localhost</parameter>
<parameter key="doctrine_cache.predis.port">6379</parameter>
<parameter key="doctrine_cache.redis.class">Doctrine\Common\Cache\RedisCache</parameter>
<parameter key="doctrine_cache.redis.connection.class">Redis</parameter>
<parameter key="doctrine_cache.redis.host">localhost</parameter>
<parameter key="doctrine_cache.redis.port">6379</parameter>
<parameter key="doctrine_cache.riak.class">Doctrine\Common\Cache\RiakCache</parameter>
<parameter key="doctrine_cache.riak.bucket.class">Riak\Bucket</parameter>
<parameter key="doctrine_cache.riak.connection.class">Riak\Connection</parameter>
<parameter key="doctrine_cache.riak.bucket_property_list.class">Riak\BucketPropertyList</parameter>
<parameter key="doctrine_cache.riak.host">localhost</parameter>
<parameter key="doctrine_cache.riak.port">8087</parameter>
<parameter key="doctrine_cache.sqlite3.class">Doctrine\Common\Cache\SQLite3Cache</parameter>
<parameter key="doctrine_cache.sqlite3.connection.class">SQLite3</parameter>
<parameter key="doctrine_cache.void.class">Doctrine\Common\Cache\VoidCache</parameter>
<parameter key="doctrine_cache.wincache.class">Doctrine\Common\Cache\WinCacheCache</parameter>
<parameter key="doctrine_cache.xcache.class">Doctrine\Common\Cache\XcacheCache</parameter>
<parameter key="doctrine_cache.zenddata.class">Doctrine\Common\Cache\ZendDataCache</parameter>
<parameter key="doctrine_cache.security.acl.cache.class">Doctrine\Bundle\DoctrineCacheBundle\Acl\Model\AclCache</parameter>
</parameters>
<services>
<service id="doctrine_cache.abstract.apc" class="%doctrine_cache.apc.class%" abstract="true" />
<service id="doctrine_cache.abstract.apcu" class="%doctrine_cache.apcu.class%" abstract="true" />
<service id="doctrine_cache.abstract.array" class="%doctrine_cache.array.class%" abstract="true" />
<service id="doctrine_cache.abstract.chain" class="%doctrine_cache.chain.class%" abstract="true" />
<service id="doctrine_cache.abstract.couchbase" class="%doctrine_cache.couchbase.class%" abstract="true" />
<service id="doctrine_cache.abstract.file_system" class="%doctrine_cache.file_system.class%" abstract="true" />
<service id="doctrine_cache.abstract.php_file" class="%doctrine_cache.php_file.class%" abstract="true" />
<service id="doctrine_cache.abstract.memcache" class="%doctrine_cache.memcache.class%" abstract="true" />
<service id="doctrine_cache.abstract.memcached" class="%doctrine_cache.memcached.class%" abstract="true" />
<service id="doctrine_cache.abstract.mongodb" class="%doctrine_cache.mongodb.class%" abstract="true" />
<service id="doctrine_cache.abstract.redis" class="%doctrine_cache.redis.class%" abstract="true" />
<service id="doctrine_cache.abstract.predis" class="Doctrine\Common\Cache\PredisCache" abstract="true" />
<service id="doctrine_cache.abstract.riak" class="%doctrine_cache.riak.class%" abstract="true" />
<service id="doctrine_cache.abstract.sqlite3" class="%doctrine_cache.sqlite3.class%" abstract="true" />
<service id="doctrine_cache.abstract.void" class="%doctrine_cache.void.class%" abstract="true" />
<service id="doctrine_cache.abstract.wincache" class="%doctrine_cache.wincache.class%" abstract="true" />
<service id="doctrine_cache.abstract.xcache" class="%doctrine_cache.xcache.class%" abstract="true" />
<service id="doctrine_cache.abstract.zenddata" class="%doctrine_cache.zenddata.class%" abstract="true" />
<service id="doctrine_cache.contains_command" class="Doctrine\Bundle\DoctrineCacheBundle\Command\ContainsCommand">
<tag name="console.command" />
</service>
<service id="doctrine_cache.delete_command" class="Doctrine\Bundle\DoctrineCacheBundle\Command\DeleteCommand">
<tag name="console.command" />
</service>
<service id="doctrine_cache.flush_command" class="Doctrine\Bundle\DoctrineCacheBundle\Command\FlushCommand">
<tag name="console.command" />
</service>
<service id="doctrine_cache.stats_command" class="Doctrine\Bundle\DoctrineCacheBundle\Command\StatsCommand">
<tag name="console.command" />
</service>
</services>
</container>