/** * {@inheritdoc} */ public function boot(ContainerInterface $container) { if (empty($this->options)) { throw new \RuntimeException('You must provide options for the Symfony 1.4 kernel.'); } if ($this->isBooted()) { return; } if ($this->classLoader && !$this->classLoader->isAutoloaded()) { $this->classLoader->autoload(); } $dispatcher = $container->get('event_dispatcher'); $event = new LegacyKernelBootEvent($container->get('request'), $this->options); $dispatcher->dispatch(LegacyKernelEvents::BOOT, $event); $this->options = $event->getOptions(); require_once $this->rootDir . '/config/ProjectConfiguration.class.php'; $application = $this->options['application']; $environment = $this->options['environment']; $debug = $this->options['debug']; $this->configuration = \ProjectConfiguration::getApplicationConfiguration($application, $environment, $debug, $this->getRootDir()); $this->configuration->loadHelpers(array('Url')); // Create a context to use with some helpers like Url. if (!\sfContext::hasInstance()) { $session = $container->get('session'); if ($session->isStarted()) { $session->save(); } ob_start(); \sfContext::createInstance($this->configuration); ob_end_flush(); $session->migrate(); } $this->isBooted = true; }
/** * Loads standard extensions for Symfony into the view. */ protected function loadExtensions() { // should be replaced with sf_twig_standard_extensions $prefixes = array_merge(array('Helper', 'Url', 'Asset', 'Tag', 'Escaping', 'Partial', 'I18N'), sfConfig::get('sf_standard_helpers')); foreach ($prefixes as $prefix) { $class_name = $prefix . '_Twig_Extension'; if (class_exists($class_name)) { $this->twig->addExtension(new $class_name()); } } // for now the extensions needs the original helpers so lets load thoose. $this->configuration->loadHelpers($prefixes); // makes it possible to load custom twig extensions. foreach (sfConfig::get('sf_twig_extensions', array()) as $extension) { if (!class_exists($extension)) { throw new InvalidArgumentException(sprintf('Unable to load "%s" as an Twig_Extension into Twig_Environment', $extension)); } $this->twig->addExtension(new $extension()); } }