├── .gitattributes
├── .github
└── FUNDING.yml
├── view
└── frontend
│ └── templates
│ └── messages
│ └── withHtml.phtml
├── registration.php
├── etc
├── module.xml
└── frontend
│ └── di.xml
├── CHANGELOG.md
├── composer.json
├── LICENSE.md
└── README.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | /docs export-ignore
2 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: markshust
4 |
--------------------------------------------------------------------------------
/view/frontend/templates/messages/withHtml.phtml:
--------------------------------------------------------------------------------
1 | = $block->escapeHtml($block->getData('html'), $block->getData('allowed_tags'));
2 |
--------------------------------------------------------------------------------
/registration.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 | All notable changes to this project will be documented in this file.
3 |
4 | The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5 | and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6 |
7 | ## [1.0.1] - 2019-10-18
8 |
9 | ### Fixed
10 | - Updated composer version constraints to support newer versions of Magento.
11 |
12 | ## [1.0.0] - 2019-01-11
13 |
14 | ### Added
15 | - Initial release.
16 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "markshust/magento2-module-messages",
3 | "description": "The Messages module allows you to send success, notice, warning and error messages with HTML.",
4 | "require": {
5 | "php": "^7.1",
6 | "magento/framework": "^101"
7 | },
8 | "type": "magento2-module",
9 | "version": "1.0.0",
10 | "license": [
11 | "MIT"
12 | ],
13 | "autoload": {
14 | "files": [
15 | "registration.php"
16 | ],
17 | "psr-4": {
18 | "MarkShust\\Messages\\": ""
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/etc/frontend/di.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | -
7 |
- \Magento\Framework\View\Element\Message\Renderer\BlockRenderer::CODE
8 | -
9 |
- MarkShust_Messages::messages/withHtml.phtml
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) [year] [fullname]
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
MarkShust_Messages
2 |
3 |
4 |
Send success, notice, warning and error messages with <html>
5 |
6 |

7 |

8 |

9 |

10 |

11 |
12 |
13 |
14 | ## Table of contents
15 |
16 | - [Summary](#summary)
17 | - [Installation](#installation)
18 | - [API](#api)
19 | - [Usage](#usage)
20 | - [License](#license)
21 |
22 | ## Summary
23 |
24 | By default, when you call `$this->messageManager->addSuccessMessage` within Magento, you cannot pass custom HTML into your message. This doesn't provide you with the flexibility to provide customized messages to your visitors.
25 |
26 | This module provides the ability to display custom messages including HTML, and still escapes the HTML to prevent cross-site scripting (XSS) attacks.
27 |
28 | ## Installation
29 |
30 | ```
31 | composer require markshust/magento2-module-messages
32 | bin/magento module:enable MarkShust_Messages
33 | bin/magento setup:upgrade
34 | ```
35 |
36 | ## API
37 |
38 | ```php
39 | /**
40 | * Any of the built-in complex message functions can be called with this identifer:
41 | * addComplexSuccessMessage
42 | * addComplexNoticeMessage
43 | * addComplexWarningMessage
44 | * addComplexErrorMessage
45 | *
46 | * @param string $identifer Set to 'withHtml' to use this module.
47 | * @param mixed[] $data Data containing elements.
48 | * @type string 'html' Desired output including HTML.
49 | * @type string[] 'allowed_tags' (optional) List of allowed tags to render as HTML.
50 | */
51 | $this->messageManager->addComplexSuccessMessage($identifer, $data);
52 | ```
53 |
54 | ## Usage
55 |
56 | ```php
57 | protected messageManager;
58 |
59 | public function __construct(
60 | ...
61 | \Magento\Framework\Message\ManagerInterface $messageManager,
62 | ...
63 | ) {
64 | $this->messageManager = $messageManager;
65 | ...
66 | }
67 |
68 | $this->messageManager->addComplexSuccessMessage('withHtml', [
69 | 'html' => 'This is bold text! And this is not.',
70 | 'allowed_tags' => ['b'],
71 | ]);
72 | ```
73 |
74 | 
75 |
76 | ## License
77 |
78 | [MIT](https://opensource.org/licenses/MIT)
79 |
--------------------------------------------------------------------------------