/** * Register the service provider. * * @return void */ public function register() { $this->app->singleton('twig.loader', function () { $loader = new Twig_Loader_Filesystem('/'); foreach ($this->app->getPlugins() as $plugin) { $loader->addPath($plugin->getBasePath() . '/views', $plugin->getTwigNamespace()); } return $loader; }); $this->app->bind('twig.options', function () { return ['debug' => $this->app->environment() === 'local', 'charset' => 'utf-8', 'cache' => content_directory() . '/twig-cache', 'auto_reload' => true, 'strict_variables' => false, 'autoescape' => true, 'optimizations' => -1]; }); $this->app->bind('twig.functions', function () { return ['dd', 'herbert', 'view', 'content_directory', 'plugin_directory', 'panel_url', 'route_url', 'session', 'session_flashed', 'errors']; }); $this->app->singleton('twig', function () { return $this->constructTwig(); }); $this->app->alias('twig', 'Twig_Environment'); }
/** * Gets a url to a relative asset. * * @param string $file * @return string */ public static function assetUrl($file = null) { return content_url(substr(self::asset($file), strlen(content_directory()))); }
/** * Added to satisfy interface * * @return string */ public function basePath() { return content_directory() . '/herbert-cache'; }