Skip to content

Commit

Permalink
[9.x] De-couple Console component from framework (#44864)
Browse files Browse the repository at this point in the history
* Do not resolve mutator through app

* Check if app function exists
  • Loading branch information
driesvints authored Nov 7, 2022
1 parent 4846e5f commit e5398e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/Illuminate/Console/View/Components/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,14 @@ protected function compile($view, $data)
protected function mutate($data, $mutators)
{
foreach ($mutators as $mutator) {
$mutator = new $mutator;

if (is_iterable($data)) {
foreach ($data as $key => $value) {
$data[$key] = app($mutator)->__invoke($value);
$data[$key] = $mutator($value);
}
} else {
$data = app($mutator)->__invoke($data);
$data = $mutator($data);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class EnsureRelativePaths
*/
public function __invoke($string)
{
if (app()->has('path.base')) {
if (function_exists('app') && app()->has('path.base')) {
$string = str_replace(base_path().'/', '', $string);
}

Expand Down

0 comments on commit e5398e7

Please sign in to comment.