-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable the output of the toolbar ajax query when the toolbar is disa…
…bled
- Loading branch information
Showing
12 changed files
with
106 additions
and
74 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
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
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
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,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Smile\DebugToolbar\ViewModel; | ||
|
||
use Magento\Framework\View\Element\Block\ArgumentInterface; | ||
use Smile\DebugToolbar\Helper\Config as ConfigHelper; | ||
use Smile\DebugToolbar\Helper\Data as DataHelper; | ||
|
||
class Toolbar implements ArgumentInterface | ||
{ | ||
protected DataHelper $dataHelper; | ||
protected ConfigHelper $configHelper; | ||
|
||
public function __construct(DataHelper $dataHelper, ConfigHelper $configHelper) | ||
{ | ||
$this->dataHelper = $dataHelper; | ||
$this->configHelper = $configHelper; | ||
} | ||
|
||
/** | ||
* Check whether the module is enabled. | ||
*/ | ||
public function isToolbarEnabled(): bool | ||
{ | ||
return $this->configHelper->isEnabled(); | ||
} | ||
|
||
/** | ||
* Get the toolbars list. | ||
* | ||
* @return string[] | ||
*/ | ||
public function getToolbarList(): array | ||
{ | ||
return $this->dataHelper->getContentToolbars(); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,10 @@ | ||
<?xml version="1.0"?> | ||
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd"> | ||
<container name="root" label="Root"> | ||
<block class="Smile\DebugToolbar\Block\Toolbars" name="smile_debug_toolbar_toolbars" template="Smile_DebugToolbar::toolbars.phtml" cacheable="false"/> | ||
<block class="Smile\DebugToolbar\Block\Toolbars" name="smile_debug_toolbar_toolbars" template="Smile_DebugToolbar::toolbars.phtml" cacheable="false"> | ||
<arguments> | ||
<argument name="viewModel" xsi:type="object">Smile\DebugToolbar\ViewModel\Toolbar</argument> | ||
</arguments> | ||
</block> | ||
</container> | ||
</layout> |
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 |
---|---|---|
@@ -1,21 +1,28 @@ | ||
<?php | ||
|
||
use Smile\DebugToolbar\Block\Toolbars; | ||
use Magento\Framework\View\Element\Template; | ||
use Smile\DebugToolbar\ViewModel\Toolbar; | ||
|
||
/** @var Toolbars $block */ | ||
$toolbars = $block->getToolbarList(); | ||
foreach ($toolbars as $toolbarContent): ?> | ||
<?= /* @noEscape */ $toolbarContent . "\n" ?> | ||
<?php endforeach ?> | ||
<div class="smile-toolbar" id="st-modal-display"> | ||
<div class="st-main" id="st-modal-main" onclick="event.stopPropagation();"> | ||
<div class="st-title"> | ||
<div class="st-close" id="st-modal-close"></div> | ||
<h1 id="st-modal-title">My Modal Title</h1> | ||
/** @var Template $block */ | ||
/** @var Toolbar $viewModel */ | ||
$viewModel = $block->getData('viewModel'); | ||
$toolbars = $viewModel->getToolbarList(); | ||
?> | ||
|
||
<?php if ($viewModel->isToolbarEnabled()): ?> | ||
<?php foreach ($toolbars as $toolbarContent): ?> | ||
<?= /* @noEscape */ $toolbarContent . "\n" ?> | ||
<?php endforeach ?> | ||
<div class="smile-toolbar" id="st-modal-display"> | ||
<div class="st-main" id="st-modal-main" onclick="event.stopPropagation();"> | ||
<div class="st-title"> | ||
<div class="st-close" id="st-modal-close"></div> | ||
<h1 id="st-modal-title">My Modal Title</h1> | ||
</div> | ||
<div id="st-modal-content">My Modal Content</div> | ||
</div> | ||
<div id="st-modal-content">My Modal Content</div> | ||
</div> | ||
</div> | ||
<script> | ||
smileToolbarInit(); | ||
</script> | ||
<script> | ||
smileToolbarInit(); | ||
</script> | ||
<?php endif ?> |