Skip to content

Commit 6021567

Browse files
committed
Remove Philo/Blade
1 parent 04d5705 commit 6021567

File tree

13 files changed

+214
-406
lines changed

13 files changed

+214
-406
lines changed

composer.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,16 @@
2020
],
2121
"autoload": {
2222
"psr-4": {
23-
"ACF_Gutenberg\\": "src/",
2423
"Roots\\Clover\\": "src/Clover"
2524
}
2625
},
27-
"repositories": [
28-
{
29-
"type": "vcs",
30-
"url": "[email protected]:40Q/Laravel-Blade.git"
31-
}
32-
],
3326
"require": {
3427
"php": ">=7.1",
3528
"composer/installers": "~1.0",
29+
"illuminate/view": "^5.7",
30+
"illuminate/events": "^5.7",
3631
"stoutlogic/acf-builder": "~1.6.1",
3732
"symfony/console": "^4.2",
38-
"philo/laravel-blade": "dev-bugfix",
3933
"vlucas/phpdotenv": "^3.4"
4034
},
4135
"require-dev": {

composer.lock

Lines changed: 2 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/class-ACF_Gutenberg.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ private function load_dependencies()
132132
*/
133133
require_once ACFGB_PATH . '/includes/class-i18n.php';
134134

135+
/**
136+
* The class responsible for managing Blade.
137+
*/
138+
require_once ACFGB_PATH . '/includes/class-Blade.php';
139+
135140
/**
136141
* The class responsible for defining all actions that occur in the admin area.
137142
*/

includes/class-Blade.php

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
<?php
2+
3+
namespace ACF_Gutenberg\Classes;
4+
5+
use Illuminate\Container\Container;
6+
use Illuminate\Events\Dispatcher;
7+
use Illuminate\Filesystem\Filesystem;
8+
use Illuminate\View\Engines\PhpEngine;
9+
use Illuminate\View\Engines\CompilerEngine;
10+
use Illuminate\View\Engines\EngineResolver;
11+
use Illuminate\View\Compilers\BladeCompiler;
12+
use Illuminate\View\FileViewFinder;
13+
use Illuminate\View\Factory;
14+
15+
class Blade
16+
{
17+
/**
18+
* Array containing paths where to look for blade files
19+
* @var array
20+
*/
21+
public $viewPaths;
22+
23+
/**
24+
* Location where to store cached views
25+
* @var string
26+
*/
27+
public $cachePath;
28+
29+
/**
30+
* @var Illuminate\Container\Container
31+
*/
32+
protected $container;
33+
34+
/**
35+
* @var Illuminate\View\Factory
36+
*/
37+
protected $instance;
38+
39+
/**
40+
* Initialize class
41+
* @param array $viewPaths
42+
* @param string $cachePath
43+
* @param Illuminate\Events\Dispatcher $events
44+
*/
45+
public function __construct($viewPaths = [], $cachePath, Dispatcher $events = null)
46+
{
47+
$this->container = new Container;
48+
49+
$this->viewPaths = (array) $viewPaths;
50+
51+
$this->cachePath = $cachePath;
52+
53+
$this->registerFilesystem();
54+
55+
$this->registerEvents($events ?: new Dispatcher);
56+
57+
$this->registerEngineResolver();
58+
59+
$this->registerViewFinder();
60+
61+
$this->instance = $this->registerFactory();
62+
}
63+
64+
public function view()
65+
{
66+
return $this->instance;
67+
}
68+
69+
public function registerFilesystem()
70+
{
71+
$this->container->singleton('files', function () {
72+
return new Filesystem;
73+
});
74+
}
75+
76+
public function registerEvents(Dispatcher $events)
77+
{
78+
$this->container->singleton('events', function () use ($events) {
79+
return $events;
80+
});
81+
}
82+
83+
/**
84+
* Register the engine resolver instance.
85+
*
86+
* @return void
87+
*/
88+
public function registerEngineResolver()
89+
{
90+
$me = $this;
91+
92+
$this->container->singleton('view.engine.resolver', function ($app) use ($me) {
93+
$resolver = new EngineResolver;
94+
95+
// Next we will register the various engines with the resolver so that the
96+
// environment can resolve the engines it needs for various views based
97+
// on the extension of view files. We call a method for each engines.
98+
foreach (['php', 'blade'] as $engine) {
99+
$me->{'register' . ucfirst($engine) . 'Engine'}($resolver);
100+
}
101+
102+
return $resolver;
103+
});
104+
}
105+
106+
/**
107+
* Register the PHP engine implementation.
108+
*
109+
* @param \Illuminate\View\Engines\EngineResolver $resolver
110+
* @return void
111+
*/
112+
public function registerPhpEngine($resolver)
113+
{
114+
$resolver->register('php', function () { return new PhpEngine; });
115+
}
116+
117+
/**
118+
* Register the Blade engine implementation.
119+
*
120+
* @param \Illuminate\View\Engines\EngineResolver $resolver
121+
* @return void
122+
*/
123+
public function registerBladeEngine($resolver)
124+
{
125+
$me = $this;
126+
$app = $this->container;
127+
128+
// The Compiler engine requires an instance of the CompilerInterface, which in
129+
// this case will be the Blade compiler, so we'll first create the compiler
130+
// instance to pass into the engine so it can compile the views properly.
131+
$this->container->singleton('blade.compiler', function ($app) use ($me) {
132+
$cache = $me->cachePath;
133+
134+
return new BladeCompiler($app['files'], $cache);
135+
});
136+
137+
$resolver->register('blade', function () use ($app) {
138+
return new CompilerEngine($app['blade.compiler'], $app['files']);
139+
});
140+
}
141+
142+
/**
143+
* Register the view finder implementation.
144+
*
145+
* @return void
146+
*/
147+
public function registerViewFinder()
148+
{
149+
$me = $this;
150+
$this->container->singleton('view.finder', function ($app) use ($me) {
151+
$paths = $me->viewPaths;
152+
153+
return new FileViewFinder($app['files'], $paths);
154+
});
155+
}
156+
157+
/**
158+
* Register the view environment.
159+
*
160+
* @return void
161+
*/
162+
public function registerFactory()
163+
{
164+
// Next we need to grab the engine resolver instance that will be used by the
165+
// environment. The resolver will be used by an environment to get each of
166+
// the various engine implementations such as plain PHP or Blade engine.
167+
$resolver = $this->container['view.engine.resolver'];
168+
169+
$finder = $this->container['view.finder'];
170+
171+
$env = new Factory($resolver, $finder, $this->container['events']);
172+
173+
// We will also set the container instance on this view environment since the
174+
// view composers may be classes registered in the container, which allows
175+
// for great testable, flexible composers for the application developer.
176+
$env->setContainer($this->container);
177+
178+
return $env;
179+
}
180+
181+
public function getCompiler()
182+
{
183+
return $this->container['blade.compiler'];
184+
}
185+
}

includes/class-Builder.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace ACF_Gutenberg\Includes;
1414

15-
use Philo\Blade\Blade;
15+
use ACF_Gutenberg\Classes\Blade;
1616
use ACF_Gutenberg\Lib;
1717
use function Roots\wp_die;
1818

@@ -68,7 +68,7 @@ class Builder
6868
*
6969
* @since 1.1.0
7070
* @access protected
71-
* @var Philo\Blade $blade blade object.
71+
* @var ACF_Gutenberg\Classes\Blade $blade blade object.
7272
*/
7373
protected $blade;
7474

@@ -79,9 +79,9 @@ class Builder
7979
* @access protected
8080
* @var object $compiler blade compiler.
8181
*/
82-
protected $compiler;
82+
protected $compiler;
8383

84-
protected $count;
84+
protected $count;
8585

8686
/**
8787
* Define the core functionality of the plugin.
@@ -100,8 +100,8 @@ public function __construct()
100100
$this->set_blocks_disabled();
101101
$this->load_blocks();
102102
$this->load_blade();
103-
$this->compile_components();
104-
$this->count = 0;
103+
$this->compile_components();
104+
$this->count = 0;
105105
}
106106

107107
/**
@@ -201,7 +201,7 @@ public function load_blocks()
201201
}
202202

203203
/**
204-
* Load blade by Philo\Blade
204+
* Load blade by ACF_Gutenberg\Classes\Blade
205205
*
206206
*
207207
* @since 1.1.0
@@ -293,7 +293,7 @@ public function register_field_group()
293293
acf_add_local_field_group($block_content);
294294
}
295295
}
296-
}
296+
}
297297
}
298298

299299
public function render_block($block)
@@ -354,20 +354,20 @@ public function get_components()
354354
* The reference to the class that compiler blocks and component using blade.
355355
*
356356
* @since 1.1.0
357-
* @return Philo\Blade compile blocks and components.
357+
* @return ACF_Gutenberg\Classes\Blade compile blocks and components.
358358
*/
359359
public function blade()
360360
{
361361
return $this->blade;
362-
}
363-
364-
/**
365-
* Increase Count
366-
*
367-
* @return void
368-
*/
369-
public function incrementValue()
370-
{
371-
$this->count++;
372-
}
362+
}
363+
364+
/**
365+
* Increase Count
366+
*
367+
* @return void
368+
*/
369+
public function incrementValue()
370+
{
371+
$this->count++;
372+
}
373373
}

vendor/composer/autoload_classmap.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,6 @@
366366
'Illuminate\\View\\ViewName' => $vendorDir . '/illuminate/view/ViewName.php',
367367
'Illuminate\\View\\ViewServiceProvider' => $vendorDir . '/illuminate/view/ViewServiceProvider.php',
368368
'JsonException' => $vendorDir . '/symfony/polyfill-php73/Resources/stubs/JsonException.php',
369-
'Philo\\Blade\\Blade' => $vendorDir . '/philo/laravel-blade/src/Blade.php',
370369
'PhpOption\\LazyOption' => $vendorDir . '/phpoption/phpoption/src/PhpOption/LazyOption.php',
371370
'PhpOption\\None' => $vendorDir . '/phpoption/phpoption/src/PhpOption/None.php',
372371
'PhpOption\\Option' => $vendorDir . '/phpoption/phpoption/src/PhpOption/Option.php',

0 commit comments

Comments
 (0)