pax_global_header00006660000000000000000000000064126517263230014521gustar00rootroot0000000000000052 comment=18c600a9b82f6454d2e81ca4957cdd56a1cf3504 DoctrineCacheBundle-1.3.0/000077500000000000000000000000001265172632300153475ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/.coveralls.yml000066400000000000000000000001371265172632300201430ustar00rootroot00000000000000# for php-coveralls service_name: travis-ci src_dir: ./ coverage_clover: build/logs/clover.xml DoctrineCacheBundle-1.3.0/.gitignore000066400000000000000000000000761265172632300173420ustar00rootroot00000000000000vendor build composer.phar composer.lock phpunit.xml cache.db DoctrineCacheBundle-1.3.0/.travis.yml000066400000000000000000000013071265172632300174610ustar00rootroot00000000000000language: php sudo: false php: - 5.3 - 5.4 - 5.5 - 5.6 - hhvm services: - riak - mongodb - memcached - redis-server before_script: - ./Tests/travis/install-deps.sh - composer self-update - if [ "$DEPS" = "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi; - composer update --prefer-source script: - ./vendor/bin/phpunit -v --coverage-clover ./build/logs/clover.xml - ./vendor/bin/phpcs -np --extensions=php --ignore=vendor/*,Tests/* --standard=ruleset.xml . after_script: - php ./vendor/bin/coveralls -v matrix: allow_failures: - php: hhvm include: - php: 5.6 env: DEPS="dev" DoctrineCacheBundle-1.3.0/Acl/000077500000000000000000000000001265172632300160465ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Acl/Model/000077500000000000000000000000001265172632300171065ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Acl/Model/AclCache.php000066400000000000000000000142031265172632300212420ustar00rootroot00000000000000 * @author Fabien Potencier * @author Johannes M. Schmitt */ 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); } } DoctrineCacheBundle-1.3.0/Command/000077500000000000000000000000001265172632300167255ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Command/CacheCommand.php000066400000000000000000000034021265172632300217370ustar00rootroot00000000000000 */ 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; } } DoctrineCacheBundle-1.3.0/Command/ContainsCommand.php000066400000000000000000000023331265172632300225140ustar00rootroot00000000000000 */ 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) ? 'TRUE' : 'FALSE'; $output->writeln($message); } } DoctrineCacheBundle-1.3.0/Command/DeleteCommand.php000066400000000000000000000042521265172632300221420ustar00rootroot00000000000000 */ 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 in <$color>%s has <$color>%s"; $message = sprintf($message, $cacheId, $cacheName, $success, true); } if ($all) { $message = "Deletion of <$color>all entries in <$color>%s has <$color>%s"; $message = sprintf($message, $cacheName, $success, true); } $output->writeln($message); } } DoctrineCacheBundle-1.3.0/Command/FlushCommand.php000066400000000000000000000025121265172632300220160ustar00rootroot00000000000000 */ 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 %s provider of type %s', $cacheName, $cacheProviderName, true)); $cacheProvider->flushAll(); } } DoctrineCacheBundle-1.3.0/Command/StatsCommand.php000066400000000000000000000031201265172632300220270ustar00rootroot00000000000000 */ 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, 'Which cache provider to flush?'); } /** * {@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 %s provider of type %s', $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 %s provider of type %s:', $cacheName, $cacheProviderName, true)); $output->writeln($lines); } } DoctrineCacheBundle-1.3.0/DependencyInjection/000077500000000000000000000000001265172632300212705ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/DependencyInjection/CacheProviderLoader.php000066400000000000000000000126021265172632300256470ustar00rootroot00000000000000. */ namespace Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection; use Doctrine\Common\Inflector\Inflector; use Symfony\Component\DependencyInjection\DefinitionDecorator; use Symfony\Component\DependencyInjection\ContainerBuilder; /** * Cache provider loader * * @author Fabio B. Silva */ 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'])); } foreach ($config['aliases'] as $alias) { $container->setAlias($alias, $serviceId); } 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; if ($type === 'custom_provider') { $type = $config['custom_provider']['type']; $param = $this->getCustomProviderParameter($type); if ($container->hasParameter($param)) { return new DefinitionDecorator($container->getParameter($param)); } } if ($container->hasDefinition($id)) { return new DefinitionDecorator($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; } } DoctrineCacheBundle-1.3.0/DependencyInjection/Configuration.php000066400000000000000000000452411265172632300246160ustar00rootroot00000000000000. */ 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 * @author Fabio B. Silva */ 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(); $node = $builder->root('doctrine_cache', 'array'); $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', '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(); $node = $builder->root($name); return $node; } /** * Build custom node configuration definition * * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder */ private function addCustomProviderNode() { $builder = new TreeBuilder(); $node = $builder->root('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(); $node = $builder->root('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(); $node = $builder->root('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(); $node = $builder->root('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(); $node = $builder->root('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() ->end() ; return $node; } /** * Build predis node configuration definition * * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder */ private function addPredisNode() { $builder = new TreeBuilder(); $node = $builder->root('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(); $node = $builder->root('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(); $node = $builder->root('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(); $node = $builder->root('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(); $node = $builder->root('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(); $node = $builder->root('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(); $node = $builder->root('sqlite3'); $node ->addDefaultsIfNotSet() ->children() ->scalarNode('connection_id')->defaultNull()->end() ->scalarNode('file_name')->defaultNull()->end() ->scalarNode('table_name')->defaultNull()->end() ->end() ; return $node; } } DoctrineCacheBundle-1.3.0/DependencyInjection/Definition/000077500000000000000000000000001265172632300233605ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/DependencyInjection/Definition/CacheDefinition.php000066400000000000000000000022361265172632300271100ustar00rootroot00000000000000 * * 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 */ 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); } DoctrineCacheBundle-1.3.0/DependencyInjection/Definition/ChainDefinition.php000066400000000000000000000032211265172632300271220ustar00rootroot00000000000000 * * 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 */ 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; } } DoctrineCacheBundle-1.3.0/DependencyInjection/Definition/CouchbaseDefinition.php000066400000000000000000000040441265172632300300000ustar00rootroot00000000000000 * * 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 */ 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); } } DoctrineCacheBundle-1.3.0/DependencyInjection/Definition/FileSystemDefinition.php000066400000000000000000000016311265172632300301670ustar00rootroot00000000000000 * * 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 */ 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'] )); } } DoctrineCacheBundle-1.3.0/DependencyInjection/Definition/MemcacheDefinition.php000066400000000000000000000037331265172632300276120ustar00rootroot00000000000000 * * 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 */ 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); } } DoctrineCacheBundle-1.3.0/DependencyInjection/Definition/MemcachedDefinition.php000066400000000000000000000041431265172632300277520ustar00rootroot00000000000000 * * 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 */ 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); } } DoctrineCacheBundle-1.3.0/DependencyInjection/Definition/MongodbDefinition.php000066400000000000000000000064721265172632300275000ustar00rootroot00000000000000 * * 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 */ 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); } } DoctrineCacheBundle-1.3.0/DependencyInjection/Definition/PhpFileDefinition.php000066400000000000000000000016121265172632300274310ustar00rootroot00000000000000 * * 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 */ 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'] )); } } DoctrineCacheBundle-1.3.0/DependencyInjection/Definition/PredisDefinition.php000066400000000000000000000046711265172632300273400ustar00rootroot00000000000000 * * 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 */ 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); } } DoctrineCacheBundle-1.3.0/DependencyInjection/Definition/RedisDefinition.php000066400000000000000000000046331265172632300271560ustar00rootroot00000000000000 * * 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 */ 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']; } $connDef->setPublic(false); $connDef->addMethodCall('connect', $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); } } DoctrineCacheBundle-1.3.0/DependencyInjection/Definition/RiakDefinition.php000066400000000000000000000101551265172632300267720ustar00rootroot00000000000000 * * 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 */ 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)); } } DoctrineCacheBundle-1.3.0/DependencyInjection/Definition/Sqlite3Definition.php000066400000000000000000000037441265172632300274360ustar00rootroot00000000000000 * * 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 */ 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); } } DoctrineCacheBundle-1.3.0/DependencyInjection/DoctrineCacheExtension.php000066400000000000000000000134311265172632300263730ustar00rootroot00000000000000. */ namespace Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection; use Symfony\Component\Config\FileLocator; 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 * @author Fabio B. Silva * @author Danilo Cabello */ 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, 'doctrine_cache.providers.' . $name); } } /** * @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'; } } DoctrineCacheBundle-1.3.0/DependencyInjection/SymfonyBridgeAdapter.php000066400000000000000000000136161265172632300260720ustar00rootroot00000000000000. */ 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 * @author Fabio B. Silva */ 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 $environment = $container->getParameter('kernel.root_dir').$container->getParameter('kernel.environment'); $hash = hash('sha256', $environment); $namespace = 'sf2' . $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 ); } $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; } } DoctrineCacheBundle-1.3.0/DoctrineCacheBundle.php000066400000000000000000000024131265172632300217050ustar00rootroot00000000000000. */ namespace Doctrine\Bundle\DoctrineCacheBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; /** * Symfony Bundle for Doctrine Cache * * @author Guilherme Blanco * @author Fabio B. Silva */ class DoctrineCacheBundle extends Bundle { } DoctrineCacheBundle-1.3.0/LICENSE000066400000000000000000000020501265172632300163510ustar00rootroot00000000000000Copyright (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.DoctrineCacheBundle-1.3.0/README.md000066400000000000000000000016471265172632300166360ustar00rootroot00000000000000DoctrineCacheBundle =================== Symfony Bundle for Doctrine Cache. Master: [![Build Status](https://secure.travis-ci.org/doctrine/DoctrineCacheBundle.png?branch=master)](http://travis-ci.org/doctrine/DoctrineCacheBundle) Master: [![Coverage Status](https://coveralls.io/repos/doctrine/DoctrineCacheBundle/badge.png?branch=master)](https://coveralls.io/r/doctrine/DoctrineCacheBundle?branch=master) ## Installation 1. Add this bundle to your project as a composer dependency: ```bash composer require doctrine/doctrine-cache-bundle ``` 2. Add this bundle in your application kernel: ```php // app/AppKernel.php public function registerBundles() { // ... $bundles[] = new \Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(); return $bundles; } ``` Read the [documentation](Resources/doc/index.rst) to learn how to configure and use your own cache providers. DoctrineCacheBundle-1.3.0/Resources/000077500000000000000000000000001265172632300173215ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Resources/config/000077500000000000000000000000001265172632300205665ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Resources/config/schema/000077500000000000000000000000001265172632300220265ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Resources/config/schema/doctrine_cache-1.0.xsd000066400000000000000000000264301265172632300260010ustar00rootroot00000000000000 DoctrineCacheBundle-1.3.0/Resources/config/services.xml000066400000000000000000000137651265172632300231470ustar00rootroot00000000000000 Doctrine\Common\Cache\ApcCache Doctrine\Common\Cache\ApcuCache Doctrine\Common\Cache\ArrayCache Doctrine\Common\Cache\ChainCache Doctrine\Common\Cache\CouchbaseCache Couchbase localhost:8091 Doctrine\Common\Cache\FilesystemCache Doctrine\Common\Cache\PhpFileCache Doctrine\Common\Cache\MemcacheCache Memcache localhost 11211 Doctrine\Common\Cache\MemcachedCache Memcached localhost 11211 Doctrine\Common\Cache\MongoDBCache MongoCollection MongoClient localhost:27017 Predis\Client tcp localhost 6379 Doctrine\Common\Cache\RedisCache Redis localhost 6379 Doctrine\Common\Cache\RiakCache Riak\Bucket Riak\Connection Riak\BucketPropertyList localhost 8087 Doctrine\Common\Cache\SQLite3Cache SQLite3 Doctrine\Common\Cache\VoidCache Doctrine\Common\Cache\WinCacheCache Doctrine\Common\Cache\XcacheCache Doctrine\Common\Cache\ZendDataCache Doctrine\Bundle\DoctrineCacheBundle\Acl\Model\AclCache DoctrineCacheBundle-1.3.0/Resources/doc/000077500000000000000000000000001265172632300200665ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Resources/doc/acl_cache.rst000066400000000000000000000025021265172632300225010ustar00rootroot00000000000000Symfony ACL Cache ================= .. configuration-block:: .. code-block:: yaml # app/config/config.yml doctrine_cache: acl_cache: id: 'doctrine_cache.providers.acl_apc_provider' providers: acl_apc_provider: type: 'apc' .. code-block:: xml Check the following sample:: /** @var $aclCache Symfony\Component\Security\Acl\Model\AclCacheInterface */ $aclCache = $this->container->get('security.acl.cache'); DoctrineCacheBundle-1.3.0/Resources/doc/custom_providers.rst000066400000000000000000000050131265172632300242260ustar00rootroot00000000000000Custom Providers ================ You can also register your own custom cache drivers: .. configuration-block:: .. code-block:: yaml # app/config/services.yml services: my_custom_provider_service: class: "MyCustomType" # ... # app/config/config.yml doctrine_cache: custom_providers: my_custom_type: prototype: "my_custom_provider_service" definition_class: "MyCustomTypeDefinition" # optional configuration providers: my_custom_type_provider: my_custom_type: config_foo: "foo" config_bar: "bar" .. code-block:: xml my_custom_provider_service MyCustomTypeDefinition foo bar .. note:: Definition class is a optional configuration that will parse option arguments given to your custom cache driver. See `CacheDefinition code`_. .. _`CacheDefinition code`: https://github.com/doctrine/DoctrineCacheBundle/blob/master/DependencyInjection/Definition/CacheDefinition.php DoctrineCacheBundle-1.3.0/Resources/doc/index.rst000066400000000000000000000006141265172632300217300ustar00rootroot00000000000000DoctrineCacheBundle =================== The DoctrineCacheBundle allows your Symfony application to use different caching systems through the `Doctrine Cache`_ library. .. toctree:: installation usage custom_providers service_parameter acl_cache reference .. _`Doctrine Cache`: http://docs.doctrine-project.org/projects/doctrine-common/en/latest/reference/caching.html DoctrineCacheBundle-1.3.0/Resources/doc/installation.rst000066400000000000000000000020041265172632300233150ustar00rootroot00000000000000Installation ============ Step 1: Download the Bundle --------------------------- Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle: .. code-block:: bash $ composer require doctrine/doctrine-cache-bundle This command requires you to have Composer installed globally, as explained in the `installation chapter`_ of the Composer documentation. Step 2: Enable the Bundle ------------------------- Then, enable the bundle by adding it to the list of registered bundles in the ``app/AppKernel.php`` file of your project:: my_bucket_name See :doc:`reference` for all the specific configurations. DoctrineCacheBundle-1.3.0/Resources/doc/usage.rst000066400000000000000000000071251265172632300217310ustar00rootroot00000000000000Usage ===== First, configure your cache providers under the ``doctrine_cache`` configuration option. Example: .. configuration-block:: .. code-block:: yaml # app/config/config.yml doctrine_cache: providers: my_apc_metadata_cache: type: apc namespace: metadata_cache_ns my_apc_query_cache: namespace: query_cache_ns apc: ~ .. code-block:: yaml apc metadata_cache_ns Then, use the newly created ``doctrine_cache.providers.{provider_name}`` container services anywhere in your application:: $apcCache = $this->container->get('doctrine_cache.providers.my_apc_cache'); $arrayCache = $this->container->get('doctrine_cache.providers.my_array_cache'); Service Aliases --------------- In order to make your code more concise, you can define aliases for these services thanks to the ``aliases`` configuration option. Example: .. configuration-block:: .. code-block:: yaml # app/config/config.yml doctrine_cache: aliases: cache_apc: my_apc_cache providers: my_apc_cache: type: apc namespace: my_apc_cache_ns aliases: - apc_cache .. code-block:: xml my_apc_cache apc my_apc_cache_ns apc_cache Now you can use the short ``apc_cache`` alias to get the provider called ``my_apc_cache``, instead of using ``doctrine_cache.providers.my_apc_cache``:: $apcCache = $this->container->get('apc_cache'); DoctrineCacheBundle-1.3.0/Tests/000077500000000000000000000000001265172632300164515ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Tests/Acl/000077500000000000000000000000001265172632300171505ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Tests/Acl/Model/000077500000000000000000000000001265172632300202105ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Tests/Acl/Model/AclCacheTest.php000066400000000000000000000134721265172632300232130ustar00rootroot00000000000000cacheProvider = new ArrayCache(); $this->permissionGrantingStrategy = new PermissionGrantingStrategy(); $this->aclCache = new AclCache($this->cacheProvider, $this->permissionGrantingStrategy); } public function tearDown() { $this->cacheProvider = null; $this->permissionGrantingStrategy = null; $this->aclCache = null; } /** * @dataProvider provideDataForEvictFromCacheById */ public function testEvictFromCacheById($expected, $primaryKey) { $this->cacheProvider->save('bar', 'foo_1'); $this->cacheProvider->save('foo_1', 's:4:test;'); $this->aclCache->evictFromCacheById($primaryKey); $this->assertEquals($expected, $this->cacheProvider->contains('bar')); $this->assertEquals($expected, $this->cacheProvider->contains('foo_1')); } public function provideDataForEvictFromCacheById() { return array( array(false, 'bar'), array(true, 'test'), ); } /** * @dataProvider provideDataForEvictFromCacheByIdentity */ public function testEvictFromCacheByIdentity($expected, $identity) { $this->cacheProvider->save('foo_1', 's:4:test;'); $this->aclCache->evictFromCacheByIdentity($identity); $this->assertEquals($expected, $this->cacheProvider->contains('foo_1')); } public function provideDataForEvictFromCacheByIdentity() { return array( array(false, new ObjectIdentity(1, 'foo')), ); } /** * @expectedException \InvalidArgumentException */ public function testPutInCacheWithoutId() { $acl = new Acl(null, new ObjectIdentity(1, 'foo'), $this->permissionGrantingStrategy, array(), false); $this->aclCache->putInCache($acl); } public function testPutInCacheWithoutParent() { $acl = $this->getAcl(0); $this->aclCache->putInCache($acl); $this->assertTrue($this->cacheProvider->contains('foo1_class')); $this->assertTrue($this->cacheProvider->contains('oid1')); } public function testPutInCacheWithParent() { $acl = $this->getAcl(2); $this->aclCache->putInCache($acl); // current $this->assertTrue($this->cacheProvider->contains('foo2_class')); $this->assertTrue($this->cacheProvider->contains('oid2')); // parent $this->assertTrue($this->cacheProvider->contains('foo3_class')); $this->assertTrue($this->cacheProvider->contains('oid3')); // grand-parent $this->assertTrue($this->cacheProvider->contains('foo4_class')); $this->assertTrue($this->cacheProvider->contains('oid4')); } public function testClearCache() { $acl = $this->getAcl(0); $this->aclCache->putInCache($acl); $this->aclCache->clearCache(); $this->assertFalse($this->cacheProvider->contains('foo5_class')); $this->assertFalse($this->cacheProvider->contains('oid5')); } public function testGetFromCacheById() { $acl = $this->getAcl(1); $this->aclCache->putInCache($acl); $cachedAcl = $this->aclCache->getFromCacheById($acl->getId()); $this->assertEquals($acl->getId(), $cachedAcl->getId()); $this->assertNotNull($cachedParentAcl = $cachedAcl->getParentAcl()); $this->assertEquals($acl->getParentAcl()->getId(), $cachedParentAcl->getId()); $this->assertEquals($acl->getClassFieldAces('foo'), $cachedAcl->getClassFieldAces('foo')); $this->assertEquals($acl->getObjectFieldAces('foo'), $cachedAcl->getObjectFieldAces('foo')); } public function testGetFromCacheByIdentity() { $acl = $this->getAcl(1); $this->aclCache->putInCache($acl); $cachedAcl = $this->aclCache->getFromCacheByIdentity($acl->getObjectIdentity()); $this->assertEquals($acl->getId(), $cachedAcl->getId()); $this->assertNotNull($cachedParentAcl = $cachedAcl->getParentAcl()); $this->assertEquals($acl->getParentAcl()->getId(), $cachedParentAcl->getId()); $this->assertEquals($acl->getClassFieldAces('foo'), $cachedAcl->getClassFieldAces('foo')); $this->assertEquals($acl->getObjectFieldAces('foo'), $cachedAcl->getObjectFieldAces('foo')); } protected function getAcl($depth = 0) { static $id = 1; $acl = new Acl( 'oid' . $id, new ObjectIdentity('class', 'foo' . $id), $this->permissionGrantingStrategy, array(), $depth > 0 ); // insert some ACEs $sid = new UserSecurityIdentity('johannes', 'Foo'); $acl->insertClassAce($sid, 1); $acl->insertClassFieldAce('foo', $sid, 1); $acl->insertObjectAce($sid, 1); $acl->insertObjectFieldAce('foo', $sid, 1); $id++; if ($depth > 0) { $acl->setParentAcl($this->getAcl($depth - 1)); } return $acl; } } DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/000077500000000000000000000000001265172632300223725ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/AbstractDoctrineCacheExtensionTest.php000066400000000000000000000361571265172632300320330ustar00rootroot00000000000000. */ namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\DependencyInjection; use Doctrine\Bundle\DoctrineCacheBundle\Tests\TestCase; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\ResolveDefinitionTemplatesPass; use Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\DoctrineCacheExtension; /** * @group Extension * @group DependencyInjection */ abstract class AbstractDoctrineCacheExtensionTest extends TestCase { protected function setUp() { parent::setUp(); } abstract protected function loadFromFile(ContainerBuilder $container, $file); public function testParameters() { $container = $this->createContainer(); $cacheExtension = new DoctrineCacheExtension(); $cacheExtension->load(array(), $container); $this->assertTrue($container->hasParameter('doctrine_cache.apc.class')); $this->assertTrue($container->hasParameter('doctrine_cache.array.class')); $this->assertTrue($container->hasParameter('doctrine_cache.couchbase.class')); $this->assertTrue($container->hasParameter('doctrine_cache.file_system.class')); $this->assertTrue($container->hasParameter('doctrine_cache.memcached.class')); $this->assertTrue($container->hasParameter('doctrine_cache.memcache.class')); $this->assertTrue($container->hasParameter('doctrine_cache.mongodb.class')); $this->assertTrue($container->hasParameter('doctrine_cache.php_file.class')); $this->assertTrue($container->hasParameter('doctrine_cache.redis.class')); $this->assertTrue($container->hasParameter('doctrine_cache.riak.class')); $this->assertTrue($container->hasParameter('doctrine_cache.sqlite3.class')); $this->assertTrue($container->hasParameter('doctrine_cache.void.class')); $this->assertTrue($container->hasParameter('doctrine_cache.xcache.class')); $this->assertTrue($container->hasParameter('doctrine_cache.wincache.class')); $this->assertTrue($container->hasParameter('doctrine_cache.zenddata.class')); } public function testBasicCache() { $container = $this->compileContainer('basic'); $drivers = array( 'basic_apc_provider' => '%doctrine_cache.apc.class%', 'basic_array_provider' => '%doctrine_cache.array.class%', 'basic_void_provider' => '%doctrine_cache.void.class%', 'basic_xcache_provider' => '%doctrine_cache.xcache.class%', 'basic_wincache_provider' => '%doctrine_cache.wincache.class%', 'basic_zenddata_provider' => '%doctrine_cache.zenddata.class%', 'basic_ns_zenddata_provider' => '%doctrine_cache.zenddata.class%', 'basic_apc_provider2' => '%doctrine_cache.apc.class%', 'basic_array_provider2' => '%doctrine_cache.array.class%', 'basic_void_provider2' => '%doctrine_cache.void.class%', 'basic_xcache_provider2' => '%doctrine_cache.xcache.class%', 'basic_wincache_provider2' => '%doctrine_cache.wincache.class%', 'basic_zenddata_provider2' => '%doctrine_cache.zenddata.class%', ); foreach ($drivers as $key => $value) { $this->assertCacheProvider($container, $key, $value); } } public function testBasicConfigurableCache() { $container = $this->compileContainer('configurable'); $drivers = array( 'configurable_chain_provider' => array( '%doctrine_cache.chain.class%' ), 'configurable_couchbase_provider' => array( '%doctrine_cache.couchbase.class%' ), 'configurable_filesystem_provider' => array( '%doctrine_cache.file_system.class%' ), 'configurable_memcached_provider' => array( '%doctrine_cache.memcached.class%', array('setMemcached' => array()) ), 'configurable_memcache_provider' => array( '%doctrine_cache.memcache.class%', array('setMemcache' => array()) ), 'configurable_mongodb_provider' => array( '%doctrine_cache.mongodb.class%' ), 'configurable_phpfile_provider' => array( '%doctrine_cache.php_file.class%' ), 'configurable_redis_provider' => array( '%doctrine_cache.redis.class%', array('setRedis' => array()) ), 'configurable_riak_provider' => array( '%doctrine_cache.riak.class%' ), 'configurable_sqlite3_provider' => array( '%doctrine_cache.sqlite3.class%' ), ); foreach ($drivers as $id => $value) { $this->assertCacheProvider($container, $id, $value[0]); } } public function testBasicConfigurableDefaultCache() { $container = $this->compileContainer('configurable_defaults'); $drivers = array( 'configurable_memcached_provider' => array( '%doctrine_cache.memcached.class%', array('setMemcached' => array()) ), 'configurable_memcache_provider' => array( '%doctrine_cache.memcache.class%', array('setMemcache' => array()) ), 'configurable_redis_provider' => array( '%doctrine_cache.redis.class%', array('setRedis' => array()) ), 'configurable_mongodb_provider' => array( '%doctrine_cache.mongodb.class%' ), 'configurable_riak_provider' => array( '%doctrine_cache.riak.class%' ), 'configurable_filesystem_provider' => array( '%doctrine_cache.file_system.class%' ), 'configurable_phpfile_provider' => array( '%doctrine_cache.php_file.class%' ), 'configurable_couchbase_provider' => array( '%doctrine_cache.couchbase.class%' ), 'configurable_memcached_provider_type' => array( '%doctrine_cache.memcached.class%', array('setMemcached' => array()) ), 'configurable_memcache_provider_type' => array( '%doctrine_cache.memcache.class%', array('setMemcache' => array()) ), 'configurable_redis_provider_type' => array( '%doctrine_cache.redis.class%', array('setRedis' => array()) ), 'configurable_mongodb_provider_type' => array( '%doctrine_cache.mongodb.class%' ), 'configurable_riak_provider_type' => array( '%doctrine_cache.riak.class%' ), 'configurable_filesystem_provider_type' => array( '%doctrine_cache.file_system.class%' ), 'configurable_phpfile_provider_type' => array( '%doctrine_cache.php_file.class%' ), 'configurable_couchbase_provider_type' => array( '%doctrine_cache.couchbase.class%' ), ); foreach ($drivers as $id => $value) { $this->assertCacheProvider($container, $id, $value[0]); } } public function testBasicNamespaceCache() { $container = $this->compileContainer('namespaced'); $drivers = array( 'doctrine_cache.providers.foo_namespace_provider' => 'foo_namespace', 'doctrine_cache.providers.barNamespaceProvider' => 'barNamespace', ); foreach ($drivers as $key => $value) { $this->assertTrue($container->hasDefinition($key)); $def = $container->getDefinition($key); $calls = $def->getMethodCalls(); $this->assertEquals('setNamespace', $calls[0][0]); $this->assertEquals($value, $calls[0][1][0]); } } public function testAliasesCache() { $container = $this->compileContainer('aliased'); $providers = array( 'doctrine_cache.providers.foo_namespace_provider' => array('fooNamespaceProvider', 'foo'), 'doctrine_cache.providers.barNamespaceProvider' => array('bar_namespace_provider', 'bar'), ); foreach ($providers as $key => $aliases) { $this->assertTrue($container->hasDefinition($key)); foreach ($aliases as $alias) { $this->assertEquals(strtolower($key), (string) $container->getAlias($alias)); } } } public function testServiceParameters() { $container = $this->compileContainer('service_parameter'); $providers = array( 'service_bucket_riak_provider' => array( '%doctrine_cache.riak.class%' ), 'service_connection_riak_provider' => array( '%doctrine_cache.riak.class%' ), 'service_connection_memcached_provider' => array( '%doctrine_cache.memcached.class%' ), 'service_connection_memcache_provider' => array( '%doctrine_cache.memcache.class%' ), 'service_connection_redis_provider' => array( '%doctrine_cache.redis.class%' ), 'service_connection_mongodb_provider' => array( '%doctrine_cache.mongodb.class%' ), 'service_collection_mongodb_provider' => array( '%doctrine_cache.mongodb.class%' ), 'service_connection_sqlite3_provider' => array( '%doctrine_cache.sqlite3.class%' ), ); foreach ($providers as $id => $value) { $this->assertCacheProvider($container, $id, $value[0]); } } public function testCustomCacheProviders() { $container = $this->compileContainer('custom_providers'); $providers = array( 'my_custom_type_provider' => array( 'Doctrine\Bundle\DoctrineCacheBundle\Tests\DependencyInjection\Fixtures\Cache\MyCustomType', array('addConfig' => array( array('config_foo', 'foo'), array('config_bar', 'bar'), )) ), 'my_custom_type_provider2' => array( 'Doctrine\Bundle\DoctrineCacheBundle\Tests\DependencyInjection\Fixtures\Cache\MyCustomType', array() ), ); foreach ($providers as $id => $value) { $this->assertCacheProvider($container, $id, $value[0], $value[1]); } } /** * @expectedException InvalidArgumentException * @expectedExceptionMessage "unrecognized_type" is an unrecognized Doctrine cache driver. */ public function testUnrecognizedCacheDriverException() { $this->compileContainer('unrecognized'); } public function testAcl() { $container = $this->compileContainer('acl'); $this->assertTrue($container->hasDefinition('doctrine_cache.security.acl.cache')); $definition = $container->getDefinition('doctrine_cache.security.acl.cache'); $this->assertEquals('Doctrine\Bundle\DoctrineCacheBundle\Acl\Model\AclCache', $definition->getClass()); $this->assertCount(2, $definition->getArguments()); $this->assertEquals('doctrine_cache.providers.acl_apc_provider', (string) $definition->getArgument(0)); $this->assertEquals('security.acl.permission_granting_strategy', (string) $definition->getArgument(1)); $this->assertFalse($definition->isPublic()); } public function assertCacheProvider(ContainerBuilder $container, $name, $class, array $expectedCalls = array()) { $service = "doctrine_cache.providers." . $name; $this->assertTrue($container->hasDefinition($service)); $definition = $container->getDefinition($service); $this->assertTrue($definition->isPublic()); $this->assertEquals($class, $definition->getClass()); foreach (array_unique($expectedCalls) as $methodName => $params) { $this->assertMethodCall($definition, $methodName, $params); } } public function assertCacheResource(ContainerBuilder $container, $name, $class, array $expectedCalls = array()) { $service = "doctrine_cache.services.$name"; $this->assertTrue($container->hasDefinition($service)); $definition = $container->getDefinition($service); $this->assertTrue($definition->isPublic()); $this->assertEquals($class, $definition->getClass()); foreach ($expectedCalls as $methodName => $params) { $this->assertMethodCall($definition, $methodName, $params); } } private function assertMethodCall(Definition $definition, $methodName, array $parameters = array()) { $methodCalls = $definition->getMethodCalls(); $actualCalls = array(); foreach ($methodCalls as $call) { $actualCalls[$call[0]][] = $call[1]; } $this->assertArrayHasKey($methodName, $actualCalls); $this->assertCount(count($parameters), $actualCalls[$methodName]); foreach ($parameters as $index => $param) { $this->assertArrayHasKey($index, $actualCalls[$methodName]); $this->assertEquals($param, $actualCalls[$methodName][$index]); } } /** * @param string $file * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container * * @return \Symfony\Component\DependencyInjection\ContainerBuilder */ protected function compileContainer($file, ContainerBuilder $container = null) { $container = $container ?: $this->createContainer(); $cacheExtension = new DoctrineCacheExtension(); $container->registerExtension($cacheExtension); $compilerPassConfig = $container->getCompilerPassConfig(); $compilerPassConfig->setOptimizationPasses(array(new ResolveDefinitionTemplatesPass())); $compilerPassConfig->setRemovingPasses(array()); $this->loadFromFile($container, $file); $container->compile(); return $container; } } DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/000077500000000000000000000000001265172632300242035ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/Bundles/000077500000000000000000000000001265172632300255775ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/000077500000000000000000000000001265172632300274715ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/XmlBundle.php000066400000000000000000000007621265172632300321010ustar00rootroot00000000000000 * (c) Doctrine Project, Benjamin Eberlei * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Fixtures\Bundles\YamlBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; class XmlBundle extends Bundle { } DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/Bundles/YamlBundle/000077500000000000000000000000001265172632300276335ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/Bundles/YamlBundle/YamlBundle.php000066400000000000000000000007631265172632300324060ustar00rootroot00000000000000 * (c) Doctrine Project, Benjamin Eberlei * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Fixtures\Bundles\YamlBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; class YamlBundle extends Bundle { } DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/Cache/000077500000000000000000000000001265172632300252065ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/Cache/MyCustomType.php000066400000000000000000000010171265172632300303400ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\DependencyInjection\Fixtures\Cache; use Doctrine\Common\Cache\ArrayCache; class MyCustomType extends ArrayCache { public $configs; public function addConfig($name, $value) { $this->configs[$name] = $value; } } DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/Definition/000077500000000000000000000000001265172632300262735ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/Definition/MyCustomTypeDefinition.php000066400000000000000000000016061265172632300334420ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\DependencyInjection\Fixtures\Definition; use Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\Definition\CacheDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; class MyCustomTypeDefinition extends CacheDefinition { /** * {@inheritDoc} */ public function configure($name, array $config, Definition $service, ContainerBuilder $container) { foreach ($config['custom_provider']['options'] as $name => $value) { $service->addMethodCall('addConfig', array($name, $value)); } } } DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/config/000077500000000000000000000000001265172632300254505ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/config/xml/000077500000000000000000000000001265172632300262505ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/config/xml/acl.xml000066400000000000000000000013041265172632300275270ustar00rootroot00000000000000 DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/config/xml/aliased.xml000066400000000000000000000016031265172632300303740ustar00rootroot00000000000000 foo_namespace_provider fooNamespaceProvider bar_namespace_provider bar DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/config/xml/basic.xml000066400000000000000000000030731265172632300300560ustar00rootroot00000000000000 DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/config/xml/configurable.xml000066400000000000000000000061041265172632300314330ustar00rootroot00000000000000 configurable_array_provider configurable_apc_provider my_database my_collection my_bucket false 1 my_table %kernel.cache_dir%/configurable-filesystem-provider %kernel.cache_dir%/configurable-phpfile-provider my_bucket 127.0.0.1:809 DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/config/xml/configurable_defaults.xml000066400000000000000000000050701265172632300333230ustar00rootroot00000000000000 memcached_provider_type memcache_provider_type redis_provider_type mongodb_provider_type memcached_provider_type filesystem_provider_type phpfile_provider_type couchbase_provider_type DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/config/xml/custom_providers.xml000066400000000000000000000031301265172632300323760ustar00rootroot00000000000000 my_custom_provider_service Doctrine\Bundle\DoctrineCacheBundle\Tests\DependencyInjection\Fixtures\Definition\MyCustomTypeDefinition my_custom_provider_service foo bar foobar DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/config/xml/namespaced.xml000066400000000000000000000013361265172632300310750ustar00rootroot00000000000000 DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/config/xml/service_parameter.xml000066400000000000000000000101021265172632300324640ustar00rootroot00000000000000 localhost 8087 my_service_bucket_name cache.db localhost 11211 localhost 11211 localhost 6379 localhost:27017 my_database my_cache_collection my_bucket_name my_memcache_connection_service my_memcache_connection_service my_database my_cache_collection DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/config/xml/unrecognized.xml000066400000000000000000000011671265172632300314730ustar00rootroot00000000000000 DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/config/yml/000077500000000000000000000000001265172632300262515ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/config/yml/acl.yml000066400000000000000000000002271265172632300275340ustar00rootroot00000000000000doctrine_cache: acl_cache: id: 'doctrine_cache.providers.acl_apc_provider' providers: acl_apc_provider: type: 'apc'DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/config/yml/aliased.yml000066400000000000000000000005151265172632300303770ustar00rootroot00000000000000doctrine_cache: aliases: foo: foo_namespace_provider providers: foo_namespace_provider: type: array aliases: - fooNamespaceProvider barNamespaceProvider: type: array aliases: - bar_namespace_provider - barDoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/config/yml/basic.yml000066400000000000000000000014161265172632300300570ustar00rootroot00000000000000doctrine_cache: providers: basic_apc_provider: type: apc basic_array_provider: type: array basic_void_provider: type: void basic_xcache_provider: type: xcache basic_wincache_provider: type: wincache basic_zenddata_provider: type: zenddata basic_ns_zenddata_provider: type: zenddata namespace: zenddata_ns basic_apc_provider2: apc: ~ basic_array_provider2: array: ~ basic_void_provider2: void: ~ basic_xcache_provider2: xcache: ~ basic_wincache_provider2: wincache: ~ basic_zenddata_provider2: zenddata: ~ DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/config/yml/configurable.yml000066400000000000000000000036171265172632300314430ustar00rootroot00000000000000doctrine_cache: providers: configurable_apc_provider: apc: ~ configurable_array_provider: array: ~ configurable_chain_provider: chain: providers: - configurable_array_provider - configurable_apc_provider configurable_memcached_provider: memcached: servers: memcached01.ss: ~ memcached02.ss: ~ configurable_memcache_provider: memcache: servers: memcache01.ss: ~ memcache02.ss: ~ configurable_redis_provider: redis: host: localhost port: 11211 configurable_couchbase_provider: couchbase: hostnames: [ 127.0.0.1:809 ] bucket_name: my_bucket username: Administrator password: password configurable_phpfile_provider: php_file: extension: phpc directory: "%kernel.cache_dir%/configurable-phpfile-provider" configurable_filesystem_provider: file_system: extension: fsc directory: "%kernel.cache_dir%/configurable-filesystem-provider" configurable_mongodb_provider: mongodb: server: localhost:11211 database_name: my_database collection_name: my_collection configurable_riak_provider: riak: host: localhost port: 8087 bucket_name: my_bucket bucket_property_list: allow_multiple: false n_value: 1 configurable_sqlite3_provider: sqlite3: file_name: cache.db table_name: my_tableDoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/config/yml/configurable_defaults.yml000066400000000000000000000031321265172632300333220ustar00rootroot00000000000000doctrine_cache: providers: configurable_memcached_provider: memcached: ~ configurable_memcache_provider: memcache: ~ configurable_redis_provider: redis: ~ configurable_couchbase_provider: couchbase: ~ configurable_phpfile_provider: php_file: ~ configurable_filesystem_provider: file_system: ~ configurable_mongodb_provider: mongodb: ~ configurable_riak_provider: riak: ~ configurable_memcached_provider_type: type : memcached aliases : - memcached_provider_type configurable_memcache_provider_type: type : memcache aliases : - memcache_provider_type configurable_redis_provider_type: type : redis aliases : - redis_provider_type configurable_couchbase_provider_type: type : couchbase aliases : - couchbase_provider_type configurable_phpfile_provider_type: type : php_file aliases : - php_file_provider_type configurable_filesystem_provider_type: type : file_system aliases : - file_system_provider_type configurable_mongodb_provider_type: type : mongodb aliases : - mongodb_provider_type configurable_riak_provider_type: type : riak aliases : - riak_provider_typeDoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/config/yml/custom_providers.yml000066400000000000000000000013261265172632300324050ustar00rootroot00000000000000services: my_custom_provider_service: class: Doctrine\Bundle\DoctrineCacheBundle\Tests\DependencyInjection\Fixtures\Cache\MyCustomType doctrine_cache: custom_providers: my_custom_type: prototype: "my_custom_provider_service" definition_class: Doctrine\Bundle\DoctrineCacheBundle\Tests\DependencyInjection\Fixtures\Definition\MyCustomTypeDefinition my_custom_type2: prototype: "my_custom_provider_service" providers: my_custom_type_provider: my_custom_type: config_foo: "foo" config_bar: "bar" my_custom_type_provider2: my_custom_type2: config_foobar: "foobar" DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/config/yml/namespaced.yml000066400000000000000000000003251265172632300310740ustar00rootroot00000000000000doctrine_cache: providers: foo_namespace_provider: type: array namespace: foo_namespace barNamespaceProvider: type: array namespace: barNamespaceDoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/config/yml/service_parameter.yml000066400000000000000000000047661265172632300325110ustar00rootroot00000000000000services: my_memcached_connection_service: class: "%doctrine_cache.memcached.connection.class%" calls: - [addServer, ["localhost", 11211]] my_memcache_connection_service: class: "%doctrine_cache.memcache.connection.class%" calls: - [connect, ["localhost", 11211]] my_mongodb_connection_service: class: "%doctrine_cache.mongodb.connection.class%" arguments: ["localhost:27017"] my_mongodb_collection_service: class: "%doctrine_cache.mongodb.collection.class%" arguments: ["my_database", "my_cache_collection"] my_redis_connection_service: class: "%doctrine_cache.redis.connection.class%" calls: - [connect, ["localhost", 6379]] my_riak_connection_service: class: "%doctrine_cache.riak.connection.class%" arguments: ["localhost", 8087] my_riak_bucket_service: class: "%doctrine_cache.riak.bucket.class%" arguments: ["@my_riak_connection_service", "my_service_bucket_name"] my_sqlite3_connection_service: class: "%doctrine_cache.sqlite3.connection.class%" arguments: ["cache.db"] doctrine_cache: providers: service_connection_couchbase_provider: couchbase: connection_id: "my_couchbase_connection_service" service_connection_memcached_provider: memcached: connection_id: "my_memcached_connection_service" service_connection_memcache_provider: memcache: connection_id: "my_memcache_connection_service" service_collection_mongodb_provider: mongodb: collection_id: "my_mongodb_collection_service" service_connection_mongodb_provider: mongodb: connection_id: "my_mongodb_connection_service" collection_name: "my_cache_collection" database_name: "my_database" service_connection_redis_provider: redis: connection_id: "my_redis_connection_service" service_bucket_riak_provider: riak: bucket_id : "my_riak_bucket_service" service_connection_riak_provider: riak: connection_id: "my_riak_connection_service" bucket_name: "my_bucket_name" service_connection_sqlite3_provider: sqlite3: connection_id: "my_sqlite3_connection_service" table_name: 'my_table' DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/Fixtures/config/yml/unrecognized.yml000066400000000000000000000001471265172632300314720ustar00rootroot00000000000000doctrine_cache: providers: unrecognized_cache_provider: type: unrecognized_typeDoctrineCacheBundle-1.3.0/Tests/DependencyInjection/SymfonyBridgeAdapterTest.php000066400000000000000000000130171265172632300300270ustar00rootroot00000000000000. */ namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\DependencyInjection; use Doctrine\Bundle\DoctrineCacheBundle\Tests\TestCase; use Symfony\Component\DependencyInjection\Definition; use Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\SymfonyBridgeAdapter; use Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\CacheProviderLoader; /** * @group Extension * @group SymfonyBridge * * @author Kinn Coelho Julião * @author Fabio B. Silva */ class SymfonyBridgeAdpterTest extends TestCase { /** * @var \Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\SymfonyBridgeAdapter */ private $adapter; protected function setUp() { parent::setUp(); $this->adapter = new SymfonyBridgeAdapter(new CacheProviderLoader(), 'doctrine.orm', 'orm'); } public function providerBasicDrivers() { return array( array('%doctrine_cache.apc.class%', array('type' => 'apc')), array('%doctrine_cache.array.class%', array('type' => 'array')), array('%doctrine_cache.xcache.class%', array('type' => 'xcache')), array('%doctrine_cache.wincache.class%', array('type' => 'wincache')), array('%doctrine_cache.zenddata.class%', array('type' => 'zenddata')), array('%doctrine_cache.redis.class%', array('type' => 'redis'), array('setRedis')), array('%doctrine_cache.memcache.class%', array('type' => 'memcache'), array('setMemcache')), array('%doctrine_cache.memcached.class%', array('type' => 'memcached'), array('setMemcached')), ); } /** * @param string $class * @param array $config * * @dataProvider providerBasicDrivers */ public function testLoadBasicCacheDriver($class, array $config, array $expectedCalls = array()) { $container = $this->createServiceContainer(); $cacheName = 'metadata_cache'; $objectManager = array( 'name' => 'default', 'metadata_cache_driver' => $config ); $this->adapter->loadObjectManagerCacheDriver($objectManager, $container, $cacheName); $this->assertTrue($container->hasAlias('doctrine.orm.default_metadata_cache')); $alias = $container->getAlias('doctrine.orm.default_metadata_cache'); $decorator = $container->getDefinition($alias); $definition = $container->getDefinition($decorator->getParent()); $defCalls = $decorator->getMethodCalls(); $expectedCalls[] = 'setNamespace'; $actualCalls = array_map(function ($call) { return $call[0]; }, $defCalls); $this->assertEquals($class, $definition->getClass()); foreach (array_unique($expectedCalls) as $call) { $this->assertContains($call, $actualCalls); } } public function testServiceCacheDriver() { $cacheName = 'metadata_cache'; $container = $this->createServiceContainer(); $definition = new Definition('%doctrine.orm.cache.apc.class%'); $objectManager = array( 'name' => 'default', 'metadata_cache_driver' => array( 'type' => 'service', 'id' => 'service_driver' ) ); $container->setDefinition('service_driver', $definition); $this->adapter->loadObjectManagerCacheDriver($objectManager, $container, $cacheName); $this->assertTrue($container->hasAlias('doctrine.orm.default_metadata_cache')); } /** * @expectedException InvalidArgumentException * @expectedExceptionMessage "unrecognized_type" is an unrecognized Doctrine cache driver. */ public function testUnrecognizedCacheDriverException() { $cacheName = 'metadata_cache'; $container = $this->createServiceContainer(); $objectManager = array( 'name' => 'default', 'metadata_cache_driver' => array( 'type' => 'unrecognized_type' ) ); $this->adapter->loadObjectManagerCacheDriver($objectManager, $container, $cacheName); } public function testLoadServicesConfiguration() { $container = $this->createContainer(); $this->assertFalse($container->hasParameter('doctrine_cache.array.class')); $this->adapter->loadServicesConfiguration($container); $this->assertTrue($container->hasParameter('doctrine_cache.array.class')); } }DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/XmlDoctrineCacheExtensionTest.php000066400000000000000000000031361265172632300310170ustar00rootroot00000000000000. */ namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\DependencyInjection; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; /** * @group Extension * @group DependencyInjection */ class XmlDoctrineCacheExtensionTest extends AbstractDoctrineCacheExtensionTest { /** * {@inheritdoc} */ protected function loadFromFile(ContainerBuilder $container, $file) { $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/config/xml')); $loader->load($file . '.xml'); } } DoctrineCacheBundle-1.3.0/Tests/DependencyInjection/YmlDoctrineCacheExtensionTest.php000066400000000000000000000031401265172632300310130ustar00rootroot00000000000000. */ namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\DependencyInjection; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; /** * @group Extension * @group DependencyInjection */ class YmlDoctrineCacheExtensionTest extends AbstractDoctrineCacheExtensionTest { /** * {@inheritdoc} */ protected function loadFromFile(ContainerBuilder $container, $file) { $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/config/yml')); $loader->load($file . '.yml'); } } DoctrineCacheBundle-1.3.0/Tests/Functional/000077500000000000000000000000001265172632300205535ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Tests/Functional/ArrayCacheTest.php000066400000000000000000000025671265172632300241400ustar00rootroot00000000000000. */ namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional; /** * @group Functional * @group Array */ class ArrayCacheTest extends BaseCacheTest { /** * {@inheritDoc} */ protected function createCacheDriver() { $container = $this->compileContainer('array'); $cache = $container->get('doctrine_cache.providers.my_array_cache'); return $cache; } } DoctrineCacheBundle-1.3.0/Tests/Functional/BaseCacheTest.php000066400000000000000000000034131265172632300237230ustar00rootroot00000000000000. */ namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional; use Doctrine\Bundle\DoctrineCacheBundle\Tests\FunctionalTestCase; /** * @group Functional */ abstract class BaseCacheTest extends FunctionalTestCase { /** * @return \Doctrine\Common\Cache\Cache */ abstract protected function createCacheDriver(); public function testCacheDriver() { $cache = $this->createCacheDriver(); $this->assertNotNull($cache); $this->assertInstanceOf('Doctrine\Common\Cache\Cache', $cache); $this->assertTrue($cache->save('key', 'value')); $this->assertTrue($cache->contains('key')); $this->assertEquals('value', $cache->fetch('key')); $this->assertTrue($cache->delete('key')); $this->assertFalse($cache->contains('key')); } }DoctrineCacheBundle-1.3.0/Tests/Functional/ChainCacheTest.php000066400000000000000000000032001265172632300240650ustar00rootroot00000000000000. */ namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional; /** * @group Functional * @group Chain */ class ChainCacheTest extends BaseCacheTest { public function setUp() { parent::setUp(); if (!class_exists('Doctrine\Common\Cache\ChainCache')) { $this->markTestSkipped('The ' . __CLASS__ .' requires the use of ChainCache available in doctrine/cache since 1.4'); } } /** * {@inheritDoc} */ protected function createCacheDriver() { $container = $this->compileContainer('chain'); $cache = $container->get('doctrine_cache.providers.my_chain_cache'); return $cache; } } DoctrineCacheBundle-1.3.0/Tests/Functional/Command/000077500000000000000000000000001265172632300221315ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Tests/Functional/Command/CommandTestCase.php000066400000000000000000000043061265172632300256570ustar00rootroot00000000000000container = $this->compileContainer('array'); $this->provider = $this->container->get('doctrine_cache.providers.' . $this->cacheName); $this->kernel = $this->getMockKernel(); $this->app = new Application($this->kernel); } /** * @param \Doctrine\Bundle\DoctrineCacheBundle\Command\CacheCommand $command * * @return \Symfony\Component\Console\Tester\CommandTester */ protected function getTester(CacheCommand $command) { $command->setContainer($this->container); $command->setApplication($this->app); return new CommandTester($command); } /** * Gets Kernel mock instance * * @return \Symfony\Component\HttpKernel\Kernel */ private function getMockKernel() { return $this->getMock('\Symfony\Component\HttpKernel\Kernel', array(), array(), '', false, false); } /** * Gets Filesystem mock instance * * @return \Symfony\Bundle\FrameworkBundle\Util\Filesystem */ private function getMockFilesystem() { return $this->getMock('\Symfony\Bundle\FrameworkBundle\Util\Filesystem', array(), array(), '', false, false); } } DoctrineCacheBundle-1.3.0/Tests/Functional/Command/ContainsCommandTest.php000066400000000000000000000027121265172632300265610ustar00rootroot00000000000000 */ class ContainsCommandTest extends CommandTestCase { /** * @var \Doctrine\Bundle\DoctrineCacheBundle\Command\ContainsCommand */ protected $command; /** * @var \Symfony\Component\Console\Tester\CommandTester */ protected $tester; /** * {@inheritdoc} */ public function setUp() { parent::setUp(); $this->command = new ContainsCommand(); $this->tester = $this->getTester($this->command); } /** * Tests if a cache does not contain an entry. */ public function testContainsFalse() { $this->tester->execute(array( 'cache-name' => $this->cacheName, 'cache-id' => $this->cacheId, )); $this->assertEquals("FALSE\n", $this->tester->getDisplay()); } /** * Tests if a cache contains an entry. */ public function testContainsTrue() { $this->provider->save($this->cacheId, 'hello world'); $this->tester->execute(array( 'cache-name' => $this->cacheName, 'cache-id' => $this->cacheId, )); $this->assertEquals("TRUE\n", $this->tester->getDisplay()); } } DoctrineCacheBundle-1.3.0/Tests/Functional/Command/DeleteCommandTest.php000066400000000000000000000030721265172632300262050ustar00rootroot00000000000000 */ class DeleteCommandTest extends CommandTestCase { /** * @var \Doctrine\Bundle\DoctrineCacheBundle\Command\DeleteCommand */ protected $command; /** * @var \Symfony\Component\Console\Tester\CommandTester */ protected $tester; /** * {@inheritdoc} */ public function setUp() { parent::setUp(); $this->command = new DeleteCommand(); $this->tester = $this->getTester($this->command); } /** * Tests a cache delete success. */ public function testDeleteSuccess() { $this->provider->save($this->cacheId, 'hello world'); $this->tester->execute(array( 'cache-name' => $this->cacheName, 'cache-id' => $this->cacheId, )); $this->assertEquals("Deletion of {$this->cacheId} in {$this->cacheName} has succeeded\n", $this->tester->getDisplay()); } /** * Tests a cache delete all. */ public function testDeleteAll() { $this->tester->execute(array( 'cache-name' => $this->cacheName, 'cache-id' => $this->cacheId, '--all' => true )); $this->assertEquals("Deletion of all entries in {$this->cacheName} has succeeded\n", $this->tester->getDisplay()); } } DoctrineCacheBundle-1.3.0/Tests/Functional/Command/FlushCommandTest.php000066400000000000000000000021201265172632300260550ustar00rootroot00000000000000 */ class FlushCommandTest extends CommandTestCase { /** * @var \Doctrine\Bundle\DoctrineCacheBundle\Command\FlushCommand */ protected $command; /** * @var \Symfony\Component\Console\Tester\CommandTester */ protected $tester; /** * {@inheritdoc} */ public function setUp() { parent::setUp(); $this->command = new FlushCommand(); $this->tester = $this->getTester($this->command); } /** * Tests flushing a cache. */ public function testFlush() { $this->tester->execute(array( 'cache-name' => $this->cacheName, )); $this->assertEquals("Clearing the cache for the {$this->cacheName} provider of type {$this->cacheProviderClass}\n", $this->tester->getDisplay()); } } DoctrineCacheBundle-1.3.0/Tests/Functional/Command/StatsCommandTest.php000066400000000000000000000035521265172632300261040ustar00rootroot00000000000000 */ class StatsCommandTest extends CommandTestCase { /** * @var \Doctrine\Bundle\DoctrineCacheBundle\Command\StatsCommand */ protected $command; /** * @var \Symfony\Component\Console\Tester\CommandTester */ protected $tester; /** * {@inheritdoc} */ public function setUp() { parent::setUp(); $this->command = new StatsCommand(); $this->tester = $this->getTester($this->command); } /** * Tests getting cache provider stats. */ public function testStats() { $this->tester->execute(array( 'cache-name' => $this->cacheName, )); $stats = $this->tester->getDisplay(); if (strpos($stats, 'Stats were not') === false) { // This test is for Doctrine/Cache >= 1.6.0 only $this->assertStringStartsWith( "Stats for the {$this->cacheName} provider of type Doctrine\\Common\\Cache\\ArrayCache:", $stats ); $this->assertContains("[hits] 0\n", $stats); $this->assertContains("[misses] 0\n", $stats); $this->assertRegExp('/\[uptime\] [0-9]{10}' . "\n/", $stats); $this->assertContains("[memory_usage] \n", $stats); $this->assertContains("[memory_available] \n", $stats); } else { // This test is for Doctrine/Cache < 1.6.0 only $this->assertEquals("Stats were not provided for the {$this->cacheName} provider of type Doctrine\\Common\\Cache\\ArrayCache\n", $this->tester->getDisplay()); } } } DoctrineCacheBundle-1.3.0/Tests/Functional/FileSystemCacheTest.php000066400000000000000000000026131265172632300251360ustar00rootroot00000000000000. */ namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional; /** * @group Functional * @group FileSystem */ class FileSystemCacheTest extends BaseCacheTest { /** * {@inheritDoc} */ protected function createCacheDriver() { $container = $this->compileContainer('file_system'); $cache = $container->get('doctrine_cache.providers.my_filesystem_cache'); return $cache; } }DoctrineCacheBundle-1.3.0/Tests/Functional/Fixtures/000077500000000000000000000000001265172632300223645ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Tests/Functional/Fixtures/Memcached.php000066400000000000000000000006521265172632300247460ustar00rootroot00000000000000persistentId = $persistent_id; } public function getPersistentId() { return $this->persistentId; } } DoctrineCacheBundle-1.3.0/Tests/Functional/Fixtures/config/000077500000000000000000000000001265172632300236315ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Tests/Functional/Fixtures/config/array.xml000066400000000000000000000011771265172632300254770ustar00rootroot00000000000000 DoctrineCacheBundle-1.3.0/Tests/Functional/Fixtures/config/chain.xml000066400000000000000000000016231265172632300254370ustar00rootroot00000000000000 my_array_cache my_second_array_cache DoctrineCacheBundle-1.3.0/Tests/Functional/Fixtures/config/file_system.xml000066400000000000000000000014551265172632300267030ustar00rootroot00000000000000 %kernel.cache_dir%/configurable-filesystem-provider DoctrineCacheBundle-1.3.0/Tests/Functional/Fixtures/config/memcache.xml000066400000000000000000000013561265172632300261220ustar00rootroot00000000000000 DoctrineCacheBundle-1.3.0/Tests/Functional/Fixtures/config/memcached.xml000066400000000000000000000014051265172632300262610ustar00rootroot00000000000000 DoctrineCacheBundle-1.3.0/Tests/Functional/Fixtures/config/mongodb.xml000066400000000000000000000015161265172632300260030ustar00rootroot00000000000000 my_database my_collection DoctrineCacheBundle-1.3.0/Tests/Functional/Fixtures/config/php_file.xml000066400000000000000000000014421265172632300261420ustar00rootroot00000000000000 %kernel.cache_dir%/configurable-phpfile-provider DoctrineCacheBundle-1.3.0/Tests/Functional/Fixtures/config/predis.xml000066400000000000000000000016071265172632300256450ustar00rootroot00000000000000 2 10 test_ DoctrineCacheBundle-1.3.0/Tests/Functional/Fixtures/config/riak.xml000066400000000000000000000016571265172632300253120ustar00rootroot00000000000000 my_bucket false 1 DoctrineCacheBundle-1.3.0/Tests/Functional/Fixtures/config/sqlite3.xml000066400000000000000000000013761265172632300257460ustar00rootroot00000000000000 my_table DoctrineCacheBundle-1.3.0/Tests/Functional/Fixtures/config/void.xml000066400000000000000000000011751265172632300253200ustar00rootroot00000000000000 DoctrineCacheBundle-1.3.0/Tests/Functional/MemcacheCacheTest.php000066400000000000000000000034311265172632300245530ustar00rootroot00000000000000. */ namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional; /** * @group Functional * @group Memcache */ class MemcacheCacheTest extends BaseCacheTest { /** * {@inheritDoc} */ protected function setUp() { parent::setUp(); if ( ! extension_loaded('memcache')) { $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache'); } if (@fsockopen('localhost', 11211) === false) { $this->markTestSkipped('The ' . __CLASS__ .' cannot connect to memcache'); } } /** * {@inheritDoc} */ protected function createCacheDriver() { $container = $this->compileContainer('memcache'); $cache = $container->get('doctrine_cache.providers.my_memcache_cache'); return $cache; } }DoctrineCacheBundle-1.3.0/Tests/Functional/MemcachedCacheTest.php000066400000000000000000000043721265172632300247240ustar00rootroot00000000000000. */ namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional; use Symfony\Component\DependencyInjection\ContainerBuilder; /** * @group Functional * @group Memcached */ class MemcachedCacheTest extends BaseCacheTest { public function testPersistentId() { $cache = $this->createCacheDriver(); $this->assertEquals('app', $cache->getMemcached()->getPersistentId()); } /** * {@inheritDoc} */ protected function setUp() { parent::setUp(); if ( ! extension_loaded('memcached')) { $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcached'); } if (@fsockopen('localhost', 11211) === false) { $this->markTestSkipped('The ' . __CLASS__ .' cannot connect to memcached'); } } protected function overrideContainer(ContainerBuilder $container) { $container->setParameter('doctrine_cache.memcached.connection.class', 'Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional\Fixtures\Memcached'); } /** * {@inheritDoc} */ protected function createCacheDriver() { $container = $this->compileContainer('memcached'); $cache = $container->get('doctrine_cache.providers.my_memcached_cache'); return $cache; } }DoctrineCacheBundle-1.3.0/Tests/Functional/MongoDBCacheTest.php000066400000000000000000000034251265172632300243410ustar00rootroot00000000000000. */ namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional; /** * @group Functional * @group MongoDB */ class MongoDBCacheTest extends BaseCacheTest { /** * {@inheritDoc} */ protected function setUp() { parent::setUp(); if ( ! extension_loaded('mongo')) { $this->markTestSkipped('The ' . __CLASS__ .' requires the use of mongo >= 1.3.0'); } if (@fsockopen('localhost', 27017) === false) { $this->markTestSkipped('The ' . __CLASS__ .' cannot connect to mongo'); } } /** * {@inheritDoc} */ protected function createCacheDriver() { $container = $this->compileContainer('mongodb'); $cache = $container->get('doctrine_cache.providers.my_mongodb_cache'); return $cache; } }DoctrineCacheBundle-1.3.0/Tests/Functional/PhpFileCacheTest.php000066400000000000000000000025771265172632300244120ustar00rootroot00000000000000. */ namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional; /** * @group Functional * @group PhpFile */ class PhpFileCacheTest extends BaseCacheTest { /** * {@inheritDoc} */ protected function createCacheDriver() { $container = $this->compileContainer('php_file'); $cache = $container->get('doctrine_cache.providers.my_phpfile_cache'); return $cache; } }DoctrineCacheBundle-1.3.0/Tests/Functional/PredisCacheTest.php000066400000000000000000000033741265172632300243050ustar00rootroot00000000000000. */ namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional; /** * Predis Driver Test * * @group Functional * @group Predis * @author Ivo Bathke */ class PredisCacheTest extends BaseCacheTest { /** * {@inheritDoc} */ protected function setUp() { parent::setUp(); if ( ! class_exists('Doctrine\Common\Cache\PredisCache')) { $this->markTestSkipped('The ' . __CLASS__ .' requires the use of PredisCache available in doctrine/cache since 1.4'); } } /** * {@inheritDoc} */ protected function createCacheDriver() { $container = $this->compileContainer('predis'); $cache = $container->get('doctrine_cache.providers.my_predis_cache'); return $cache; } } DoctrineCacheBundle-1.3.0/Tests/Functional/RiakCacheTest.php000066400000000000000000000033741265172632300237450ustar00rootroot00000000000000. */ namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional; /** * @group Functional * @group Riak */ class RiakCacheTest extends BaseCacheTest { /** * {@inheritDoc} */ protected function setUp() { parent::setUp(); if ( ! extension_loaded('riak')) { $this->markTestSkipped('The ' . __CLASS__ .' requires the use of riak'); } if (@fsockopen('localhost', 8087) === false) { $this->markTestSkipped('The ' . __CLASS__ .' cannot connect to riak'); } } /** * {@inheritDoc} */ protected function createCacheDriver() { $container = $this->compileContainer('riak'); $cache = $container->get('doctrine_cache.providers.my_riak_cache'); return $cache; } }DoctrineCacheBundle-1.3.0/Tests/Functional/Sqlite3CacheTest.php000066400000000000000000000035121265172632300243750ustar00rootroot00000000000000. */ namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional; /** * @group Functional * @group Sqlite3 */ class Sqlite3CacheTest extends BaseCacheTest { /** * {@inheritDoc} */ protected function setUp() { parent::setUp(); if ( ! extension_loaded('sqlite3')) { $this->markTestSkipped('The ' . __CLASS__ .' requires the use of sqlite3'); } if (!class_exists('Doctrine\Common\Cache\SQLite3Cache')) { $this->markTestSkipped('The ' . __CLASS__ .' requires the use of SQLite3Cache available in doctrine/cache since 1.4'); } } /** * {@inheritDoc} */ protected function createCacheDriver() { $container = $this->compileContainer('sqlite3'); $cache = $container->get('doctrine_cache.providers.my_sqlite3_cache'); return $cache; } }DoctrineCacheBundle-1.3.0/Tests/Functional/VoidCacheTest.php000066400000000000000000000041571265172632300237600ustar00rootroot00000000000000. */ namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional; use Doctrine\Bundle\DoctrineCacheBundle\Tests\FunctionalTestCase; /** * @group Functional * @group Void */ class VoidCacheTest extends BaseCacheTest { public function setUp() { parent::setUp(); if (!class_exists('Doctrine\Common\Cache\VoidCache')) { $this->markTestSkipped('The ' . __CLASS__ .' requires the use of VoidCache available in doctrine/cache since 1.5'); } } public function testCacheDriver() { $cache = $this->createCacheDriver(); $this->assertNotNull($cache); $this->assertInstanceOf('Doctrine\Common\Cache\Cache', $cache); $this->assertTrue($cache->save('key', 'value')); $this->assertFalse($cache->contains('key')); $this->assertFalse($cache->fetch('key')); $this->assertTrue($cache->delete('key')); $this->assertFalse($cache->contains('key')); } protected function createCacheDriver() { $container = $this->compileContainer('void'); $cache = $container->get('doctrine_cache.providers.my_void_cache'); return $cache; } } DoctrineCacheBundle-1.3.0/Tests/FunctionalTestCase.php000066400000000000000000000047541265172632300227320ustar00rootroot00000000000000. */ namespace Doctrine\Bundle\DoctrineCacheBundle\Tests; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Doctrine\Bundle\DoctrineCacheBundle\DependencyInjection\DoctrineCacheExtension; class FunctionalTestCase extends TestCase { /** * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container * * @param type $file */ protected function loadFromFile(ContainerBuilder $container, $file) { $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/Functional/Fixtures/config')); $loader->load($file . '.xml'); } /** * @param string $file * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container * * @return \Symfony\Component\DependencyInjection\ContainerBuilder */ protected function compileContainer($file, ContainerBuilder $container = null) { $container = $container ?: $this->createContainer(); $loader = new DoctrineCacheExtension(); $container->registerExtension($loader); $this->loadFromFile($container, $file); $this->overrideContainer($container); $container->compile(); return $container; } /** * Override this hook in your functional TestCase to customize the container * * @param ContainerBuilder $container */ protected function overrideContainer(ContainerBuilder $container) { } } DoctrineCacheBundle-1.3.0/Tests/TestCase.php000066400000000000000000000052571265172632300207060ustar00rootroot00000000000000. */ namespace Doctrine\Bundle\DoctrineCacheBundle\Tests; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; class TestCase extends \PHPUnit_Framework_TestCase { /** * @param array $bundles * @param string $vendor * @return \Symfony\Component\DependencyInjection\ContainerBuilder */ protected function createContainer(array $bundles = array('YamlBundle'), $vendor = null) { $mappings = array(); foreach ($bundles as $bundle) { require_once __DIR__.'/DependencyInjection/Fixtures/Bundles/'.($vendor ? $vendor.'/' : '').$bundle.'/'.$bundle.'.php'; $mappings[$bundle] = 'DependencyInjection\\Fixtures\\Bundles\\'.($vendor ? $vendor.'\\' : '').$bundle.'\\'.$bundle; } return new ContainerBuilder(new ParameterBag(array( 'kernel.debug' => false, 'kernel.bundles' => $mappings, 'kernel.environment' => 'test', 'kernel.root_dir' => __DIR__.'/../', 'kernel.cache_dir' => sys_get_temp_dir(), ))); } /** * @param array $bundles * @param string $vendor * @return \Symfony\Component\DependencyInjection\ContainerBuilder */ protected function createServiceContainer(array $bundles = array('YamlBundle'), $vendor = null) { $container = $this->createContainer($bundles, $vendor); $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.xml'); return $container; } } DoctrineCacheBundle-1.3.0/Tests/bootstrap.php000066400000000000000000000022631265172632300212020ustar00rootroot00000000000000. */ if ( ! @include __DIR__ . '/../vendor/autoload.php') { die("You must set up the project dependencies, run the following commands: wget http://getcomposer.org/composer.phar php composer.phar install --dev "); } DoctrineCacheBundle-1.3.0/Tests/travis/000077500000000000000000000000001265172632300177615ustar00rootroot00000000000000DoctrineCacheBundle-1.3.0/Tests/travis/install-deps.sh000077500000000000000000000002341265172632300227160ustar00rootroot00000000000000#!/usr/bin/env sh BASEDIR=$(dirname $0); if [ "$TRAVIS_PHP_VERSION" = "hhvm" ]; then exit 0; fi pecl install riak phpenv config-add $BASEDIR/php.ini DoctrineCacheBundle-1.3.0/Tests/travis/php.ini000066400000000000000000000001461265172632300212520ustar00rootroot00000000000000extension="mongo.so" extension="memcache.so" extension="memcached.so" apc.enabled=1 apc.enable_cli=1 DoctrineCacheBundle-1.3.0/composer.json000066400000000000000000000045531265172632300201000ustar00rootroot00000000000000{ "name": "doctrine/doctrine-cache-bundle", "homepage": "http://www.doctrine-project.org", "description": "Symfony Bundle for Doctrine Cache", "keywords": ["cache", "caching"], "type": "symfony-bundle", "license": "MIT", "authors": [ { "name": "Fabien Potencier", "email": "fabien@symfony.com" }, { "name": "Benjamin Eberlei", "email": "kontakt@beberlei.de" }, { "name": "Fabio B. Silva", "email": "fabio.bat.silva@gmail.com" }, { "name": "Guilherme Blanco", "email": "guilhermeblanco@hotmail.com" }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" }, { "name": "Doctrine Project", "homepage": "http://www.doctrine-project.org/" } ], "require": { "php": ">=5.3.2", "symfony/doctrine-bridge": "~2.2|~3.0", "doctrine/inflector": "~1.0", "doctrine/cache": "^1.4.2" }, "require-dev": { "phpunit/phpunit": "~4", "symfony/phpunit-bridge": "~2.7|~3.0", "symfony/yaml": "~2.2|~3.0", "symfony/validator": "~2.2|~3.0", "symfony/console": "~2.2|~3.0", "symfony/finder": "~2.2|~3.0", "symfony/framework-bundle": "~2.2|~3.0", "symfony/security-acl": "~2.3|~3.0", "instaclick/coding-standard": "~1.1", "satooshi/php-coveralls": "~0.6.1", "squizlabs/php_codesniffer": "~1.5", "instaclick/object-calisthenics-sniffs": "dev-master", "instaclick/symfony2-coding-standard": "dev-remaster", "predis/predis": "~0.8" }, "suggest": { "symfony/security-acl": "For using this bundle to cache ACLs" }, "autoload": { "psr-4": { "Doctrine\\Bundle\\DoctrineCacheBundle\\": "" } }, "extra": { "branch-alias": { "dev-master": "1.2.x-dev" } } } DoctrineCacheBundle-1.3.0/phpunit.xml.dist000066400000000000000000000017121265172632300205230ustar00rootroot00000000000000 ./Tests benchmark . ./Resources ./vendor ./Tests DoctrineCacheBundle-1.3.0/ruleset.xml000066400000000000000000000005331265172632300175550ustar00rootroot00000000000000 Instaclick Coding Standard */Resources/*