Skip to content

Commit b1c88a5

Browse files
professorhaseebwebwizo
authored andcommitted
Updates for Laravel 5.6 (#30)
* update for laravel 5.6 * fix for laravel 5.6
1 parent f89e3e9 commit b1c88a5

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/Compilers/ShortcodeCompiler.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class ShortcodeCompiler
3737
* @var array
3838
*/
3939
protected $data = [];
40+
41+
protected $_viewData;
4042

4143
/**
4244
* Enable
@@ -139,6 +141,13 @@ protected function renderShortcodes($value)
139141

140142
return preg_replace_callback("/{$pattern}/s", [$this, 'render'], $value);
141143
}
144+
145+
// get view data
146+
public function viewData( $viewData )
147+
{
148+
$this->_viewData = $viewData;
149+
return $this;
150+
}
142151

143152
/**
144153
* Render the current calld shortcode.
@@ -152,14 +161,15 @@ public function render($matches)
152161
// Compile the shortcode
153162
$compiled = $this->compileShortcode($matches);
154163
$name = $compiled->getName();
164+
$viewData = $this->_viewData;
155165

156166
// Render the shortcode through the callback
157167
return call_user_func_array($this->getCallback($name), [
158168
$compiled,
159169
$compiled->getContent(),
160170
$this,
161171
$name,
162-
$this->getData()
172+
$viewData
163173
]);
164174
}
165175

src/View/View.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
use ArrayAccess;
44
use Illuminate\Contracts\Support\Renderable;
55
use Illuminate\View\View as IlluminateView;
6-
use Illuminate\Contracts\View\Engine as EngineInterface;
76
use Webwizo\Shortcodes\Compilers\ShortcodeCompiler;
7+
use Illuminate\View\Engines\CompilerEngine;
88

99
class View extends IlluminateView implements ArrayAccess, Renderable
1010
{
@@ -20,13 +20,13 @@ class View extends IlluminateView implements ArrayAccess, Renderable
2020
* Create a new view instance.
2121
*
2222
* @param \Illuminate\View\Factory|Factory $factory
23-
* @param \Illuminate\Contracts\View\Engine|EngineInterface $engine
23+
* @param \Illuminate\View\Compilers\CompilerEngine|CompilerEngine $engine
2424
* @param string $view
2525
* @param string $path
2626
* @param array $data
2727
* @param \Webwizo\Shortcodes\Compilers\ShortcodeCompiler $shortcode
2828
*/
29-
public function __construct(Factory $factory, EngineInterface $engine, $view, $path, $data = [], ShortcodeCompiler $shortcode)
29+
public function __construct(Factory $factory, CompilerEngine $engine, $view, $path, $data = [], ShortcodeCompiler $shortcode)
3030
{
3131
parent::__construct($factory, $engine, $view, $path, $data);
3232
$this->shortcode = $shortcode;
@@ -39,8 +39,6 @@ public function withShortcodes()
3939
{
4040
$this->shortcode->enable();
4141

42-
$this->shortcode->attachData($this->getData());
43-
4442
return $this;
4543
}
4644

0 commit comments

Comments
 (0)