public function register(Container $app) { $app['view.globals'] = []; $app['view.engines'] = ['mustache' => 'view.engine.mustache', 'ms' => 'view.engine.mustache', 'tpl' => 'view.engine.smarty', 'twig' => 'view.engine.twig', 'php' => 'view.engine.php', 'html' => 'view.engine.string']; $app['view.engine'] = function ($app) { $factory = $app['debug'] && $app['logger'] ? $app['view.factory.debug'] : $app['view.factory']; $factory->getSharedBag()->add($app['view.globals']); return $factory; }; $app['engine'] = function ($app) { return $app['view.engine']; }; $app['view.factory'] = function ($app) { return new ViewFactory($app['view.engine_delegate']); }; $app['view.factory.debug'] = function ($app) { return new LoggableViewFactory($app['view.engine_delegate'], $app['view.logger']); }; $app['view.engine_delegate'] = function ($app) { return new DelegatingEngine($app['view.engine_resolver']); }; $app['view.engine_resolver'] = function ($app) { return new LazyEngineResolver($app, $app['view.engines'], $app['view.default_engine']); }; $app['view.logger'] = function ($app) { $stopwatch = isset($app['debug.stopwatch']) ? $app['debug.stopwatch'] : null; return new ViewLogger($app['logger'], $stopwatch); }; $app['view.finder'] = function ($app) { $paths = $app['config']['view.paths']; $extensions = $app['config']['view.extensions']; return new ViewFinder($app['files'], $paths, $extensions); }; $app['view.parser'] = function ($app) { return new Parser($app); }; $app['template'] = function ($app) { $template = new Template(); $template->setContainer($app); $template->setDefaults(); return $template; }; $app['theme'] = function ($app) { return $app['template']; }; $extensions = $this->getSettings('view.extensions'); $app['view.default_engine'] = is_array($extensions) ? $extensions[0] : 'tpl'; $this->registerEngines($app); $this->registerSmartyEngine($app); $this->registerTwigEngine($app); }