本文整理汇总了PHP中Illuminate\View\Engines\EngineResolver类的典型用法代码示例。如果您正苦于以下问题:PHP EngineResolver类的具体用法?PHP EngineResolver怎么用?PHP EngineResolver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EngineResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* 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: __construct
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: registerTwigEngine
/**
* 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: setUp
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: registerJadeEngine
/**
* 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: __construct
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: __construct
/**
* 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: registerBladeEngine
/**
* 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: registerMarkdownEngine
/**
* 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: register
/**
* 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: registerBladeEngine
/**
* 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: getEngineResolver
/**
* 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: __construct
/**
* 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: makeView
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: getViewFactory
/**
* 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;
}