Skip to content

Loading…

[DoctrineBridge] [ORM] Use custom cache namespace option if it is specified #8639

Closed
wants to merge 3 commits into from

3 participants

@Tatsh
Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

This allows an option namespace to be used instead of having Symfony generate the hash. If the option is not set, the original behaviour will occur.

While this code will execute on the current version, this change depends on doctrine/DoctrineBundle#198 to fully work.

@fabpot
Symfony member

This can only be merged if doctrine/DoctrineBundle#198 is ever merged.

@stof
Symfony member

:+1: for this.

@Tatsh you should also send PRs to other doctrine bundles to allow using this feature with them.

@fabpot fabpot added a commit that referenced this pull request
@fabpot fabpot merged branch Tatsh/di-cache-namespace (PR #8639)
This PR was squashed before being merged into the master branch (closes #8639).

Discussion
----------

[DoctrineBridge] [ORM] Use custom cache namespace option if it is specified

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

This allows an option `namespace` to be used instead of having Symfony generate the hash. If the option is not set, the original behaviour will occur.

While this code will execute on the current version, this change depends on doctrine/DoctrineBundle#198 to fully work.

Commits
-------

e6687d9 [DoctrineBridge] [ORM] Use custom cache namespace option if it is specified
3248c1b
@fabpot fabpot added a commit that closed this pull request
@fabpot fabpot merged branch Tatsh/di-cache-namespace (PR #8639)
This PR was squashed before being merged into the master branch (closes #8639).

Discussion
----------

[DoctrineBridge] [ORM] Use custom cache namespace option if it is specified

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

This allows an option `namespace` to be used instead of having Symfony generate the hash. If the option is not set, the original behaviour will occur.

While this code will execute on the current version, this change depends on doctrine/DoctrineBundle#198 to fully work.

Commits
-------

e6687d9 [DoctrineBridge] [ORM] Use custom cache namespace option if it is specified
3248c1b
@fabpot fabpot closed this in 3248c1b
@Tatsh

@stof Would really like to, what other major Doctrine bundles (other than forks) are there that would need this option added?

@stof
Symfony member

DoctrineMongoDBBundle, DoctrinePHPCRBundle and DoctrineCouchDBBundle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 1, 2013
  1. @Tatsh
  2. @Tatsh

    Fix array to access

    Tatsh committed
  3. @Tatsh

    Fix doc block

    Tatsh committed
Showing with 7 additions and 3 deletions.
  1. +7 −3 src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php
View
10 src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php
@@ -362,9 +362,13 @@ protected function loadObjectManagerCacheDriver(array $objectManager, ContainerB
}
$cacheDef->setPublic(false);
- // generate a unique namespace for the given application
- $namespace = 'sf2'.$this->getMappingResourceExtension().'_'.$objectManager['name'].'_'.md5($container->getParameter('kernel.root_dir').$container->getParameter('kernel.environment'));
- $cacheDef->addMethodCall('setNamespace', array($namespace));
+
+ if (!isset($cacheDriver['namespace'])) {
+ // generate a unique namespace for the given application
+ $cacheDriver['namespace'] = 'sf2'.$this->getMappingResourceExtension().'_'.$objectManager['name'].'_'.md5($container->getParameter('kernel.root_dir').$container->getParameter('kernel.environment'));
+ }
+
+ $cacheDef->addMethodCall('setNamespace', array($cacheDriver['namespace']));
$container->setDefinition($cacheDriverService, $cacheDef);
}
Something went wrong with that request. Please try again.