-
-
Notifications
You must be signed in to change notification settings - Fork 540
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix custom logo when using arrays with null (#3408)
- Loading branch information
1 parent
7a74fc4
commit 4f6ada5
Showing
4 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Statamic\Http\View\Composers; | ||
|
||
use Illuminate\View\View; | ||
use Statamic\Statamic; | ||
use Statamic\Support\Arr; | ||
|
||
class CustomLogoComposer | ||
{ | ||
const VIEWS = [ | ||
'statamic::partials.global-header', | ||
'statamic::partials.outside-logo', | ||
]; | ||
|
||
public function compose(View $view) | ||
{ | ||
$view->with('customLogo', $this->customLogo($view)); | ||
} | ||
|
||
protected function customLogo($view) | ||
{ | ||
if (! Statamic::pro()) { | ||
return false; | ||
} | ||
|
||
$config = config('statamic.cp.custom_logo_url'); | ||
|
||
switch ($view->name()) { | ||
case 'statamic::partials.outside-logo': | ||
$type = 'outside'; | ||
break; | ||
case 'statamic::partials.global-header': | ||
$type = 'nav'; | ||
break; | ||
default: | ||
$type = 'other'; | ||
} | ||
|
||
if ($logo = Arr::get($config, $type)) { | ||
return $logo; | ||
} | ||
|
||
if (! is_array($config)) { | ||
return $config; | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters