Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

using doctrine abstract extension to load cache driver #13

Open
wants to merge 3 commits into from

3 participants

Bilal Amarni Lukas Kahwe Smith Christophe Coevoet
Bilal Amarni

tests didn't pass without couchdb-odm, so I've added it in the require-dev section of the composer.json file, but then I couldn't install the vendors witouth getting an "assert failed" error, but now it's gone, could someone confirm if this change is ok?

Lukas Kahwe Smith lsmith77 commented on the diff
.gitignore
@@ -1,2 +1,3 @@
+composer.phar
Lukas Kahwe Smith Collaborator

please remove this file

Bilal Amarni
bamarni added a note

Are you sure? It's ignored in other doctrine bundles

Lukas Kahwe Smith Collaborator

i got confused .. never mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Lukas Kahwe Smith lsmith77 commented on the diff
Tests/bootstrap.php
@@ -6,14 +6,3 @@
php composer.phar install
");
}
-
-spl_autoload_register(function($class) {
Lukas Kahwe Smith Collaborator

why are you remove this?

Bilal Amarni
bamarni added a note

stof told me it's not necessary as composer could handle it itself

Lukas Kahwe Smith Collaborator

ah .. might be a new feature.

Christophe Coevoet Collaborator
stof added a note

it is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 10, 2012
  1. Bilal Amarni
  2. Bilal Amarni

    small fixes

    bamarni authored
Commits on May 18, 2012
  1. Bilal Amarni

    added service id

    bamarni authored
This page is out of date. Refresh to see the latest.
1  .gitignore
View
@@ -1,2 +1,3 @@
+composer.phar
Lukas Kahwe Smith Collaborator

please remove this file

Bilal Amarni
bamarni added a note

Are you sure? It's ignored in other doctrine bundles

Lukas Kahwe Smith Collaborator

i got confused .. never mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
composer.lock
vendor
3  DependencyInjection/Configuration.php
View
@@ -234,7 +234,8 @@ private function getOdmCacheDriverNode($name)
->then(function($v) { return array('type' => $v); })
->end()
->children()
- ->scalarNode('type')->defaultValue('array')->isRequired()->end()
+ ->scalarNode('type')->defaultValue('array')->end()
+ ->scalarNode('id')->end()
->scalarNode('host')->end()
->scalarNode('port')->end()
->scalarNode('instance_class')->end()
60 DependencyInjection/DoctrineCouchDBExtension.php
View
@@ -211,7 +211,6 @@ protected function loadOdmDocumentManagerMappingInformation(array $documentManag
}
}
-
$odmConfig->addMethodCall('setDocumentNamespaces', array($this->aliasMap));
}
@@ -223,64 +222,7 @@ protected function loadOdmDocumentManagerMappingInformation(array $documentManag
*/
protected function loadOdmCacheDrivers(array $documentManager, ContainerBuilder $container)
{
- $this->loadOdmDocumentManagerCacheDriver($documentManager, $container, 'metadata_cache');
- }
-
- /**
- * Loads a configured document managers metadata, query or result cache driver.
- *
- * @param array $documentManager A configured ORM document manager.
- * @param ContainerBuilder $container A ContainerBuilder instance
- * @param string $cacheName
- */
- protected function loadOdmDocumentManagerCacheDriver(array $documentManager, ContainerBuilder $container, $cacheName)
- {
- $cacheDriverService = sprintf('doctrine_couchdb.odm.%s_%s', $documentManager['name'], $cacheName);
-
- $driver = $cacheName."_driver";
- $cacheDef = $this->getDocumentManagerCacheDefinition($documentManager, $documentManager[$driver], $container);
- $container->setDefinition($cacheDriverService, $cacheDef);
- }
-
- /**
- * Gets an document manager cache driver definition for caches.
- *
- * @param array $documentManager The array configuring an document manager.
- * @param array $cacheDriver The cache driver configuration.
- * @param ContainerBuilder $container
- * @return Definition $cacheDef
- */
- protected function getDocumentManagerCacheDefinition(array $documentManager, $cacheDriver, ContainerBuilder $container)
- {
- switch ($cacheDriver['type']) {
- case 'memcache':
- $memcacheClass = !empty($cacheDriver['class']) ? $cacheDriver['class'] : '%doctrine_couchdb.odm.cache.memcache.class%';
- $memcacheInstanceClass = !empty($cacheDriver['instance_class']) ? $cacheDriver['instance_class'] : '%doctrine_couchdb.odm.cache.memcache_instance.class%';
- $memcacheHost = !empty($cacheDriver['host']) ? $cacheDriver['host'] : '%doctrine_couchdb.odm.cache.memcache_host%';
- $memcachePort = !empty($cacheDriver['port']) ? $cacheDriver['port'] : '%doctrine_couchdb.odm.cache.memcache_port%';
- $cacheDef = new Definition($memcacheClass);
- $memcacheInstance = new Definition($memcacheInstanceClass);
- $memcacheInstance->addMethodCall('connect', array(
- $memcacheHost, $memcachePort
- ));
- $container->setDefinition(sprintf('doctrine_couchdb.odm.%s_memcache_instance', $documentManager['name']), $memcacheInstance);
- $cacheDef->addMethodCall('setMemcache', array(new Reference(sprintf('doctrine_couchdb.odm.%s_memcache_instance', $documentManager['name']))));
- break;
- case 'apc':
- case 'array':
- case 'xcache':
- $cacheDef = new Definition('%'.sprintf('doctrine_couchdb.odm.cache.%s.class', $cacheDriver['type']).'%');
- break;
- default:
- throw new \InvalidArgumentException(sprintf('"%s" is an unrecognized Doctrine cache driver.', $cacheDriver['type']));
- }
-
- $cacheDef->setPublic(false);
- // generate a unique namespace for the given application
- $namespace = 'sf2couchdb_'.$documentManager['name'].'_'.md5($container->getParameter('kernel.root_dir'));
- $cacheDef->addMethodCall('setNamespace', array($namespace));
-
- return $cacheDef;
+ $this->loadObjectManagerCacheDriver($documentManager, $container, 'metadata_cache');
}
protected function getObjectManagerElementName($name)
1  Tests/ContainerTest.php
View
@@ -47,6 +47,7 @@ public function createYamlBundleTestContainer()
'kernel.debug' => false,
'kernel.bundles' => array('YamlBundle' => 'Fixtures\Bundles\YamlBundle\YamlBundle'),
'kernel.cache_dir' => sys_get_temp_dir(),
+ 'kernel.environment' => 'test',
'kernel.root_dir' => __DIR__ . "/../../../../" // src dir
)));
1  Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
View
@@ -126,6 +126,7 @@ protected function getContainer($bundles = 'YamlBundle', $vendor = null)
'kernel.debug' => false,
'kernel.bundles' => $map,
'kernel.cache_dir' => sys_get_temp_dir(),
+ 'kernel.environment' => 'test',
'kernel.root_dir' => __DIR__ . "/../../../../../" // src dir
)));
}
11 Tests/bootstrap.php
View
@@ -6,14 +6,3 @@
php composer.phar install
");
}
-
-spl_autoload_register(function($class) {
Lukas Kahwe Smith Collaborator

why are you remove this?

Bilal Amarni
bamarni added a note

stof told me it's not necessary as composer could handle it itself

Lukas Kahwe Smith Collaborator

ah .. might be a new feature.

Christophe Coevoet Collaborator
stof added a note

it is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
- if (0 === strpos($class, 'Doctrine\\Bundle\\CouchDBBundle')) {
- $path = __DIR__.'/../'.implode('/', array_slice(explode('\\', $class), 3)).'.php';
- if (!stream_resolve_include_path($path)) {
- return false;
- }
- require_once $path;
- return true;
- }
-});
3  composer.json
View
@@ -14,6 +14,9 @@
"doctrine/couchdb": "*",
"symfony/symfony": "2.1.*"
},
+ "require-dev": {
+ "doctrine/couchdb-odm": "*"
+ },
"suggest": {
"doctrine/couchdb-odm": "*"
},
Something went wrong with that request. Please try again.