/**
  * {@inheritDoc}
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     if ($input->getOption('em')) {
         CommandHelper::setApplicationEntityManager($this->getHelper('container'), $input->getOption('em'));
     }
     $this->cacheCleaner->invalidate();
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $registry = $this->container->getDoctrine();
     $em = $registry->getManager($input->getOption('em'));
     $con = $registry->getConnection($input->getOption('con'));
     $helperSet = $this->getApplication()->getHelperSet();
     $helperSet->set(new EntityManagerHelper($em), 'em');
     parent::execute($input, $output);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->get('entity_manager');
     $helperSet = new HelperSet();
     $helperSet->set(new ConnectionHelper($em->getConnection()), 'db');
     $helperSet->set(new EntityManagerHelper($em), 'em');
     $command = new GenerateProxiesCommand();
     $command->setHelperSet($helperSet);
     $arguments = array();
     if ($input->getOption('filter')) {
         $arguments['--filter'] = $input->getOption('filter');
     }
     if ($input->getArgument('dest-path')) {
         $arguments['dest-path'] = $input->getArgument('dest-path');
     }
     $returnCode = $command->run(new ArrayInput($arguments), $output);
     return $returnCode;
 }
Пример #4
0
 /**
  * @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');
     } elseif ($exporter instanceof YamlExporter) {
         $exporter->setExtension('.orm.yml');
     }
     return $exporter;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     DoctrineCommand::setApplicationEntityManager($this->application, $input->getOption('em'));
     return parent::execute($input, $output);
 }
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     Debugger::$productionMode = !$input->getOption('debug-mode');
     $this->cacheCleaner->invalidate();
 }
Пример #7
0
 protected function configure()
 {
     parent::configure();
     $this->setName('generate-proxies');
 }
Пример #8
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     parent::execute($input, $output);
 }
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->cacheCleaner->invalidate();
 }
 /**
  * Registers services on the given app.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param Application $app An Application instance
  */
 public function register(Application $app)
 {
     $app['orm.default.parameters'] = array('orm.cache.dir' => __DIR__ . '/../../../../../cache/orm', 'orm.entity.path' => array(), 'orm.proxy.dir' => __DIR__ . '/../../../../../cache/proxies', 'orm.proxy.namespace' => 'Doctrine\\ORM\\Proxies');
     foreach ($app['orm.default.parameters'] as $key => $value) {
         if (!isset($app[$key])) {
             $app[$key] = $value;
         }
     }
     /**
      * @param  Application $app
      *
      * @return \Doctrine\Common\Cache\Cache
      */
     $app['orm.cache.driver'] = function (Application $app) {
         if (extension_loaded('apc')) {
             return new ApcCache();
         } else {
             return new FilesystemCache($app['orm.cache.dir']);
         }
     };
     /**
      * @param  Application $app
      *
      * @return \Doctrine\ORM\Configuration
      */
     $app['orm.config'] = $app->share(function (Application $app) {
         $config = new Configuration();
         $config->setMetadataCacheImpl($app['orm.cache.driver']);
         $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver($app['orm.entity.path']));
         $config->setQueryCacheImpl($app['orm.cache.driver']);
         $config->setProxyDir($app['orm.proxy.dir']);
         $config->setProxyNamespace($app['orm.proxy.namespace']);
         $config->setAutoGenerateProxyClasses($app['debug']);
         return $config;
     });
     /**
      * @param  Application $app
      *
      * @throws \RuntimeException
      *
      * @return \Doctrine\ORM\EntityManager
      */
     $app['orm.em'] = $app->share(function (Application $app) {
         if (!isset($app['db'])) {
             throw new \RuntimeException('DoctrineServiceProvider is not registered');
         }
         return EntityManager::create($app['db'], $app['orm.config'], $app['db.event_manager']);
     });
     /**
      * @param  Application $app
      *
      * @return \Doctrine\ORM\Tools\SchemaTool
      */
     $app['orm.schema_tool'] = $app->share(function (Application $app) {
         return new SchemaTool($app['orm.em']);
     });
     /*
      * Register console commands for doctrine if `kzykhys/console-service-provider` is registered
      */
     if (isset($app['console.commands'])) {
         $app['console'] = $app->share($app->extend('console', function (Console $console, Application $app) {
             $console->getHelperSet()->set(new ConnectionHelper($app['db']), 'db');
             $console->getHelperSet()->set(new EntityManagerHelper($app['orm.em']), 'em');
             return $console;
         }));
         $app['console.commands'] = $app->share($app->extend('console.commands', function (array $commands) {
             $create = new CreateCommand();
             $update = new UpdateCommand();
             $drop = new DropCommand();
             $generateEntity = new GenerateEntitiesCommand();
             $generateProxy = new GenerateProxiesCommand();
             $commands[] = $create->setName('doctrine:schema:create');
             $commands[] = $update->setName('doctrine:schema:update');
             $commands[] = $drop->setName('doctrine:schema:drop');
             $commands[] = $generateEntity->setName('doctrine:generate:entities');
             $commands[] = $generateProxy->setName('doctrine:generate:proxies');
             return $commands;
         }));
     }
 }