sfContext::switchTo PHP Method

switchTo() public static method

Sets the current context to something else
public static switchTo ( string $name )
$name string The name of the context to switch to
    public static function switchTo($name)
    {
        if (!isset(self::$instances[$name])) {
            $currentConfiguration = sfContext::getInstance()->getConfiguration();
            sfContext::createInstance(ProjectConfiguration::getApplicationConfiguration($name, $currentConfiguration->getEnvironment(), $currentConfiguration->isDebug()));
        }
        self::$current = $name;
        sfContext::getInstance()->getConfiguration()->activate();
    }

Usage Example

 protected function createContextInstance($application = 'frontend', $enviroment = 'dev', $debug = true)
 {
     $configuration = ProjectConfiguration::getApplicationConfiguration($application, $enviroment, $debug);
     sfContext::createInstance($configuration);
     sfContext::switchTo($application);
     $this->context = sfContext::getInstance();
 }
All Usage Examples Of sfContext::switchTo