Skip to content

Commit

Permalink
Make Illuminate\View\View Macroable. (#23787)
Browse files Browse the repository at this point in the history
* Make Illuminate\View\View Macroable.

* Update to use __call as macroCall to avoid conflict.
  • Loading branch information
DanielCoulbourne authored and taylorotwell committed Apr 3, 2018
1 parent 5c99e86 commit 42248fb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Illuminate/View/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@
use Illuminate\Support\Str;
use Illuminate\Support\MessageBag;
use Illuminate\Contracts\View\Engine;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Contracts\Support\MessageProvider;
use Illuminate\Contracts\View\View as ViewContract;

class View implements ArrayAccess, ViewContract
{
use Macroable {
__call as macroCall;
}

/**
* The view factory instance.
*
Expand Down Expand Up @@ -395,6 +400,10 @@ public function __unset($key)
*/
public function __call($method, $parameters)
{
if (static::hasMacro($method)) {
return $this->macroCall($method, $parameters);
}

if (! Str::startsWith($method, 'with')) {
throw new BadMethodCallException(sprintf(
'Method %s::%s does not exist.', static::class, $method
Expand Down

0 comments on commit 42248fb

Please sign in to comment.