public function __construct(array $options = array()) { $this->_timer = new sfTimer(); $this->_timer->startTimer(); $options = array_intersect_key($options, $this->_options); $this->_options = array_merge($this->_options, $options); $this->_initialize(); }
protected function execute($arguments = array(), $options = array()) { $definitions = $this->getDefinition(); $timer = new sfTimer(); $succeeded = array(); $targets = $this->getOption('targets', array_keys($definitions)); foreach ((array) $definitions as $k => $v) { if (!in_array($k, $targets)) { continue; } $timer->startTimer(); $defaultOptions = array_merge($this->options, array('name' => $k, 'dir' => $this->basePath, 'required_rules' => array(), 'configuration' => $this->configuration, 'dispatcher' => new sfEventDispatcher(), 'formatter' => $this->formatter)); $v = array_merge(array('options' => $defaultOptions), $v); if (!isset($v['options']['required_rules'])) { $v['options']['required_rules'] = array(); } $requiredRules = (array) $v['options']['required_rules']; if (!empty($requiredRules) && array_diff($requiredRules, $succeeded)) { $this->logSection('upgrade', 'Passed ' . $k, null, 'ERROR'); continue; } $this->logSection('upgrade', 'Processing ' . $k); if (isset($v['file']) && is_file($v['file'])) { require_once $v['file']; } if (class_exists($v['strategy'])) { $className = $v['strategy']; } else { $className = 'opUpgrade' . $v['strategy'] . 'Strategy'; } opApplicationConfiguration::registerZend(); try { // disable Doctrine profiling sfConfig::set('sf_debug', false); $strategy = new $className($v['options']); $strategy->run(); $succeeded[] = $k; } catch (Exception $e) { $this->logBlock($e->getMessage(), 'ERROR'); } opApplicationConfiguration::unregisterZend(); $this->logSection('upgrade', sprintf('Processed %s (%.2f sec)', $k, $timer->addTime())); } $this->logSection('upgrade', sprintf('Completed Upgrading (%.2f sec)', $timer->getElapsedTime())); $this->logSection('upgrade', sprintf('The %.2f MB memory allocated', round(memory_get_peak_usage(true) / 1048576, 2))); }