Skip to content

Commit

Permalink
[DoctrineBundle] Remove the CreateProxyDirectoryPass and let the cach…
Browse files Browse the repository at this point in the history
…e directory generation be done by the cache warmer.
  • Loading branch information
beberlei authored and fabpot committed Jan 26, 2011
1 parent 8cfa246 commit 18c611a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 31 deletions.
Expand Up @@ -49,6 +49,15 @@ public function isOptional()

public function warmUp($cacheDir)
{
$proxyCacheDir = $this->container->getParameter('doctrine.orm.proxy_dir');
if (!file_exists($proxyCacheDir)) {
if (false === @mkdir($proxyCacheDir, 0777, true)) {
throw new \RuntimeException(sprintf('Unable to create the Doctrine Proxy directory (%s)', dirname($proxyCacheDir)));
}
} else if (!is_writable($proxyCacheDir)) {
throw new \RuntimeException(sprintf('Doctrine Proxy directory (%s) is not writeable for the current system user.', $proxyCacheDir));
}

$entityManagers = $this->container->getParameter('doctrine.orm.entity_managers');
foreach ($entityManagers AS $entityManagerName) {
$em = $this->container->get(sprintf('doctrine.orm.%s_entity_manager', $entityManagerName));
Expand Down

This file was deleted.

Expand Up @@ -20,6 +20,8 @@ class ProxyCacheWarmerTest extends \Symfony\Bundle\DoctrineBundle\Tests\TestCase
* because there are none in the AnnotationsBundle. However that is
* rather a task of doctrine to test. We touch the lines here and
* verify that the container is called correctly for the relevant information.
*
* @group DoctrineORMProxy
*/
public function testWarmCache()
{
Expand All @@ -28,14 +30,18 @@ public function testWarmCache()
);
$container = $this->getMock('Symfony\Component\DependencyInjection\Container');
$container->expects($this->at(0))
->method('getParameter')
->with($this->equalTo('doctrine.orm.proxy_dir'))
->will($this->returnValue(sys_get_temp_dir()));
$container->expects($this->at(1))
->method('getParameter')
->with($this->equalTo('doctrine.orm.entity_managers'))
->will($this->returnValue(array('default', 'foo')));
$container->expects($this->at(1))
$container->expects($this->at(2))
->method('get')
->with($this->equalTo('doctrine.orm.default_entity_manager'))
->will($this->returnValue($testManager));
$container->expects($this->at(2))
$container->expects($this->at(3))
->method('get')
->with($this->equalTo('doctrine.orm.foo_entity_manager'))
->will($this->returnValue($testManager));
Expand Down

0 comments on commit 18c611a

Please sign in to comment.