Skip to content
This repository was archived by the owner on Feb 5, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
composer.phar

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i got confused .. never mind.

composer.lock
vendor
3 changes: 2 additions & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
60 changes: 1 addition & 59 deletions DependencyInjection/DoctrineCouchDBExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ protected function loadOdmDocumentManagerMappingInformation(array $documentManag
}
}


$odmConfig->addMethodCall('setDocumentNamespaces', array($this->aliasMap));
}

Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions Tests/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)));
}
Expand Down
11 changes: 0 additions & 11 deletions Tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,3 @@
php composer.phar install
");
}

spl_autoload_register(function($class) {
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 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"doctrine/couchdb": "*",
"symfony/symfony": "2.1.*"
},
"require-dev": {
"doctrine/couchdb-odm": "*"
},
"suggest": {
"doctrine/couchdb-odm": "*"
},
Expand Down