/** * Diem override: * sfContext is hardcoded in symfony unit tests. * Replace it with dmContext. * * @see sfBrowser */ public function getContext($forceReload = false) { if (null === $this->context || $forceReload) { $isContextEmpty = null === $this->context; $context = $isContextEmpty ? sfContext::getInstance() : $this->context; // create configuration $currentConfiguration = $context->getConfiguration(); $configuration = ProjectConfiguration::getApplicationConfiguration($currentConfiguration->getApplication(), $currentConfiguration->getEnvironment(), $currentConfiguration->isDebug()); // connect listeners $configuration->getEventDispatcher()->connect('application.throw_exception', array($this, 'listenToException')); foreach ($this->listeners as $name => $listener) { $configuration->getEventDispatcher()->connect($name, $listener); } // create context $this->context = dm::createContext($configuration); unset($currentConfiguration); if (!$isContextEmpty) { sfConfig::clear(); sfConfig::add($this->rawConfiguration); } else { $this->rawConfiguration = sfConfig::getAll(); } } return $this->context; }
protected function boot() { $configuration = ProjectConfiguration::getApplicationConfiguration($this->options['app'], $this->options['env'], $this->options['debug']); $this->context = dm::createContext($configuration); sfConfig::set('sf_logging_enabled', false); // remove all cache sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir')); }
public function getContext() { if (null === $this->context) { if (!dmContext::hasInstance()) { $this->logSection('diem', sprintf('Loading %s...', get_class($this->configuration))); dm::createContext($this->configuration); } $this->context = dmContext::getInstance(); } return $this->context; }
/** * Get the current context * @return dmContext */ public function getContext() { if (null === $this->context) { if (!dmContext::hasInstance()) { $this->logSection('Diem Extended', sprintf('Loading %s...', get_class($this->configuration))); dm::createContext($this->configuration); } $this->context = dmContext::getInstance(); $this->context->get('filesystem')->setFormatter($this->formatter); } return $this->context; }
<?php require_once dirname(__FILE__) . '/../config/ProjectConfiguration.class.php'; $configuration = ProjectConfiguration::getApplicationConfiguration('front', 'prod', false); dm::createContext($configuration)->dispatch();
<?php // guess current application if (!isset($app)) { $traces = debug_backtrace(); $caller = $traces[0]; $dirPieces = explode(DIRECTORY_SEPARATOR, dirname($caller['file'])); $app = array_pop($dirPieces); } require_once dirname(__FILE__) . '/../../config/ProjectConfiguration.class.php'; $configuration = ProjectConfiguration::getApplicationConfiguration($app, 'test', isset($debug) ? $debug : true); dm::createContext($configuration); // remove all cache sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));