Decoupled from main app View Factory (#475)

This commit is contained in:
theMadness
2017-03-31 11:14:28 +02:00
committed by Barry vd. Heuvel
parent 144a50e8ee
commit 75e1f22ec6
4 changed files with 29 additions and 6 deletions
+1 -1
View File
@@ -90,7 +90,7 @@ class MetaCommand extends Command
}
}
$content = $this->view->make('ide-helper::meta', [
$content = $this->view->make('meta', [
'bindings' => $bindings,
'methods' => $this->methods,
])->render();
+1 -1
View File
@@ -80,7 +80,7 @@ class Generator
public function generatePhpHelper()
{
$app = app();
return $this->view->make('ide-helper::helper')
return $this->view->make('helper')
->with('namespaces_by_extends_ns', $this->getAliasesByExtendsNamespace())
->with('namespaces_by_alias_ns', $this->getAliasesByAliasNamespace())
->with('helpers', $this->helpers)
+25 -4
View File
@@ -14,6 +14,10 @@ use Illuminate\Support\ServiceProvider;
use Barryvdh\LaravelIdeHelper\Console\MetaCommand;
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
use Barryvdh\LaravelIdeHelper\Console\GeneratorCommand;
use Illuminate\View\Engines\EngineResolver;
use Illuminate\View\Engines\PhpEngine;
use Illuminate\View\Factory;
use Illuminate\View\FileViewFinder;
class IdeHelperServiceProvider extends ServiceProvider
{
@@ -53,11 +57,12 @@ class IdeHelperServiceProvider extends ServiceProvider
{
$configPath = __DIR__ . '/../config/ide-helper.php';
$this->mergeConfigFrom($configPath, 'ide-helper');
$localViewFactory = $this->createLocalViewFactory();
$this->app->singleton(
'command.ide-helper.generate',
function ($app) {
return new GeneratorCommand($app['config'], $app['files'], $app['view']);
function ($app) use ($localViewFactory) {
return new GeneratorCommand($app['config'], $app['files'], $localViewFactory);
}
);
@@ -70,8 +75,8 @@ class IdeHelperServiceProvider extends ServiceProvider
$this->app->singleton(
'command.ide-helper.meta',
function ($app) {
return new MetaCommand($app['files'], $app['view']);
function ($app) use ($localViewFactory) {
return new MetaCommand($app['files'], $localViewFactory);
}
);
@@ -87,4 +92,20 @@ class IdeHelperServiceProvider extends ServiceProvider
{
return array('command.ide-helper.generate', 'command.ide-helper.models');
}
/**
* @return Factory
*/
private function createLocalViewFactory()
{
$resolver = new EngineResolver();
$resolver->register('php', function () {
return new PhpEngine();
});
$finder = new FileViewFinder($this->app['files'], [__DIR__ . '/../resources/views']);
$factory = new Factory($resolver, $finder, $this->app['events']);
$factory->addExtension('php', 'php');
return $factory;
}
}