From c0af692a1b38ea0a346b9c0437c121f477003146 Mon Sep 17 00:00:00 2001 From: Olawale Lawal Date: Fri, 27 Jul 2018 11:57:11 +0100 Subject: [PATCH 1/5] (BaseWidget): Add `beginDiv` and `endDiv` (Widget): Add `EmptyStateWidget`, `BaseContentHeaderButton`, `ContentHeaderWidget` (ActiveFormModalWidget): Extract buttons' classes as fields --- src/Helpers/Html.php | 22 ++++++- src/Widgets/ActionButtons.php | 6 +- src/Widgets/BaseContentHeaderButton.php | 56 ++++++++++++++++ src/Widgets/BaseFormWidget.php | 5 +- src/Widgets/BaseModalWidget.php | 3 +- src/Widgets/BaseWidget.php | 17 +++++ src/Widgets/ContentHeaderWidget.php | 69 ++++++++++++++++++++ src/Widgets/DropzoneWidget.php | 22 +++---- src/Widgets/EmptyStateWidget.php | 58 ++++++++++++++++ src/Widgets/GridViewWidget.php | 1 + src/Widgets/Modals/ActiveFormModalWidget.php | 11 ++-- src/Widgets/Modals/ConfirmModalWidget.php | 13 +++- 12 files changed, 254 insertions(+), 29 deletions(-) create mode 100644 src/Widgets/BaseContentHeaderButton.php create mode 100644 src/Widgets/ContentHeaderWidget.php create mode 100644 src/Widgets/EmptyStateWidget.php diff --git a/src/Helpers/Html.php b/src/Helpers/Html.php index 3386274..f543732 100644 --- a/src/Helpers/Html.php +++ b/src/Helpers/Html.php @@ -104,12 +104,30 @@ public static function svgImg($src, $options = []) if (is_bool($fallback) && is_string($src)) { $fallback = rtrim($src, 'svg') . $fallbackExt; $options['onerror'] = "this.src = '$fallback'; this.onerror = '';"; - } - else if (is_string($fallback)) { + } else if (is_string($fallback)) { $options['onerror'] = "this.src = '$fallback'; this.onerror = '';"; } } return self::img($src, $options); } + + /** + * @param array|string $classNames + * @param array $options + * @return string + */ + public static function beginDiv($classNames = [], $options = []) + { + self::addCssClass($options, $classNames); + return self::beginTag('div', $options) . "\n"; + } + + /** + * @return string + */ + public static function endDiv() + { + return self::endTag('div') . "\n"; + } } diff --git a/src/Widgets/ActionButtons.php b/src/Widgets/ActionButtons.php index 7697a1b..25dff7d 100644 --- a/src/Widgets/ActionButtons.php +++ b/src/Widgets/ActionButtons.php @@ -38,7 +38,7 @@ class ActionButtons extends BaseWidget /** * @var string the actions button dropdown label */ - public $actionsButtonLabel = 'Actions'; + public $actionsButtonLabel = 'Actions '; /** * @var string caret html for the action button */ @@ -152,14 +152,14 @@ private function renderActionButton() private function beginButtonGroup() { if ($this->groupLinks) { - echo Html::beginTag('div', ['class' => 'btn-group']); + echo $this->beginDiv('btn-group'); } } private function endButtonGroup() { if ($this->groupLinks) { - echo Html::endTag('div'); + echo $this->endDiv(); } } } diff --git a/src/Widgets/BaseContentHeaderButton.php b/src/Widgets/BaseContentHeaderButton.php new file mode 100644 index 0000000..72317b7 --- /dev/null +++ b/src/Widgets/BaseContentHeaderButton.php @@ -0,0 +1,56 @@ + + * @package app\widgets + */ +class BaseContentHeaderButton extends BaseWidget +{ + public $button; + public $buttonClass; + + protected function setButton() + { + if (is_string($this->button)) { + return; + } + if (is_array($this->button)) { + $this->buildButton($this->button); + return; + } + + $buttonDetails = ArrayHelper::getValue($this->view->params, 'content-header-button', ''); + if (is_string($buttonDetails)) { + $this->button = $buttonDetails; + return; + } + $this->buildButton($buttonDetails); + } + + private function buildButton($buttonArray) + { + if (!is_array($buttonArray)) { + return; + } + + $text = ArrayHelper::getValue($buttonArray, 'label', 'Add New'); + $tag = ArrayHelper::getValue($buttonArray, 'tag', 'a'); + $iconName = ArrayHelper::getValue($buttonArray, 'icon', 'plus'); + $icon = ''; + if ($iconName) { + $icon = Html::faIcon($iconName); + } + $options = ArrayHelper::getValue($buttonArray, 'options', []); + + Html::addCssClass($options, $this->buttonClass); + + $this->button = Html::tag($tag, "$icon $text", $options); + + } +} diff --git a/src/Widgets/BaseFormWidget.php b/src/Widgets/BaseFormWidget.php index 436e5ca..ccbc061 100644 --- a/src/Widgets/BaseFormWidget.php +++ b/src/Widgets/BaseFormWidget.php @@ -2,7 +2,6 @@ namespace CottaCush\Yii2\Widgets; -use yii\base\Widget; use yii\helpers\Html; use yii\helpers\Url; @@ -11,11 +10,11 @@ * @author Damilola Olaleye * @package CottaCush\Yii2\Widgets */ -class BaseFormWidget extends Widget +class BaseFormWidget extends BaseWidget { public $formRoute; public $formOptions = []; - public $formMethod ='post'; + public $formMethod = 'post'; public function run() { diff --git a/src/Widgets/BaseModalWidget.php b/src/Widgets/BaseModalWidget.php index fb5345c..fb01fc8 100644 --- a/src/Widgets/BaseModalWidget.php +++ b/src/Widgets/BaseModalWidget.php @@ -19,6 +19,7 @@ class BaseModalWidget extends BaseWidget public $id; public $route; public $footerSubmit; + public $footerCancel; public $formMethod; public $formOptions; public $modalHeaderClass; @@ -45,7 +46,7 @@ public function beginModal() 'id' => $this->id ], 'footer' => - Html::button('Cancel', ['class' => $this->modalCancelFooterClass, 'data-dismiss' => 'modal']) . + Html::button($this->footerCancel, ['class' => $this->modalCancelFooterClass, 'data-dismiss' => 'modal']) . Html::input( 'submit', '', diff --git a/src/Widgets/BaseWidget.php b/src/Widgets/BaseWidget.php index 451febb..8119426 100644 --- a/src/Widgets/BaseWidget.php +++ b/src/Widgets/BaseWidget.php @@ -2,6 +2,7 @@ namespace CottaCush\Yii2\Widgets; +use CottaCush\Yii2\Helpers\Html; use yii\base\Widget; /** @@ -12,5 +13,21 @@ */ class BaseWidget extends Widget { + /** + * @param array|string $classNames + * @param array $options + * @return string + */ + protected function beginDiv($classNames = [], $options = []) + { + return Html::beginDiv($classNames, $options); + } + /** + * @return string + */ + protected function endDiv() + { + return Html::endDiv(); + } } diff --git a/src/Widgets/ContentHeaderWidget.php b/src/Widgets/ContentHeaderWidget.php new file mode 100644 index 0000000..9877bf4 --- /dev/null +++ b/src/Widgets/ContentHeaderWidget.php @@ -0,0 +1,69 @@ + + * @package CottaCush\Yii2\Widgets + */ +class ContentHeaderWidget extends BaseContentHeaderButton +{ + public $title; + public $breadcrumbs; + public $buttonClass = 'btn btn-sm content-header-btn'; + public $contentRight; + public $icon; + + public function init() + { + parent::init(); + + $view = $this->view; + + if (is_null($this->title)) { + $this->title = isset($view->params['pageTitle']) ? $view->params['pageTitle'] : $view->title; + } + if (is_null($this->breadcrumbs)) { + $this->breadcrumbs = isset($view->params['breadcrumbs']) ? $view->params['breadcrumbs'] : [$this->title]; + } + if (is_null($this->contentRight)) { + $this->contentRight = isset($view->params['contentHeaderRight']) ? $view->params['contentHeaderRight'] : ''; + } + + $this->setButton(); + } + + public function run() + { + echo Html::beginTag('section', ['class' => 'content-header']); + echo $this->beginDiv(' clearfix'); + echo $this->beginDiv(' content-header__left'); + echo Html::beginTag('h1', ['class' => 'content-header-title']); + + echo ($this->icon) ? Html::faIcon($this->icon) . ' ' . $this->title : $this->title; + + echo Html::endTag('h1'); + + echo $this->endDiv(); + echo Html::tag('div', $this->contentRight, ['class' => 'content-header__right']); + if (ArrayHelper::getValue($this->view->params, 'show-content-header-button', true)) { + echo $this->button; + } + echo $this->endDiv(); + echo Breadcrumbs::widget([ + 'tag' => 'ol', + 'homeLink' => [ + 'label' => 'Home', + 'url' => Url::toRoute('/') + ], + 'links' => $this->breadcrumbs + ]); + echo Html::endTag('section'); + } +} diff --git a/src/Widgets/DropzoneWidget.php b/src/Widgets/DropzoneWidget.php index d39491e..ffe1163 100644 --- a/src/Widgets/DropzoneWidget.php +++ b/src/Widgets/DropzoneWidget.php @@ -3,7 +3,6 @@ namespace CottaCush\Yii2\Widgets; use CottaCush\Yii2\Assets\DropzoneImageUploadAsset; -use yii\base\Widget; use yii\helpers\Html; /** @@ -22,7 +21,7 @@ * * @author Adeyemi Olaoye */ -class DropzoneWidget extends Widget +class DropzoneWidget extends BaseWidget { public $imageUrl = null; public $uploadUrl; @@ -47,9 +46,9 @@ public function init() public function run() { - echo Html::beginTag('div', ['class' => 'clearfix']); + echo $this->beginDiv('clearfix'); - echo Html::beginTag('div', ['class' => 'dropzone-placeholder']); + echo $this->beginDiv('dropzone-placeholder'); $placeholderImage = Html::img($this->imageUrl, ['class' => 'img-responsive dropzone-placeholder__image']); $removeImageLabel = Html::a($this->removeImageLabel, '#', [ @@ -71,7 +70,8 @@ public function run() ] ); - echo Html::endTag('div'); + echo $this->endDiv(); //.dropzone-placeholder + echo $this->endDiv(); //.clearfix echo Html::script('var dropzoneOptions =' . json_encode([ @@ -88,20 +88,20 @@ public function run() private function getDefaultPreviewTemplate() { - $previewTemplate = Html::beginTag('div', ['class' => 'dz-preview dz-image-preview']); - $previewTemplate .= Html::beginTag('div', ['class' => 'dz-image']); + $previewTemplate = $this->beginDiv('dz-preview dz-image-preview'); + $previewTemplate .= $this->beginDiv('dz-image'); $previewTemplate .= Html::img('', ['data-dz-thumbnail' => '']); - $previewTemplate .= Html::endTag('div'); - $previewTemplate .= Html::beginTag('div', ['class' => 'dz-error-message']); + $previewTemplate .= $this->endDiv(); + $previewTemplate .= $this->beginDiv('dz-error-message'); $previewTemplate .= Html::tag('span', '', ['data-dz-errormessage' => '']); - $previewTemplate .= Html::endTag('div'); + $previewTemplate .= $this->endDiv(); $previewTemplate .= Html::tag( 'span', '', ['id' => 'dropzone_upload_info', 'class' => 'text-center dropzone_upload_info'] ); $previewTemplate .= Html::tag('a', '', ['class' => 'dz-remove', 'data-dz-remove']); - $previewTemplate .= Html::endTag('div'); + $previewTemplate .= $this->endDiv(); return $previewTemplate; } } diff --git a/src/Widgets/EmptyStateWidget.php b/src/Widgets/EmptyStateWidget.php new file mode 100644 index 0000000..6972242 --- /dev/null +++ b/src/Widgets/EmptyStateWidget.php @@ -0,0 +1,58 @@ + + * @author Olawale Lawal + */ +class EmptyStateWidget extends BaseContentHeaderButton +{ + public $icon; + public $title; + public $description; + public $buttonClass = 'btn btn-primary'; + public $showContentHeader = true; + public $showContentHeaderButton = true; + public $showButton = true; + + public function init() + { + parent::init(); + $view = $this->view; + + $view->params['show-content-header'] = $this->showContentHeader; + $view->params['show-content-header-button'] = $this->showContentHeaderButton; + + if (is_null($this->button)) { + $this->button = ArrayHelper::getValue($view->params, 'content-header-button', true); + } + + if ($this->showButton) { + $this->setButton(); + } + + FontAwesomeAsset::register($this->view); + } + + public function run() + { + echo Html::beginTag('section', ['class' => 'empty-state']); + + echo Html::faIcon($this->icon, ['class' => 'empty-state__icon']); + echo Html::tag('h2', $this->title, ['class' => 'empty-state__title']); + echo Html::tag('p', $this->description, ['class' => 'empty-state__description']); + + if ($this->showButton) { + echo Html::tag('div', $this->button, ['class' => 'empty-state__btn']); + } + + echo Html::endTag('section'); + } +} diff --git a/src/Widgets/GridViewWidget.php b/src/Widgets/GridViewWidget.php index 732756c..d73fa56 100644 --- a/src/Widgets/GridViewWidget.php +++ b/src/Widgets/GridViewWidget.php @@ -34,6 +34,7 @@ private function setupDefaultConfigs() { $this->setLayout(); $this->setSummary(); + if (!$this->isEmpty()) { $this->setActionBar(); } diff --git a/src/Widgets/Modals/ActiveFormModalWidget.php b/src/Widgets/Modals/ActiveFormModalWidget.php index 72ddd42..19d335f 100644 --- a/src/Widgets/Modals/ActiveFormModalWidget.php +++ b/src/Widgets/Modals/ActiveFormModalWidget.php @@ -22,12 +22,8 @@ class ActiveFormModalWidget extends BaseModalWidget */ public $populateFields = false; - public function init() - { - $this->modalCancelFooterClass = 'btn'; - $this->modalSubmitFooterClass = 'btn btn-primary'; - parent::init(); - } + public $modalCancelFooterClass = 'btn btn-default'; + public $modalSubmitFooterClass = 'btn btn-primary'; public function beginForm() { @@ -41,11 +37,12 @@ public function endForm() public function endModal() { - parent::endModal(); if ($this->populateFields) { $this->view->registerJs( "App.Components.Modal.populateModal('#" . $this->id . "','" . $this->model->formName() . "');" ); } + + parent::endModal(); } } diff --git a/src/Widgets/Modals/ConfirmModalWidget.php b/src/Widgets/Modals/ConfirmModalWidget.php index ac45d44..1e4ddfd 100644 --- a/src/Widgets/Modals/ConfirmModalWidget.php +++ b/src/Widgets/Modals/ConfirmModalWidget.php @@ -20,6 +20,9 @@ class ConfirmModalWidget extends BaseModalWidget public $formMethod = 'post'; public $formOptions = ['class' => 'disable-submit-buttons']; + public $modalSubmitFooterClass = 'btn btn-danger'; + public $modalCancelFooterClass = 'btn btn-default'; + public function beginModal() { Modal::begin([ @@ -28,8 +31,14 @@ public function beginModal() 'id' => $this->modalId, 'data-generic-modal' => 'true' ], - 'footer' => Html::button($this->footerCancel, ['class' => 'btn btn-default', 'data-dismiss' => 'modal']) . - Html::submitButton($this->footerSubmit, ['class' => 'btn btn-danger', 'data-submit-modal-form' => '']) + 'footer' => Html::button( + $this->footerCancel, + ['class' => $this->modalCancelFooterClass, 'data-dismiss' => 'modal'] + ) . + Html::submitButton( + $this->footerSubmit, + ['class' => $this->modalSubmitFooterClass, 'data-submit-modal-form' => true] + ) ]); } From e10d8a37c1a6630d52b07199b8b987f84c60b42c Mon Sep 17 00:00:00 2001 From: Olawale Lawal Date: Fri, 27 Jul 2018 12:37:47 +0100 Subject: [PATCH 2/5] (BaseWidget): Cleanup --- src/Widgets/BaseContentHeaderButton.php | 2 +- src/Widgets/BaseModalWidget.php | 9 +++++---- src/Widgets/Modals/ActiveFormModalWidget.php | 3 --- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Widgets/BaseContentHeaderButton.php b/src/Widgets/BaseContentHeaderButton.php index 72317b7..e28468a 100644 --- a/src/Widgets/BaseContentHeaderButton.php +++ b/src/Widgets/BaseContentHeaderButton.php @@ -41,7 +41,7 @@ private function buildButton($buttonArray) $text = ArrayHelper::getValue($buttonArray, 'label', 'Add New'); $tag = ArrayHelper::getValue($buttonArray, 'tag', 'a'); - $iconName = ArrayHelper::getValue($buttonArray, 'icon', 'plus'); + $iconName = ArrayHelper::getValue($buttonArray, 'icon'); $icon = ''; if ($iconName) { $icon = Html::faIcon($iconName); diff --git a/src/Widgets/BaseModalWidget.php b/src/Widgets/BaseModalWidget.php index fb01fc8..91a3b84 100644 --- a/src/Widgets/BaseModalWidget.php +++ b/src/Widgets/BaseModalWidget.php @@ -18,13 +18,14 @@ class BaseModalWidget extends BaseWidget public $title; public $id; public $route; - public $footerSubmit; - public $footerCancel; + public $footerSubmit = 'Submit'; + public $footerCancel = 'Cancel'; public $formMethod; public $formOptions; public $modalHeaderClass; - public $modalCancelFooterClass; - public $modalSubmitFooterClass; + public $modalCancelFooterClass = 'btn btn-default'; + public $modalSubmitFooterClass = 'btn btn-primary'; + /** @var ActiveForm $form */ protected $form; diff --git a/src/Widgets/Modals/ActiveFormModalWidget.php b/src/Widgets/Modals/ActiveFormModalWidget.php index 19d335f..f856fac 100644 --- a/src/Widgets/Modals/ActiveFormModalWidget.php +++ b/src/Widgets/Modals/ActiveFormModalWidget.php @@ -22,9 +22,6 @@ class ActiveFormModalWidget extends BaseModalWidget */ public $populateFields = false; - public $modalCancelFooterClass = 'btn btn-default'; - public $modalSubmitFooterClass = 'btn btn-primary'; - public function beginForm() { $this->form = ActiveForm::begin(['action' => $this->route, 'method' => $this->formMethod]); From a1f11327311ee2685be5e2604f0a1f9c29907ecb Mon Sep 17 00:00:00 2001 From: Olawale Lawal Date: Fri, 27 Jul 2018 13:20:27 +0100 Subject: [PATCH 3/5] (EmptyStateWidget): Extract the assets --- src/Assets/EmptyStateAsset.php | 15 +++++++++ src/Widgets/EmptyStateWidget.php | 2 ++ src/public-assets/css/empty-state.css | 40 +++++++++++++++++++++++ src/public-assets/less/empty-state.less | 43 +++++++++++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 src/Assets/EmptyStateAsset.php create mode 100644 src/public-assets/css/empty-state.css create mode 100644 src/public-assets/less/empty-state.less diff --git a/src/Assets/EmptyStateAsset.php b/src/Assets/EmptyStateAsset.php new file mode 100644 index 0000000..829ba42 --- /dev/null +++ b/src/Assets/EmptyStateAsset.php @@ -0,0 +1,15 @@ + + */ +class EmptyStateAsset extends LocalAssetBundle +{ + public $css = [ + 'css/empty-state.css', + ]; +} diff --git a/src/Widgets/EmptyStateWidget.php b/src/Widgets/EmptyStateWidget.php index 6972242..296d1e0 100644 --- a/src/Widgets/EmptyStateWidget.php +++ b/src/Widgets/EmptyStateWidget.php @@ -2,6 +2,7 @@ namespace CottaCush\Yii2\Widgets; +use CottaCush\Yii2\Assets\EmptyStateAsset; use CottaCush\Yii2\Assets\FontAwesomeAsset; use CottaCush\Yii2\Helpers\Html; use yii\helpers\ArrayHelper; @@ -54,5 +55,6 @@ public function run() } echo Html::endTag('section'); + EmptyStateAsset::register($this->getView()); } } diff --git a/src/public-assets/css/empty-state.css b/src/public-assets/css/empty-state.css new file mode 100644 index 0000000..48fdd0e --- /dev/null +++ b/src/public-assets/css/empty-state.css @@ -0,0 +1,40 @@ +.empty-state { + min-height: 400px; + padding: 40px 0 100px; + text-align: center; +} + +.empty-state__icon { + display: inline-block; + width: 160px; + height: 160px; + margin: 0 auto; + padding: 38px 0; + font-size: 80px; + line-height: 1; + color: #999; + border: 2px solid #ccc; + border-radius: 50%; +} + +.empty-state__title { + font-size: 36px; + margin: 20px 0 15px; + color: #1e4e4e; +} + +.empty-state__description { + margin: 0 auto 40px; + font-size: 18px; + line-height: 1.3333333; + color: #666; +} + +.empty-state__btn .btn { + padding: 7px 16px; + font-size: 16px; + line-height: 1.3333333; + border-radius: 4px; +} + +/*# sourceMappingURL=maps/dropzone-image-upload.css.map */ diff --git a/src/public-assets/less/empty-state.less b/src/public-assets/less/empty-state.less new file mode 100644 index 0000000..6af4a52 --- /dev/null +++ b/src/public-assets/less/empty-state.less @@ -0,0 +1,43 @@ +//EMPTY STATE +//-------------------------------------------------------- + +.empty-state { + min-height: 400px; + padding: 40px 0 100px; + text-align: center; + + &__icon { + display: inline-block; + width: 160px; + height: 160px; + margin: 0 auto; + padding: 38px 0; + font-size: 80px; + line-height: 1; + color: #999; + border: 2px solid #ccc; + border-radius: 50%; + } + + &__title { + font-size: 36px; + margin: 20px 0 15px; + color: #1e4e4e; + } + + &__description { + margin: 0 auto 40px; + font-size: 18px; + line-height: 1.3333333; + color: #666; + } + + &__btn { + .btn { + padding: 7px 16px; + font-size: 16px; + line-height: 1.3333333; + border-radius: 4px; + } + } +} From 6b4e5dd35847e1d74f51e119c406de80f884733b Mon Sep 17 00:00:00 2001 From: Olawale Lawal Date: Fri, 27 Jul 2018 13:36:41 +0100 Subject: [PATCH 4/5] (EmptyStateWidget): Extract the assets --- src/Widgets/EmptyStateWidget.php | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/src/Widgets/EmptyStateWidget.php b/src/Widgets/EmptyStateWidget.php index 296d1e0..1eb753f 100644 --- a/src/Widgets/EmptyStateWidget.php +++ b/src/Widgets/EmptyStateWidget.php @@ -5,7 +5,6 @@ use CottaCush\Yii2\Assets\EmptyStateAsset; use CottaCush\Yii2\Assets\FontAwesomeAsset; use CottaCush\Yii2\Helpers\Html; -use yii\helpers\ArrayHelper; /** * Class EmptyStateWidget @@ -13,34 +12,15 @@ * @author Olajide Oye * @author Olawale Lawal */ -class EmptyStateWidget extends BaseContentHeaderButton +class EmptyStateWidget extends BaseWidget { public $icon; public $title; public $description; public $buttonClass = 'btn btn-primary'; - public $showContentHeader = true; - public $showContentHeaderButton = true; - public $showButton = true; - - public function init() - { - parent::init(); - $view = $this->view; - - $view->params['show-content-header'] = $this->showContentHeader; - $view->params['show-content-header-button'] = $this->showContentHeaderButton; - - if (is_null($this->button)) { - $this->button = ArrayHelper::getValue($view->params, 'content-header-button', true); - } - - if ($this->showButton) { - $this->setButton(); - } - FontAwesomeAsset::register($this->view); - } + public $showButton = true; + public $button; public function run() { @@ -55,6 +35,8 @@ public function run() } echo Html::endTag('section'); + EmptyStateAsset::register($this->getView()); + FontAwesomeAsset::register($this->view); } } From 1860eaa342a179b74f3551e552eedf66143fd78f Mon Sep 17 00:00:00 2001 From: Olawale Lawal Date: Fri, 27 Jul 2018 13:49:05 +0100 Subject: [PATCH 5/5] (EmptyStateWidget): Extract the assets --- src/Widgets/ContentHeaderWidget.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Widgets/ContentHeaderWidget.php b/src/Widgets/ContentHeaderWidget.php index 9877bf4..2be69c7 100644 --- a/src/Widgets/ContentHeaderWidget.php +++ b/src/Widgets/ContentHeaderWidget.php @@ -27,13 +27,13 @@ public function init() $view = $this->view; if (is_null($this->title)) { - $this->title = isset($view->params['pageTitle']) ? $view->params['pageTitle'] : $view->title; + $this->title = ArrayHelper::getValue($view, 'params.pageTitle', $view->title); } if (is_null($this->breadcrumbs)) { - $this->breadcrumbs = isset($view->params['breadcrumbs']) ? $view->params['breadcrumbs'] : [$this->title]; + $this->breadcrumbs = ArrayHelper::getValue($view, 'params.breadcrumbs', $this->title); } if (is_null($this->contentRight)) { - $this->contentRight = isset($view->params['contentHeaderRight']) ? $view->params['contentHeaderRight'] : ''; + $this->contentRight = ArrayHelper::getValue($view, 'params.contentHeaderRight', ''); } $this->setButton();