Exemplo n.º 1
0
 /**
  * @param Configuration $cliConfig
  */
 protected function _doRun(\Doctrine\Common\Cli\Configuration $cliConfig)
 {
     if (!is_writable(dirname($this->installSqlFile))) {
         throw new \BuildException("Directory to write Install Sql File into is not writable.");
     }
     $em = $cliConfig->getAttribute('em');
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($em);
     $cmf = $em->getMetadataFactory();
     $classes = $cmf->getAllMetadata();
     $sql = $schemaTool->getCreateSchemaSql($classes);
     $code = "<?php\n\nreturn " . var_export($sql, true) . ";\n";
     file_put_contents($this->installSqlFile, $code);
     $this->log("Wrote the Array of SQL statements to create schema to file " . $this->installSqlFile);
 }
Exemplo n.º 2
0
 /**
  * @param Configuration $cliConfig
  */
 protected function _doRun(\Doctrine\Common\Cli\Configuration $cliConfig)
 {
     if ($this->proxyDir !== null && (!is_dir($this->proxyDir) || !is_writable($this->proxyDir))) {
         throw new \BuildException("Proxy directory is not valid or writable.");
     }
     /* @var $cliConfig \Doctrine\Common\Cli\Configuration */
     $em = $cliConfig->getAttribute('em');
     $cmf = $em->getMetadataFactory();
     $classes = $cmf->getAllMetadata();
     $factory = $em->getProxyFactory();
     if (empty($classes)) {
         $this->log('No classes to generate proxies for.');
     } else {
         $proxyDir = $this->proxyDir != null ? $this->proxyDir : $em->getConfiguration()->getProxyDir();
         $factory->generateProxyClasses($classes, $proxyDir);
         $this->log('Doctrine 2 proxy classes generated to: ' . $proxyDir);
     }
 }
 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $configuration = new Configuration();
     $configuration->setAttribute('em', $this->container->getDoctrine_Orm_ManagerService());
     $dirs = array();
     $bundleDirs = $this->container->getKernelService()->getBundleDirs();
     foreach ($this->container->getKernelService()->getBundles() as $bundle) {
         $tmp = dirname(str_replace('\\', '/', get_class($bundle)));
         $namespace = dirname($tmp);
         $class = basename($tmp);
         if (isset($bundleDirs[$namespace]) && is_dir($dir = $bundleDirs[$namespace] . '/' . $class . '/Model/Doctrine')) {
             $dirs[] = $dir;
         }
     }
     if (!is_dir($dir = $this->container->getParameter('kernel.cache_dir') . '/doctrine/Proxies')) {
         mkdir($dir, 0777, true);
     }
     $cli = new DoctrineCliController($configuration);
     foreach ($dirs as $dir) {
         $cli->run(array('doctrine', 'orm:generate-proxies', '--class-dir=' . $dir));
     }
 }
Exemplo n.º 4
0
 public function testConfiguration()
 {
     $config = new Configuration();
     $config->setAttribute('name', 'value');
     $this->assertTrue($config->hasAttribute('name'));
     $this->assertEquals('value', $config->hasAttribute('name'));
     $config->setAttribute('name');
     $this->assertFalse($config->hasAttribute('name'));
 }