This repository has been archived by the owner on Feb 5, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,55 @@ | |||
<?php | |||
|
|||
namespace Doctrine\Bundle\CouchDBBundle\CacheWarmer; | |||
|
|||
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; | |||
use Symfony\Component\DependencyInjection\ContainerInterface; | |||
|
|||
class ProxyCacheWarmer implements CacheWarmerInterface | |||
{ | |||
private $container; | |||
|
|||
/** | |||
* Constructor. | |||
* | |||
* @param ContainerInterface $container | |||
*/ | |||
public function __construct(ContainerInterface $container) | |||
{ | |||
$this->container = $container; | |||
} | |||
|
|||
/** | |||
* This cache warmer is not optional, without proxies fatal error occurs! | |||
* | |||
* @return false | |||
*/ | |||
public function isOptional() | |||
{ | |||
return false; | |||
} | |||
|
|||
public function warmUp($cacheDir) | |||
{ | |||
foreach ($this->container->getParameter('doctrine_couchdb.document_managers') as $dmName) { | |||
$dm = $this->container->get($dmName); | |||
|
|||
// we need the directory no matter the proxy cache generation strategy | |||
if (!file_exists($proxyCacheDir = $dm->getConfiguration()->getProxyDir())) { | |||
if (false === @mkdir($proxyCacheDir, 0777, true)) { | |||
throw new \RuntimeException(sprintf('Unable to create the Doctrine CouchDB Proxy directory "%s".', dirname($proxyCacheDir))); | |||
} | |||
} elseif (!is_writable($proxyCacheDir)) { | |||
throw new \RuntimeException(sprintf('The Doctrine CouchDB Proxy directory "%s" is not writeable for the current system user.', $proxyCacheDir)); | |||
} | |||
|
|||
// if proxies are autogenerated we don't need to generate them in the cache warmer | |||
/*if ($dm->getConfiguration()->getAutoGenerateProxyClasses()) { | |||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
beberlei
Author
Member
|
|||
continue; | |||
} | |||
$classes = $dm->getMetadataFactory()->getAllMetadata(); | |||
$dm->getProxyFactory()->generateProxyClasses($classes);*/ | |||
} | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Why is it commented ?