コード例 #1
0
ファイル: TemplateRenderer.php プロジェクト: garbetjie/tiny
 /**
  * Template constructor.
  *
  * @param Container $container
  */
 public function __construct(Container $container)
 {
     $settings = $container->get('settings');
     $compiledPath = $settings['storagePath'] . DIRECTORY_SEPARATOR . 'views';
     $resolver = new EngineResolver();
     $resolver->register('blade', function () use($compiledPath, &$settings) {
         $bladeCompiler = new BladeCompiler(new Filesystem(), $compiledPath);
         // Add the @webroot directive.
         $bladeCompiler->directive('webroot', function ($expression) use(&$settings) {
             $segments = explode(',', preg_replace("/[\\(\\)\\\"\\']/", '', $expression));
             $path = rtrim($settings['webrootBasePath'], '/') . '/' . ltrim($segments[0], '/');
             $path = str_replace("'", "\\'", $path);
             return "<?= e('{$path}') ?>";
         });
         // Add the @route directive.
         $bladeCompiler->directive('route', function ($expression) use(&$settings) {
             $segments = explode(',', preg_replace("/[\\(\\)\\\"\\']/", '', $expression));
             $path = rtrim($settings['routeBasePath'], '/') . '/' . ltrim($segments[0], '/');
             $path = str_replace("'", "\\'", $path);
             return "<?= e('{$path}') ?>";
         });
         return new CompilerEngine($bladeCompiler);
     });
     $finder = new FileViewFinder(new Filesystem(), [$settings['templatePath']]);
     $factory = new ViewFactory($resolver, $finder, new Dispatcher());
     $this->factory = $factory;
     $this->container = $container;
 }
コード例 #2
0
ファイル: Container.php プロジェクト: ngangchill/ronin-blade
 public function __construct()
 {
     $this->instance('container', $this);
     $this->singleton('events', function () {
         return new Dispatcher();
     });
     $this->singleton('files', function () {
         return new Filesystem();
     });
     $this->singleton('blade.compiler', function () {
         return new BladeCompiler($this['files'], $this['view.compiled']);
     });
     $this->singleton('view.engine.resolver', function () {
         $resolver = new EngineResolver();
         $resolver->register('blade', function () {
             return new CompilerEngine($this['blade.compiler'], $this['files']);
         });
         $resolver->register('php', function () {
             return new PhpEngine();
         });
         return $resolver;
     });
     $this->singleton('view.finder', function () {
         return new FileViewFinder($this['files'], $this['view.paths']);
     });
     $this->singleton('view', function () {
         $env = new Factory($this['view.engine.resolver'], $this['view.finder'], $this['events']);
         $env->setContainer($this['container']);
         return $env;
     });
 }
コード例 #3
0
 /**
  * Register the Twig engine to the EngineResolver.
  * 
  * @param string         $engine
  * @param EngineResolver $resolver
  */
 protected function registerTwigEngine($engine, EngineResolver $resolver)
 {
     $container = $this->app;
     $resolver->register($engine, function () use($container) {
         // Set the loader main namespace (paths).
         $container['twig.loader']->setPaths($container['view.finder']->getPaths());
         return new TwigEngine($container['twig'], $container['view.finder']);
     });
 }
コード例 #4
0
 protected function setUp()
 {
     parent::setUp();
     $this->mock_view_finder = Mockery::mock('Illuminate\\View\\ViewFinderInterface')->shouldIgnoreMissing();
     $this->mock_engine_resolver = Mockery::mock('Illuminate\\View\\Engines\\EngineResolver')->shouldIgnoreMissing();
     $this->mock_translator = Mockery::mock('\\Illuminate\\Translation\\Translator')->shouldIgnoreMissing();
     $this->mock_session = Mockery::mock('\\Illuminate\\Session\\Store')->shouldIgnoreMissing();
     $this->mock_dispatcher = Mockery::mock('\\Illuminate\\Contracts\\Events\\Dispatcher')->shouldIgnoreMissing();
     $this->mock_engine_resolver->shouldReceive('resolve')->andReturn(Mockery::mock('\\Illuminate\\View\\Engines\\EngineInterface')->shouldIgnoreMissing());
     $this->factory = new Factory($this->mock_engine_resolver, $this->mock_view_finder, $this->mock_dispatcher, $this->mock_translator);
     $this->factory->setSession($this->mock_session);
 }
コード例 #5
0
 /**
  * Register the Jade engine implementation.
  *
  * @param \Illuminate\View\Engines\EngineResolver $resolver
  */
 public function registerJadeEngine(EngineResolver $resolver)
 {
     $app = $this->app;
     $app->singleton('jade.compiler', function ($app) {
         $cache = $app['config']['view.compiled'];
         return new JadeCompiler($app['files'], $cache);
     });
     $resolver->register('jade', function () use($app) {
         return new CompilerEngine($app['jade.compiler'], $app['files']);
     });
     $app['view']->addExtension('jade.php', 'jade');
 }
コード例 #6
0
ファイル: App.php プロジェクト: wilgucki/blade-builder
 public function __construct($viewsDir, $cacheDir)
 {
     $filesystem = new Filesystem();
     $engineResolver = new EngineResolver();
     $engineResolver->register('blade', function () use($filesystem, $cacheDir) {
         return new CompilerEngine(new BladeCompiler($filesystem, $cacheDir));
     });
     $factory = new Factory($engineResolver, new FileViewFinder($filesystem, [$viewsDir]), new Dispatcher());
     $this->factory = $factory;
     $this->viewsDir = $viewsDir;
     $this->filesystem = $filesystem;
 }
コード例 #7
0
ファイル: BladeRenderer.php プロジェクト: babdev/renderer
 /**
  * Constructor.
  *
  * @param   Factory  $renderer  Rendering engine
  *
  * @since   __DEPLOY_VERSION__
  */
 public function __construct(Factory $renderer = null)
 {
     if (!$renderer) {
         $filesystem = new Filesystem();
         $resolver = new EngineResolver();
         $resolver->register('blade', function () use($filesystem) {
             return new CompilerEngine(new BladeCompiler($filesystem, getcwd() . '/cache'));
         });
         $renderer = new Factory($resolver, new FileViewFinder($filesystem, []), new Dispatcher());
     }
     $this->renderer = $renderer;
 }
コード例 #8
0
 /**
  * Register the Blade engine implementation.
  *
  * @param  \Illuminate\View\Engines\EngineResolver  $resolver
  * @return void
  */
 public function registerBladeEngine($resolver)
 {
     $app = $this->app;
     $resolver->register('blade', function () use($app) {
         $cache = $app['path.storage'] . '/views';
         // The Compiler engine requires an instance of the CompilerInterface, which in
         // this case will be the Blade compiler, so we'll first create the compiler
         // instance to pass into the engine so it can compile the views properly.
         $compiler = new BladeCompiler($app['files'], $cache);
         return new CompilerEngine($compiler, $app['files']);
     });
 }
コード例 #9
0
 /**
  * Register the Markdown engine implementation.
  *
  * @param  EngineResolver  $resolver
  * @return void
  */
 public function registerMarkdownEngine($resolver)
 {
     $app = $this->app;
     $resolver->register('markdown', function () use($app) {
         $cache = storage_path() . '/markdown';
         if (!File::isDirectory($cache)) {
             File::makeDirectory($cache);
         }
         $compiler = new MarkdownCompiler($app['files'], $cache);
         $compiler->setOptions(Config::get('markdown.options'));
         return new CompilerEngine($compiler, $app['files']);
     });
 }
コード例 #10
0
ファイル: ServiceProvider.php プロジェクト: elwinar/minit
 /**
  * Register the application services.
  *
  * @return void
  */
 public function register()
 {
     $this->app->bind('minit', function () {
         return new \Minit\Engine();
     });
     $this->app->singleton('view.engine.resolver', function () {
         $resolver = new EngineResolver();
         $resolver->register('php', function () {
             return new \Minit\Engine();
         });
         return $resolver;
     });
 }
コード例 #11
0
ファイル: ViewServiceProvider.php プロジェクト: ejay010/Ploy
 /**
  * Register the Blade engine implementation.
  *
  * @param  \Illuminate\View\Engines\EngineResolver  $resolver
  * @return void
  */
 public function registerBladeEngine($resolver)
 {
     $app = $this->app;
     // The Compiler engine requires an instance of the CompilerInterface, which in
     // this case will be the Blade compiler, so we'll first create the compiler
     // instance to pass into the engine so it can compile the views properly.
     $app->singleton('blade.compiler', function ($app) {
         $cache = $app['config']['view.compiled'];
         return new BladeCompiler($app['files'], $cache);
     });
     $resolver->register('blade', function () use($app) {
         return new CompilerEngine($app['blade.compiler']);
     });
 }
コード例 #12
0
ファイル: BladeEngine.php プロジェクト: ymnl007/Clerk
 /**
  * Register the engine resolver instance.
  *
  * @return EngineResolver
  */
 public function getEngineResolver()
 {
     $resolver = new EngineResolver();
     // Add PhpEngine
     $resolver->register('php', function () {
         return new PhpEngine();
     });
     // Add Blade compiler engine
     $resolver->register('blade', function () {
         $compiler = new BladeCompiler($this->files, $this->cachePath);
         return new CompilerEngine($compiler);
     });
     return $resolver;
 }
コード例 #13
0
ファイル: Blade.php プロジェクト: rakit/blade
 /**
  * Create a new Blade Factory instance
  *
  * @param array $view_paths
  * @param mixed $view_cache_path
  */
 public function __construct(array $view_paths, $view_cache_path = null)
 {
     $resolver = new EngineResolver();
     $finder = new FileViewFinder(new Filesystem(), $view_paths);
     $dispatcher = new Dispatcher();
     $resolver->register("blade", function () use($view_cache_path) {
         if (!is_dir($view_cache_path)) {
             mkdir($view_cache_path, 0777, true);
         }
         $blade = new BladeCompiler(new Filesystem(), $view_cache_path);
         return new CompilerEngine($blade);
     });
     parent::__construct($resolver, $finder, $dispatcher);
 }
コード例 #14
0
 protected function makeView()
 {
     $app = new Container();
     $resolver = new EngineResolver();
     $resolver->register('php', function () {
         return new PhpEngine();
     });
     $finder = new FileViewFinder(new Filesystem(), [realpath(__DIR__)]);
     $dispatcher = (new Dispatcher($app))->setQueueResolver(function () use($app) {
         return $app->make('Illuminate\\Contracts\\Queue\\Factory');
     });
     $env = new Factory($resolver, $finder, $dispatcher);
     $env->setContainer($app);
     $env->share('app', $app);
     return new Illuminate($env);
 }
コード例 #15
0
ファイル: Environment.php プロジェクト: roffjump/forum
 /**
  * Register a valid Markdown extension and its engine.
  *
  * @param  string   $extension
  * @param  string   $engine
  * @param  Closure  $resolver
  * @return void
  */
 public function addExtension($extension, $engine, $resolver = null)
 {
     $this->finder->addExtension($extension);
     if (isset($resolver)) {
         $this->engines->register($engine, $resolver);
     }
     $this->extensions[$extension] = $engine;
 }
コード例 #16
0
ファイル: BladeInstance.php プロジェクト: ngangchill/blade-1
 /**
  * Get the laravel view factory.
  *
  * @return Factory
  */
 protected function getViewFactory()
 {
     if ($this->factory) {
         return $this->factory;
     }
     $resolver = new EngineResolver();
     $resolver->register("blade", function () {
         if (!is_dir($this->cache)) {
             mkdir($this->cache, 0777, true);
         }
         $blade = new BladeCompiler(new Filesystem(), $this->cache);
         Blade::registerDirectives($blade);
         return new CompilerEngine($blade);
     });
     $this->factory = new Factory($resolver, $this->getViewFinder(), new Dispatcher());
     return $this->factory;
 }
コード例 #17
0
 /**
  * Register the mustache engine implementation.
  *
  * @param  \Illuminate\View\Engines\EngineResolver  $resolver
  * @return void
  */
 public function registerHandlebarsEngine($resolver)
 {
     $app = $this->app;
     // The Compiler engine requires an instance of the CompilerInterface, which in
     // this case will be the Handlebars compiler, so we'll first create the compiler
     // instance to pass into the engine so it can compile the views properly.
     $app->singleton('handlebars.lightncandy', function ($app) {
         return new LightnCandy();
     });
     $app->singleton('handlebars.compiler', function ($app) {
         $cache = $app['config']['view.compiled'];
         return new HandlebarsCompiler($app['files'], $app['handlebars.lightncandy'], $cache);
     });
     $resolver->register('handlebars', function () use($app) {
         return new HandlebarsEngine($app['handlebars.compiler']);
     });
 }
コード例 #18
0
ファイル: Katana.php プロジェクト: themsaid/katana-core
 /**
  * Create the view factory with a Blade Compiler.
  *
  * @return Factory
  */
 private function createViewFactory()
 {
     $resolver = new EngineResolver();
     $bladeCompiler = $this->createBladeCompiler();
     $resolver->register('blade', function () use($bladeCompiler) {
         return new CompilerEngine($bladeCompiler);
     });
     $dispatcher = new Dispatcher();
     $dispatcher->listen('creating: *', function () {
         /**
          * On rendering Blade views we will mute error reporting as
          * we don't care about undefined variables or type
          * mistakes during compilation.
          */
         error_reporting(error_reporting() & ~E_NOTICE & ~E_WARNING);
     });
     return new Factory($resolver, new FileViewFinder($this->filesystem, [KATANA_CONTENT_DIR]), $dispatcher);
 }
コード例 #19
0
ファイル: Factory.php プロジェクト: nix9/laracasts
 /**
  * Register a valid view extension and its engine.
  *
  * @param  string    $extension
  * @param  string    $engine
  * @param  \Closure  $resolver
  * @return void
  */
 public function addExtension($extension, $engine, $resolver = null)
 {
     $this->finder->addExtension($extension);
     if (isset($resolver)) {
         $this->engines->register($engine, $resolver);
     }
     unset($this->extensions[$extension]);
     $this->extensions = array_merge([$extension => $engine], $this->extensions);
 }
コード例 #20
0
ファイル: BladeRenderer.php プロジェクト: im286er/windwalker
 /**
  * Method to get property Resolver
  *
  * @return  EngineResolver
  */
 public function getResolver()
 {
     if (!$this->resolver) {
         $self = $this;
         $this->resolver = new EngineResolver();
         $this->resolver->register('blade', function () use($self) {
             return $self->getCompiler();
         });
     }
     return $this->resolver;
 }
コード例 #21
0
ファイル: LessServiceProvider.php プロジェクト: vtalbot/less
 /**
  * Register the LESS engine implementation.
  *
  * @param  Illuminate\View\Engines\EngineResolver  $resolver
  * @return void
  */
 public function registerLessEngine($resolver)
 {
     $app = $this->app;
     $resolver->register('less', function () use($app) {
         $cache = storage_path() . '/less';
         if (!File::isDirectory($cache)) {
             File::makeDirectory($cache);
         }
         $compiler = new LessCompiler(app('files'), $cache);
         return new CompilerEngine($compiler, app('files'));
     });
 }
コード例 #22
0
ファイル: ConvertConfigCommand.php プロジェクト: Devitek/orm
 /**
  * @return \Illuminate\View\Factory
  */
 protected function createViewFactory()
 {
     $FileViewFinder = new FileViewFinder(new Filesystem(), [realpath(__DIR__ . '/ConfigMigrations/templates')]);
     $dispatcher = new Dispatcher(new Container());
     $compiler = new BladeCompiler(new Filesystem(), storage_path() . '/framework/views');
     $bladeEngine = new CompilerEngine($compiler);
     $engineResolver = new EngineResolver();
     $engineResolver->register('blade', function () use(&$bladeEngine) {
         return $bladeEngine;
     });
     $viewFactory = new \Illuminate\View\Factory($engineResolver, $FileViewFinder, $dispatcher);
     return $viewFactory;
 }
コード例 #23
0
 /**
  * Registers services on the given container.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param Container $pimple A container instance
  */
 public function register()
 {
     /*
      * application default view
      *
      * @param $c container
      * @return Factory view Factory
      */
     $this->app['view'] = function ($c) {
         $viewResolver = new EngineResolver();
         $compiler = new BladeCompiler($c['filesystem'], $this->app->basePath() . '/storage/view');
         $filesystem = $c['filesystem'];
         $viewResolver->register('blade', function () use($compiler, $filesystem) {
             return new CompilerEngine($compiler, $filesystem);
         });
         $viewResolver->register('php', function () {
             return new PhpEngine();
         });
         $viewFinder = new FileViewFinder($filesystem, [$this->app->path . '/View']);
         $viewFactory = new Factory($viewResolver, $viewFinder, new Dispatcher());
         return $viewFactory;
     };
 }
コード例 #24
0
 /**
  * @param Container $app
  */
 public function register(Container $app)
 {
     // we only need to do this if Blade views are enabled.
     if ($app['config']['view.blade.enabled']) {
         $app['blade.settings'] = $app['config']['view.blade.defaults'];
         $app['blade.template.paths'] = $app['blade.settings']['template_paths'];
         $app['files'] = function () {
             return new Filesystem();
         };
         $app['view.finder'] = function ($app) {
             return new FileViewFinder(new Filesystem(), $app['blade.template.paths']);
         };
         // create the Blade compiler using Filesystem and cache directory
         $app['blade.compiler'] = function ($app) {
             return new BladeCompiler(new Filesystem(), $app['blade.settings']['cache']);
         };
         // get a blade compiler engine instance
         $app['blade.engine'] = function ($app) {
             return new CompilerEngine($app['blade.compiler']);
         };
         $app['view.engine.resolver'] = function ($app) {
             $resolver = new EngineResolver();
             $resolver->register('php', function () {
                 return new PhpEngine();
             });
             $resolver->register('blade', function () use($app) {
                 return new CompilerEngine($app['blade.compiler'], $app['files']);
             });
             return $resolver;
         };
         $app['blade.factory'] = function ($app) {
             $view_factory = new IlluminateViewFactory($app['view.engine.resolver'], $app['view.finder'], $app['illuminate.events']);
             $view_factory->setContainer($app['nine.container']);
             return $view_factory;
         };
     }
 }
コード例 #25
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $app = $this->app;
     $this->mergeConfigFrom($this->configPath(), 'view-docblock');
     if ($this->app->environment() === 'production' && !$app['config']['view-docblock.enable_production']) {
         return;
     }
     $app->bind(TokenParserInterface::class, TokenParser::class);
     # Support additional types via configuration
     $app->singleton(ArgumentValidation::class, function ($app) {
         $validator = new ArgumentValidation(TypeDescriptionParser::class, $app['config']['view-docblock.report_missing_arguments']);
         foreach ($app['config']['view-docblock.additional_types'] as $typeClass => $aliases) {
             $type = $app[$typeClass];
             if (empty($aliases)) {
                 $validator->registerType($type);
             } else {
                 $aliases = !is_array($aliases) ? [$aliases] : $aliases;
                 foreach ($aliases as $alias) {
                     $validator->registerTypeAs($type, $alias);
                 }
             }
         }
         return $validator;
     });
     # From here on mimic behaviour of
     # \Illuminate\View\ViewServiceProvider
     $app->singleton('blade.compiler', function ($app) {
         $cache = $app['config']['view.compiled'];
         return new BladeCompiler($app['files'], $cache);
     });
     # Override default engines
     $app->singleton('view.engine.resolver', function ($app) {
         $resolver = new EngineResolver();
         $resolver->register('php', function () use($app) {
             return new PhpEngine($app[Parser::class], $app[ExtractFromDocblock::class], $app[ArgumentValidation::class], $app['config']->get('view-docblock.require_docblock_on_data'), $app['config']->get('view-docblock.argument_blacklist'));
         });
         $resolver->register('blade', function () use($app) {
             return new CompilerEngine($app['blade.compiler'], $app[Parser::class], $app[ExtractFromDocblock::class], $app[ArgumentValidation::class], $app['config']->get('view-docblock.require_docblock_on_data'), $app['config']->get('view-docblock.argument_blacklist'));
         });
         return $resolver;
     });
 }
コード例 #26
0
ファイル: Blade.php プロジェクト: triangle-lab/bitrix-blade
 /**
  * Register the Blade engine implementation.
  *
  * @param EngineResolver $resolver
  *
  * @return void
  */
 public function registerBladeEngine($resolver)
 {
     $me = $this;
     $app = $this->container;
     $this->container->singleton('blade.compiler', function ($app) use($me) {
         $cache = $me->cachePath;
         return new BladeCompiler($app['files'], $cache);
     });
     $resolver->register('blade', function () use($app) {
         return new CompilerEngine($app['blade.compiler'], $app['files']);
     });
 }
コード例 #27
0
ファイル: HtmlFormat.php プロジェクト: tootutor/tto-api
 public static function blade(array $data, $debug = true)
 {
     $resolver = new EngineResolver();
     $files = new Filesystem();
     $compiler = new BladeCompiler($files, static::$cacheDirectory);
     $engine = new CompilerEngine($compiler);
     $resolver->register('blade', function () use($engine) {
         return $engine;
     });
     /** @var Restler $restler */
     $restler = Scope::get('Restler');
     //Lets expose shortcuts for our classes
     spl_autoload_register(function ($className) use($restler) {
         if (isset($restler->apiMethodInfo->metadata['scope'][$className])) {
             return class_alias($restler->apiMethodInfo->metadata['scope'][$className], $className);
         }
         if (isset(Scope::$classAliases[$className])) {
             return class_alias(Scope::$classAliases[$className], $className);
         }
         return false;
     }, true, true);
     $viewFinder = new FileViewFinder($files, array(static::$viewPath));
     $factory = new Factory($resolver, $viewFinder, new Dispatcher());
     $path = $viewFinder->find(self::$view);
     $view = new View($factory, $engine, self::$view, $path, $data);
     $factory->callCreator($view);
     return $view->render();
 }
コード例 #28
0
ファイル: Foundation.php プロジェクト: visualturk/lexicon
 /**
  * Register the Blade engine implementation.
  *
  * @param  \Illuminate\View\Engines\EngineResolver $resolver
  * @return void
  */
 public function registerBladeEngine(EngineResolver $resolver)
 {
     $container = $this->getContainer();
     $container->bindShared('blade.compiler', function () {
         return new BladeCompiler($this->getFilesystem(), $this->getStoragePath());
     });
     $resolver->register('blade', function () use($container) {
         return new CompilerEngine($container['blade.compiler'], $this->getFilesystem());
     });
 }
コード例 #29
0
ファイル: Blade.php プロジェクト: spatie/laravel-blade
 /**
  * Register the Blade engine implementation.
  *
  * @param  \Illuminate\View\Engines\EngineResolver  $resolver
  * @return void
  */
 public function registerBladeEngine($resolver)
 {
     $me = $this;
     $app = $this->container;
     // The Compiler engine requires an instance of the CompilerInterface, which in
     // this case will be the Blade compiler, so we'll first create the compiler
     // instance to pass into the engine so it can compile the views properly.
     $this->container->bindShared('blade.compiler', function ($app) use($me) {
         $cache = $me->cachePath;
         return new BladeCompiler($app['files'], $cache);
     });
     $resolver->register('blade', function () use($app) {
         return new CompilerEngine($app['blade.compiler'], $app['files']);
     });
 }
コード例 #30
0
 public function configView()
 {
     $engineResolver = new EngineResolver();
     $engineResolver->register('php', function () {
         return new PhpEngine();
     });
     $this->app->singleton('blade.compiler', function ($app) {
         $cachePath = $this->basePath . "/storage/framework/views";
         return new BladeCompiler(new Filesystem(), $cachePath);
     });
     $engineResolver->register('blade', function () {
         return new CompilerEngine($this->app['blade.compiler']);
     });
     $fileViewFinder = new FileViewFinder(new Filesystem(), [], null);
     $this->viewFactory = new Factory($engineResolver, $fileViewFinder, new Dispatcher());
     $fileViewFinder->addLocation($this->basePath . "/resources/views");
 }