sunnysideup /
silverstripe-cms-niceties
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Sunnysideup\CMSNiceties\Extensions; |
||||
| 4 | |||||
| 5 | use Sunnysideup\CMSNiceties\Interfaces\BrandColourProvider; |
||||
| 6 | |||||
| 7 | use SilverStripe\Admin\LeftAndMain; |
||||
| 8 | use SilverStripe\Core\ClassInfo; |
||||
| 9 | use SilverStripe\Core\Extension; |
||||
| 10 | use SilverStripe\View\Requirements; |
||||
| 11 | |||||
| 12 | /** |
||||
| 13 | * Class \Sunnysideup\CMSNiceties\Extensions\LeftAndMainExtension. |
||||
| 14 | * |
||||
| 15 | * @property LeftAndMainExtension $owner |
||||
| 16 | */ |
||||
| 17 | class LeftAndMainExtension extends Extension |
||||
| 18 | { |
||||
| 19 | public function init() |
||||
| 20 | { |
||||
| 21 | Requirements::add_i18n_javascript('sunnysideup/cms-niceties: client/lang'); |
||||
|
0 ignored issues
–
show
Deprecated Code
introduced
by
Loading history...
|
|||||
| 22 | } |
||||
| 23 | |||||
| 24 | private static array $brand_colours = [ |
||||
| 25 | 'Light' => '', |
||||
| 26 | 'Dark' => '', |
||||
| 27 | 'Font' => '', |
||||
| 28 | ]; |
||||
| 29 | |||||
| 30 | public function updateClientConfig($clientConfig) |
||||
| 31 | { |
||||
| 32 | $brandColourProviders = ClassInfo::implementorsOf(BrandColourProvider::class); |
||||
| 33 | if($brandColourProviders) { |
||||
|
0 ignored issues
–
show
The expression
$brandColourProviders of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using Loading history...
|
|||||
| 34 | foreach($brandColourProviders as $provider) { |
||||
| 35 | $providerInstance = new $provider(); |
||||
| 36 | $brandColours = $providerInstance->getBrandColours(); |
||||
| 37 | if($brandColours) { |
||||
| 38 | $clientConfig['brand_colours'] = $brandColours; |
||||
| 39 | break; |
||||
| 40 | } |
||||
| 41 | } |
||||
| 42 | } else { |
||||
| 43 | $clientConfig['brand_colours'] = $this->owner->config()->get('brand_colours'); |
||||
|
0 ignored issues
–
show
The method
config() does not exist on Sunnysideup\CMSNiceties\...ns\LeftAndMainExtension.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||
| 44 | } |
||||
| 45 | $light = $clientConfig['brand_colours']['Light'] ?? ''; |
||||
| 46 | $dark = $clientConfig['brand_colours']['Dark'] ?? ''; |
||||
| 47 | $font = $clientConfig['brand_colours']['Font'] ?? ''; |
||||
| 48 | if ($light && $dark && $font) { |
||||
| 49 | Requirements::customCSS( |
||||
| 50 | ' |
||||
| 51 | #cms-menu, |
||||
| 52 | #cms-menu *, |
||||
| 53 | #cms-menu a:link, |
||||
| 54 | #cms-menu a:visited, |
||||
| 55 | #cms-menu input::placeholder, |
||||
| 56 | #cms-menu .flexbox-area-grow |
||||
| 57 | { |
||||
| 58 | background-color: ' . $light . '; |
||||
| 59 | color: ' . $font . '; |
||||
| 60 | border-color: #fff; |
||||
| 61 | } |
||||
| 62 | #cms-menu .cms-menu__list > li.current.children > a, |
||||
| 63 | #cms-menu .cms-menu__list > li.current.children > a * { |
||||
| 64 | background-color: ' . $dark . '!important; |
||||
| 65 | color: #fff!important; |
||||
| 66 | } |
||||
| 67 | #cms-menu .cms-menu__list > .current.children, |
||||
| 68 | #cms-menu .cms-menu__list > .current.children *, |
||||
| 69 | #cms-menu .cms-menu__list > .link.children > a, |
||||
| 70 | #cms-menu .cms-menu__list > .link.children > a { |
||||
| 71 | background-color: ' . $light . '!important; |
||||
| 72 | color: ' . $font . '!important; |
||||
| 73 | } |
||||
| 74 | #cms-menu .cms-menu__header, |
||||
| 75 | #cms-menu .cms-menu__header *, |
||||
| 76 | #cms-menu .cms-menu__header .cms-sitename, |
||||
| 77 | #cms-menu .cms-menu__header .cms-login-status, |
||||
| 78 | #cms-menu .toolbar, |
||||
| 79 | #cms-menu .toolbar * { |
||||
| 80 | background-color: ' . $dark . '!important; |
||||
| 81 | color: #fff!important; |
||||
| 82 | } |
||||
| 83 | |||||
| 84 | #cms-menu li a:hover { |
||||
| 85 | filter: brightness(110%); |
||||
| 86 | } |
||||
| 87 | #cms-menu li.current a { |
||||
| 88 | filter: brightness(105%); |
||||
| 89 | } |
||||
| 90 | .breadcrumbs-wrapper, |
||||
| 91 | .breadcrumbs-wrapper * |
||||
| 92 | { |
||||
| 93 | color: ' . $dark . '; |
||||
| 94 | } |
||||
| 95 | |||||
| 96 | |||||
| 97 | ', |
||||
| 98 | 'LeftAndMainExtensionCMSNiceties' |
||||
| 99 | ); |
||||
| 100 | } |
||||
| 101 | } |
||||
| 102 | } |
||||
| 103 |