Skip to content

Commit f89e3e9

Browse files
kajetan-nobelwebwizo
authored andcommitted
Create new View with old ViewFinder (#26)
1 parent 8827e16 commit f89e3e9

File tree

4 files changed

+39
-11
lines changed

4 files changed

+39
-11
lines changed

src/ShortcodesServiceProvider.php

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
<?php namespace Webwizo\Shortcodes;
1+
<?php
22

3+
namespace Webwizo\Shortcodes;
4+
5+
use Webwizo\Shortcodes\View\Factory;
36
use Illuminate\Support\ServiceProvider;
47
use Webwizo\Shortcodes\Compilers\ShortcodeCompiler;
5-
use Webwizo\Shortcodes\View\Factory;
68

79
class ShortcodesServiceProvider extends ServiceProvider
810
{
@@ -17,13 +19,14 @@ public function boot()
1719
}
1820

1921
/**
20-
* Enable the compiler
22+
* Enable the compiler.
2123
*/
2224
public function enableCompiler()
2325
{
2426
// Check if the compiler is auto enabled
2527
$state = $this->app['config']->get('laravel-shortcodes::enabled', false);
26-
// enable when needed
28+
29+
// Enable when needed
2730
if ($state) {
2831
$this->app['shortcode.compiler']->enable();
2932
}
@@ -42,7 +45,7 @@ public function register()
4245
}
4346

4447
/**
45-
* Register short code compiler
48+
* Register short code compiler.
4649
*/
4750
public function registerShortcodeCompiler()
4851
{
@@ -52,7 +55,7 @@ public function registerShortcodeCompiler()
5255
}
5356

5457
/**
55-
* Register the shortcode
58+
* Register the shortcode.
5659
*/
5760
public function registerShortcode()
5861
{
@@ -62,17 +65,19 @@ public function registerShortcode()
6265
}
6366

6467
/**
65-
* Register Laravel view
68+
* Register Laravel view.
6669
*/
6770
public function registerView()
6871
{
69-
$this->app->singleton('view', function ($app) {
72+
$finder = $this->app['view']->getFinder();
73+
74+
$this->app->singleton('view', function ($app) use ($finder) {
7075
// Next we need to grab the engine resolver instance that will be used by the
7176
// environment. The resolver will be used by an environment to get each of
7277
// the various engine implementations such as plain PHP or Blade engine.
7378
$resolver = $app['view.engine.resolver'];
74-
$finder = $app['view.finder'];
7579
$env = new Factory($resolver, $finder, $app['events'], $app['shortcode.compiler']);
80+
7681
// We will also set the container instance on this view environment since the
7782
// view composers may be classes registered in the container, which allows
7883
// for great testable, flexible composers for the application developer.

tests/NamespaceTest.php

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Webwizo\Shortcodes;
4+
5+
use Orchestra\Testbench\TestCase;
6+
7+
class NamespaceTest extends TestCase
8+
{
9+
public function testShouldLoadPreviousNamespaces()
10+
{
11+
$factory = app('view')->getFinder();
12+
13+
app()->register('Webwizo\Shortcodes\ShortcodesServiceProvider');
14+
15+
$freshFactory = app('view')->getFinder();
16+
17+
$this->assertEquals($factory, $freshFactory);
18+
}
19+
}

tests/ShortcodeTest.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Webwizo\Shortcodes;
1+
<?php
2+
3+
namespace Webwizo\Shortcodes;
24

35
use Webwizo\Shortcodes\View\View;
46

tests/TestCase.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Webwizo\Shortcodes;
1+
<?php
2+
3+
namespace Webwizo\Shortcodes;
24

35
use Orchestra\Testbench\TestCase as TestBenchTestCase;
46

0 commit comments

Comments
 (0)