public function execute($arguments = array(), $options = array()) { $databaseManager = new sfDatabaseManager($this->configuration); $message = 'Compiling the Doctrine core'; if ($options['driver']) { $message .= ' with driver(s) "' . implode('", "', $options['driver']) . '"'; } $this->logSection('doctrine', $message); $target = Doctrine_Core::compile($arguments['target'], $options['driver']); $target = realpath($target); $targetPhp = var_export($target, true); foreach (array('sf_symfony_lib_dir', 'sf_lib_dir', 'sf_root_dir') as $name) { $path = sfConfig::get($name); if (0 === strpos($target, $path)) { $targetPhp = "sfConfig::get('{$name}')." . var_export(substr($target, strlen($path)), true); break; } } $this->log(<<<EOF Doctrine compilation complete. Add the following code to ProjectConfiguration: public function setup() { // ... if (\$this instanceof sfApplicationConfiguration && !\$this->isDebug()) { require_once {$targetPhp}; } } EOF ); }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { $databaseManager = new sfDatabaseManager($this->configuration); $compiledFile = sfConfig::get('sf_cache_dir') . '/doctrine.compiled.php'; if (file_exists($compiledFile)) { $this->logSection('error', $compiledFile . ' already exists', null, 'ERROR'); $this->logBlock('Run symfony:cache-clear first', 'INFO'); return; } $drivers = array(); foreach ($databaseManager->getNames() as $name) { $drivers[] = strtolower($databaseManager->getDatabase($name)->getDoctrineConnection()->getDriverName()); } $drivers = array_unique($drivers); $this->logSection('compile', 'Included drivers: ' . implode(', ', $drivers)); Doctrine_Core::compile($compiledFile, $drivers); $this->logSection('file+', $compiledFile); }
public function execute() { $compiledPath = Doctrine_Core::compile($this->getArgument('compiled_path'), $this->getArgument('drivers', array())); $this->notify('Compiled Doctrine successfully to: ' . $compiledPath); }