Upgraded to Symfony 2.1-beta2
This commit is contained in:
@@ -27,6 +27,9 @@ use Doctrine\DBAL\DriverManager;
|
||||
*/
|
||||
class CreateDatabaseDoctrineCommand extends DoctrineCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
@@ -47,6 +50,9 @@ EOT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$connection = $this->getDoctrineConnection($input->getOption('connection'));
|
||||
|
@@ -24,6 +24,11 @@ use Doctrine\ORM\Tools\EntityGenerator;
|
||||
*/
|
||||
abstract class DoctrineCommand extends ContainerAwareCommand
|
||||
{
|
||||
/**
|
||||
* get a doctrine entity generator
|
||||
*
|
||||
* @return EntityGenerator
|
||||
*/
|
||||
protected function getEntityGenerator()
|
||||
{
|
||||
$entityGenerator = new EntityGenerator();
|
||||
@@ -37,6 +42,12 @@ abstract class DoctrineCommand extends ContainerAwareCommand
|
||||
return $entityGenerator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a doctrine entity manager by symfony name.
|
||||
*
|
||||
* @param string $name
|
||||
* @return \Doctrine\ORM\EntityManager
|
||||
*/
|
||||
protected function getEntityManager($name)
|
||||
{
|
||||
return $this->getContainer()->get('doctrine')->getManager($name);
|
||||
@@ -46,7 +57,7 @@ abstract class DoctrineCommand extends ContainerAwareCommand
|
||||
* Get a doctrine dbal connection by symfony name.
|
||||
*
|
||||
* @param string $name
|
||||
* @return Doctrine\DBAL\Connection
|
||||
* @return \Doctrine\DBAL\Connection
|
||||
*/
|
||||
protected function getDoctrineConnection($name)
|
||||
{
|
||||
|
@@ -26,6 +26,9 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
*/
|
||||
class DropDatabaseDoctrineCommand extends DoctrineCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
@@ -52,6 +55,9 @@ EOT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$connection = $this->getDoctrineConnection($input->getOption('connection'));
|
||||
|
@@ -29,6 +29,9 @@ use Doctrine\Bundle\DoctrineBundle\Mapping\DisconnectedMetadataFactory;
|
||||
*/
|
||||
class GenerateEntitiesDoctrineCommand extends DoctrineCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
@@ -79,6 +82,9 @@ EOT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$manager = new DisconnectedMetadataFactory($this->getContainer()->get('doctrine'));
|
||||
|
@@ -31,6 +31,9 @@ use Doctrine\ORM\Tools\Console\MetadataFilter;
|
||||
*/
|
||||
class ImportMappingDoctrineCommand extends DoctrineCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
@@ -65,6 +68,9 @@ EOT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$bundle = $this->getApplication()->getKernel()->getBundle($input->getArgument('bundle'));
|
||||
|
@@ -27,6 +27,9 @@ use Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand;
|
||||
*/
|
||||
class ClearMetadataCacheDoctrineCommand extends MetadataCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
@@ -49,6 +52,9 @@ EOT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
|
@@ -27,6 +27,9 @@ use Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand;
|
||||
*/
|
||||
class ClearQueryCacheDoctrineCommand extends QueryCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
@@ -49,6 +52,9 @@ EOT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
|
@@ -27,6 +27,9 @@ use Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand;
|
||||
*/
|
||||
class ClearResultCacheDoctrineCommand extends ResultCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
@@ -45,25 +48,13 @@ You can also optionally specify the <comment>--em</comment> option to specify
|
||||
which entity manager to clear the cache for:
|
||||
|
||||
<info>php app/console doctrine:cache:clear-result --em=default</info>
|
||||
|
||||
If you don't want to clear all result cache you can specify some additional
|
||||
options to control what cache is deleted:
|
||||
|
||||
<info>php app/console doctrine:cache:clear-result --id=cache_key</info>
|
||||
|
||||
Or you can specify a <comment>--regex</comment> to delete cache entries that
|
||||
match it:
|
||||
|
||||
<info>php app/console doctrine:cache:clear-result --regex="user_(.*)"</info>
|
||||
|
||||
You can also specify a <comment>--prefix</comment> or
|
||||
<comment>--suffix</comment> to delete cache entries for:
|
||||
|
||||
<info>php app/console doctrine:cache:clear-result --prefix="user_" --suffix="_frontend"</info>
|
||||
EOT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
|
@@ -31,6 +31,9 @@ use Doctrine\ORM\Tools\Export\Driver\YamlExporter;
|
||||
*/
|
||||
class ConvertMappingDoctrineCommand extends ConvertMappingCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
@@ -46,6 +49,9 @@ EOT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
@@ -53,9 +59,15 @@ EOT
|
||||
return parent::execute($input, $output);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $toType
|
||||
* @param string $destPath
|
||||
*
|
||||
* @return \Doctrine\ORM\Tools\Export\Driver\AbstractExporter
|
||||
*/
|
||||
protected function getExporter($toType, $destPath)
|
||||
{
|
||||
/** @var $exporter \Doctrine\ORM\Tools\Export\Driver\AbstractExporter */
|
||||
$exporter = parent::getExporter($toType, $destPath);
|
||||
if ($exporter instanceof XmlExporter) {
|
||||
$exporter->setExtension('.orm.xml');
|
||||
|
@@ -29,6 +29,9 @@ use Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand;
|
||||
*/
|
||||
class CreateSchemaDoctrineCommand extends CreateCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
@@ -54,6 +57,9 @@ EOT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
|
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
|
||||
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper;
|
||||
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
|
||||
|
||||
@@ -33,12 +33,19 @@ abstract class DoctrineCommandHelper
|
||||
*/
|
||||
static public function setApplicationEntityManager(Application $application, $emName)
|
||||
{
|
||||
/** @var $em \Doctrine\ORM\EntityManager */
|
||||
$em = $application->getKernel()->getContainer()->get('doctrine')->getManager($emName);
|
||||
$helperSet = $application->getHelperSet();
|
||||
$helperSet->set(new ConnectionHelper($em->getConnection()), 'db');
|
||||
$helperSet->set(new EntityManagerHelper($em), 'em');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to push the helper sets of a given connection into the application.
|
||||
*
|
||||
* @param Application $application
|
||||
* @param string $connName
|
||||
*/
|
||||
static public function setApplicationConnection(Application $application, $connName)
|
||||
{
|
||||
$connection = $application->getKernel()->getContainer()->get('doctrine')->getConnection($connName);
|
||||
|
@@ -28,6 +28,9 @@ use Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand;
|
||||
*/
|
||||
class DropSchemaDoctrineCommand extends DropCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
@@ -54,6 +57,9 @@ EOT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
|
@@ -28,6 +28,9 @@ use Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand;
|
||||
*/
|
||||
class EnsureProductionSettingsDoctrineCommand extends EnsureProductionSettingsCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
@@ -49,6 +52,9 @@ EOT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
|
@@ -27,6 +27,9 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
*/
|
||||
class InfoDoctrineCommand extends InfoCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
@@ -48,6 +51,9 @@ EOT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
|
@@ -28,6 +28,9 @@ use Doctrine\ORM\Tools\Console\Command\RunDqlCommand;
|
||||
*/
|
||||
class RunDqlDoctrineCommand extends RunDqlCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
@@ -54,6 +57,9 @@ EOT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
|
@@ -28,6 +28,9 @@ use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand;
|
||||
*/
|
||||
class RunSqlDoctrineCommand extends RunSqlCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
@@ -44,6 +47,9 @@ EOT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationConnection($this->getApplication(), $input->getOption('connection'));
|
||||
|
@@ -29,6 +29,9 @@ use Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand;
|
||||
*/
|
||||
class UpdateSchemaDoctrineCommand extends UpdateCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
@@ -58,6 +61,9 @@ EOT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
|
@@ -28,6 +28,9 @@ use Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand as DoctrineValidate
|
||||
*/
|
||||
class ValidateSchemaCommand extends DoctrineValidateSchemaCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
@@ -50,6 +53,9 @@ EOT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
|
@@ -69,6 +69,9 @@ class ConnectionFactory
|
||||
return $connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* initialize the types
|
||||
*/
|
||||
private function initializeTypes()
|
||||
{
|
||||
foreach ($this->typesConfig as $type => $typeConfig) {
|
||||
|
@@ -35,6 +35,7 @@ class ProfilerController extends ContainerAware
|
||||
*/
|
||||
public function explainAction($token, $connectionName, $query)
|
||||
{
|
||||
/** @var $profiler \Symfony\Component\HttpKernel\Profiler\Profiler */
|
||||
$profiler = $this->container->get('profiler');
|
||||
$profiler->disable();
|
||||
|
||||
|
@@ -41,9 +41,7 @@ class Configuration implements ConfigurationInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the configuration tree builder.
|
||||
*
|
||||
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
@@ -56,6 +54,11 @@ class Configuration implements ConfigurationInterface
|
||||
return $treeBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add DBAL section to configuration tree
|
||||
*
|
||||
* @param ArrayNodeDefinition $node
|
||||
*/
|
||||
private function addDbalSection(ArrayNodeDefinition $node)
|
||||
{
|
||||
$node
|
||||
@@ -105,6 +108,11 @@ class Configuration implements ConfigurationInterface
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the dbal connections node
|
||||
*
|
||||
* @return ArrayNodeDefinition
|
||||
*/
|
||||
private function getDbalConnectionsNode()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder();
|
||||
@@ -157,7 +165,7 @@ class Configuration implements ConfigurationInterface
|
||||
*
|
||||
* These keys are available for slave configurations too.
|
||||
*
|
||||
* @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $node
|
||||
* @param ArrayNodeDefinition $node
|
||||
*/
|
||||
private function configureDbalDriverNode(ArrayNodeDefinition $node)
|
||||
{
|
||||
@@ -202,6 +210,11 @@ class Configuration implements ConfigurationInterface
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the ORM section to configuration tree
|
||||
*
|
||||
* @param ArrayNodeDefinition $node
|
||||
*/
|
||||
private function addOrmSection(ArrayNodeDefinition $node)
|
||||
{
|
||||
$node
|
||||
@@ -246,6 +259,11 @@ class Configuration implements ConfigurationInterface
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return ORM target entity resolver node
|
||||
*
|
||||
* @return \Symfony\Component\Config\Definition\Builder\NodeDefinition
|
||||
*/
|
||||
private function getOrmTargetEntityResolverNode()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder();
|
||||
@@ -261,6 +279,11 @@ class Configuration implements ConfigurationInterface
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return ORM entity manager node
|
||||
*
|
||||
* @return ArrayNodeDefinition
|
||||
*/
|
||||
private function getOrmEntityManagersNode()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder();
|
||||
@@ -362,6 +385,13 @@ class Configuration implements ConfigurationInterface
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a ORM cache driver node for an given entity manager
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return ArrayNodeDefinition
|
||||
*/
|
||||
private function getOrmCacheDriverNode($name)
|
||||
{
|
||||
$treeBuilder = new TreeBuilder();
|
||||
|
@@ -32,6 +32,9 @@ use Symfony\Component\Config\FileLocator;
|
||||
*/
|
||||
class DoctrineExtension extends AbstractDoctrineExtension
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$configuration = $this->getConfiguration($configs, $container);
|
||||
@@ -377,6 +380,9 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
||||
$ormConfigDef->addMethodCall('setEntityNamespaces', array($this->aliasMap));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function getObjectManagerElementName($name)
|
||||
{
|
||||
return 'doctrine.orm.'.$name;
|
||||
@@ -387,11 +393,17 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
||||
return 'Entity';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function getMappingResourceConfigDirectory()
|
||||
{
|
||||
return 'Resources/config/doctrine';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function getMappingResourceExtension()
|
||||
{
|
||||
return 'orm';
|
||||
@@ -411,9 +423,7 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base path for the XSD files.
|
||||
*
|
||||
* @return string The XSD base path
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getXsdValidationBasePath()
|
||||
{
|
||||
@@ -421,15 +431,16 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the namespace to be used for this extension (XML namespace).
|
||||
*
|
||||
* @return string The XML namespace
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getNamespace()
|
||||
{
|
||||
return 'http://symfony.com/schema/dic/doctrine';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getConfiguration(array $config, ContainerBuilder $container)
|
||||
{
|
||||
return new Configuration($container->getParameter('kernel.debug'));
|
||||
|
@@ -36,6 +36,9 @@ class DoctrineBundle extends Bundle
|
||||
{
|
||||
private $autoloader;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function build(ContainerBuilder $container)
|
||||
{
|
||||
parent::build($container);
|
||||
@@ -48,6 +51,9 @@ class DoctrineBundle extends Bundle
|
||||
$container->addCompilerPass(new DoctrineValidationPass('orm'));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
// Register an autoloader for proxies to avoid issues when unserializing them
|
||||
@@ -66,9 +72,11 @@ class DoctrineBundle extends Bundle
|
||||
|
||||
if (!is_file($file) && $container->getParameter('kernel.debug')) {
|
||||
$originalClassName = ClassUtils::getRealClass($class);
|
||||
/** @var $registry Registry */
|
||||
$registry = $container->get('doctrine');
|
||||
|
||||
// Tries to auto-generate the proxy file
|
||||
/** @var $em \Doctrine\ORM\EntityManager */
|
||||
foreach ($registry->getManagers() as $em) {
|
||||
|
||||
if ($em->getConfiguration()->getAutoGenerateProxyClasses()) {
|
||||
@@ -94,6 +102,9 @@ class DoctrineBundle extends Bundle
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function shutdown()
|
||||
{
|
||||
if (null !== $this->autoloader) {
|
||||
@@ -102,6 +113,9 @@ class DoctrineBundle extends Bundle
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function registerCommands(Application $application)
|
||||
{
|
||||
// Use the default logic when the ORM is available.
|
||||
|
@@ -45,6 +45,13 @@ class ManagerConfigurator
|
||||
$this->enableFilters($entityManager);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable filters for an given entity manager
|
||||
*
|
||||
* @param EntityManager $entityManager
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
private function enableFilters(EntityManager $entityManager)
|
||||
{
|
||||
if (empty($this->enabledFilters)) {
|
||||
|
@@ -23,31 +23,51 @@ class ClassMetadataCollection
|
||||
private $namespace;
|
||||
private $metadata;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $metadata
|
||||
*/
|
||||
public function __construct(array $metadata)
|
||||
{
|
||||
$this->metadata = $metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getMetadata()
|
||||
{
|
||||
return $this->metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*/
|
||||
public function setPath($path)
|
||||
{
|
||||
$this->path = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $namespace
|
||||
*/
|
||||
public function setNamespace($namespace)
|
||||
{
|
||||
$this->namespace = $namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNamespace()
|
||||
{
|
||||
return $this->namespace;
|
||||
|
@@ -19,6 +19,9 @@ namespace Doctrine\Bundle\DoctrineBundle\Mapping;
|
||||
*/
|
||||
class DisconnectedMetadataFactory extends MetadataFactory
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getClassMetadataFactoryClass()
|
||||
{
|
||||
return 'Doctrine\\ORM\\Tools\\DisconnectedClassMetadataFactory';
|
||||
|
@@ -44,6 +44,7 @@ class MetadataFactory
|
||||
* @param BundleInterface $bundle A BundleInterface instance
|
||||
*
|
||||
* @return ClassMetadataCollection A ClassMetadataCollection instance
|
||||
* @throws \RuntimeException When bundle does not contain mapped entities
|
||||
*/
|
||||
public function getBundleMetadata(BundleInterface $bundle)
|
||||
{
|
||||
@@ -68,6 +69,7 @@ class MetadataFactory
|
||||
* @param string $path The path where the class is stored (if known)
|
||||
*
|
||||
* @return ClassMetadataCollection A ClassMetadataCollection instance
|
||||
* @throws MappingException When class is not valid entity or mapped superclass
|
||||
*/
|
||||
public function getClassMetadata($class, $path = null)
|
||||
{
|
||||
@@ -88,6 +90,7 @@ class MetadataFactory
|
||||
* @param string $path The path where the class is stored (if known)
|
||||
*
|
||||
* @return ClassMetadataCollection A ClassMetadataCollection instance
|
||||
* @throws \RuntimeException When namespace not contain mapped entities
|
||||
*/
|
||||
public function getNamespaceMetadata($namespace, $path = null)
|
||||
{
|
||||
@@ -105,8 +108,9 @@ class MetadataFactory
|
||||
* Find and configure path and namespace for the metadata collection.
|
||||
*
|
||||
* @param ClassMetadataCollection $metadata
|
||||
* @param string|null $path
|
||||
* @return void
|
||||
* @param string|null $path
|
||||
*
|
||||
* @throws \RuntimeException When unable to determine the path
|
||||
*/
|
||||
public function findNamespaceAndPathForMetadata(ClassMetadataCollection $metadata, $path = null)
|
||||
{
|
||||
@@ -122,11 +126,21 @@ class MetadataFactory
|
||||
$metadata->setNamespace(isset($r) ? $r->getNamespaceName() : $all[0]->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a base path for a class
|
||||
*
|
||||
* @param string $name class name
|
||||
* @param string $namespace class namespace
|
||||
* @param string $path class path
|
||||
*
|
||||
* @return string
|
||||
* @throws \RuntimeException When base path not found
|
||||
*/
|
||||
private function getBasePathForClass($name, $namespace, $path)
|
||||
{
|
||||
$namespace = str_replace('\\', '/', $namespace);
|
||||
$search = str_replace('\\', '/', $path);
|
||||
$destination = str_replace('/'.$namespace, '', $search, $c);
|
||||
$destination = str_replace('/' . $namespace, '', $search, $c);
|
||||
|
||||
if ($c != 1) {
|
||||
throw new \RuntimeException(sprintf('Can\'t find base path for "%s" (path: "%s", destination: "%s").', $name, $path, $destination));
|
||||
@@ -135,6 +149,11 @@ class MetadataFactory
|
||||
return $destination;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $namespace
|
||||
*
|
||||
* @return ClassMetadataCollection
|
||||
*/
|
||||
private function getMetadataForNamespace($namespace)
|
||||
{
|
||||
$metadata = array();
|
||||
@@ -147,6 +166,11 @@ class MetadataFactory
|
||||
return new ClassMetadataCollection($metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $entity
|
||||
*
|
||||
* @return ClassMetadataCollection
|
||||
*/
|
||||
private function getMetadataForClass($entity)
|
||||
{
|
||||
foreach ($this->getAllMetadata() as $metadata) {
|
||||
@@ -158,11 +182,15 @@ class MetadataFactory
|
||||
return new ClassMetadataCollection(array());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function getAllMetadata()
|
||||
{
|
||||
$metadata = array();
|
||||
foreach ($this->registry->getManagers() as $em) {
|
||||
$class = $this->getClassMetadataFactoryClass();
|
||||
/** @var $cmf \Doctrine\ORM\Mapping\ClassMetadataFactory */
|
||||
$cmf = new $class();
|
||||
$cmf->setEntityManager($em);
|
||||
foreach ($cmf->getAllMetadata() as $m) {
|
||||
@@ -173,6 +201,9 @@ class MetadataFactory
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getClassMetadataFactoryClass()
|
||||
{
|
||||
return 'Doctrine\\ORM\\Mapping\\ClassMetadataFactory';
|
||||
|
@@ -27,6 +27,15 @@ use Doctrine\ORM\EntityManager;
|
||||
*/
|
||||
class Registry extends ManagerRegistry implements RegistryInterface
|
||||
{
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param ContainerInterface $container
|
||||
* @param array $connections
|
||||
* @param array $entityManagers
|
||||
* @param string $defaultConnection
|
||||
* @param string $defaultEntityManager
|
||||
*/
|
||||
public function __construct(ContainerInterface $container, array $connections, array $entityManagers, $defaultConnection, $defaultEntityManager)
|
||||
{
|
||||
$this->setContainer($container);
|
||||
|
@@ -150,7 +150,7 @@ certain classes, but those are for very advanced use-cases only.
|
||||
Caching Drivers
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
For the caching drivers you can specify the values "array", "apc", "memcache"
|
||||
For the caching drivers you can specify the values "array", "apc", "memcache", "memcached"
|
||||
or "xcache".
|
||||
|
||||
The following example shows an overview of the caching configurations:
|
||||
|
@@ -37,6 +37,7 @@
|
||||
"psr-0": { "Doctrine\\Bundle\\DoctrineBundle": "" }
|
||||
},
|
||||
"target-dir": "Doctrine/Bundle/DoctrineBundle",
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
|
Reference in New Issue
Block a user