Skip to content

Commit

Permalink
[5.3] Allow passing a Closure to View::share() method (#15312)
Browse files Browse the repository at this point in the history
* [5.3] Allow passing a Closure to View::share() method

Allows you to pass a Closure as the $value parameter to View::share() method.

* Fix StyleCI
  • Loading branch information
memu authored and taylorotwell committed Sep 7, 2016
1 parent 3d44141 commit f971564
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Illuminate/View/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\View;

use Closure;
use Exception;
use Throwable;
use ArrayAccess;
Expand Down Expand Up @@ -161,6 +162,8 @@ protected function gatherData()
foreach ($data as $key => $value) {
if ($value instanceof Renderable) {
$data[$key] = $value->render();
} elseif ($value instanceof Closure) {
$data[$key] = call_user_func($value);
}
}

Expand Down

0 comments on commit f971564

Please sign in to comment.