-
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.
Add notification message when production mode is enabled
- Loading branch information
Showing
9 changed files
with
97 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Smile\DebugToolbar\Model\Message; | ||
|
||
use Magento\Framework\App\DeploymentConfig; | ||
use Magento\Framework\App\State; | ||
use Magento\Framework\Notification\MessageInterface; | ||
use Smile\DebugToolbar\Helper\Config; | ||
|
||
/** | ||
* Add zone blocks to the toolbar. | ||
*/ | ||
class ProductionMode implements MessageInterface | ||
{ | ||
public function __construct( | ||
protected DeploymentConfig $deploymentConfig, | ||
protected Config $configHelper | ||
) { | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getIdentity() | ||
{ | ||
return 'smile_debugtoolbar_production_mode'; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function isDisplayed() | ||
{ | ||
return $this->deploymentConfig->get(State::PARAM_MODE) !== State::MODE_PRODUCTION; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getText() | ||
{ | ||
return __( | ||
<<<'EOT' | ||
The DebugToolbar module is not supposed to be installed on production environments. | ||
It may expose sensitive information if it is enabled. | ||
EOT | ||
); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getSeverity() | ||
{ | ||
return $this->configHelper->isEnabled() | ||
? MessageInterface::SEVERITY_CRITICAL | ||
: MessageInterface::SEVERITY_MAJOR; | ||
} | ||
} |
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,9 @@ | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
<type name="Magento\Framework\Notification\MessageList"> | ||
<arguments> | ||
<argument name="messages" xsi:type="array"> | ||
<item name="smile_debugtoolbar" xsi:type="string">Smile\DebugToolbar\Model\Message\ProductionMode</item> | ||
</argument> | ||
</arguments> | ||
</type> | ||
</config> |