16 |
17 | ## Overview
18 | [Magento 2 Easy Template Path Hints](https://www.magepsycho.com/magento-2-easy-template-path-hints.html) is used to enable the template path hints on the fly just by using query strings.
19 |
20 | (This is a ported version of [Easy Template Path Hints - Magento 1](https://github.com/MagePsycho/MagePsycho_Easypathhints) for Magento 2)
21 |
22 | ## Functionality
23 | * Turn on template path hints on the fly for frontend
24 | * Turn on template path hints on the fly for backend
25 | * Option to configure access code
26 | * Option to save settings in cookie
27 |
28 |
29 | ## Installation
30 |
31 | ### 1 Using Composer
32 | ```
33 | composer require magepsycho/magento2-easy-template-path-hints
34 | ```
35 |
36 | ### 2 Using Modman
37 | ```
38 | modman init
39 | modman clone git@github.com:MagePsycho/magento2-easy-template-path-hints.git
40 | ```
41 |
42 | ### 3 Using Zip File
43 | * Download the [Extension Zip File](https://github.com/MagePsycho/magento2-easy-template-path-hints/archive/master.zip)
44 | * Extract & upload the files to `/path/to/magento2/app/code/MagePsycho/Easypathhints/`
45 |
46 | After installation by either means, activate the extension with following steps
47 |
48 | 1. Enable the module
49 | ```
50 | php bin/magento module:enable MagePsycho_Easypathhints --clear-static-content
51 | php bin/magento setup:upgrade
52 | ```
53 | 2. Flush the store cache
54 | ```
55 | php bin/magento cache:flush
56 | ```
57 | 3. Deploy static content - *in Production mode only*
58 | ```
59 | rm -rf pub/static/* var/view_preprocessed/*
60 | php bin/magento setup:static-content:deploy
61 | ```
62 | 4. Go to Admin > STORES > Configuration > MAGEPSYCHO > Easy Template Path Hints > Manage Settings
63 |
64 |
65 | ## Usage
66 |
67 | 1. Enable template path hints without access code:
68 | * http://magento-store-url.com/any-page?tp=1
69 |
70 | 1. Enable template path hints with access code:
71 | * http://magento-store-url.com/any-page?tp=1&code=access-code
72 |
73 | 1. Enable template path hints with cookie
74 | * http://magento-store-url.com/any-page?tp=1&code=your-access-code&cookie=1
75 |
76 | ## Screenshot
77 | 
78 |
79 |
80 | 
81 |
82 | ## Changelog
83 | **Version 1.1.3 (2022-02-14)**
84 | * Bumped the version for the sake of packagist release
85 |
86 | **Version 1.1.2 (2018-05-10)**
87 | * Fixed wrong module path if installed via composer
88 |
89 | **Version 1.1.1 (2018-05-10)**
90 | * Fixed template block class hints not showing
91 |
92 | **Version 1.1.0 (2017-06-16)**
93 | * Refactored the code (Logger, Cookie, Config etc.)
94 | * Fixed template path hints not working for Magento versions 2.1.3+
95 |
96 | **Version 1.0.2 (2016-04-03)**
97 | * Fixed template path hints for admin.
98 | * Refactored code.
99 |
100 | **Version 1.0.1 (2016-04-03)**
101 | * Fixed relative XSD path of xml configurations.
102 | * Added modman file.
103 | * Refactored code.
104 |
105 | **Version 1.0.0 (2015-10-30)**
106 | * Initial Release
107 |
108 | ## Authors
109 | - Raj KB [](https://twitter.com/rajkbnp)
110 |
111 | ## Contributors
112 |
113 | 
114 |
115 | ## To Contribute
116 | Any contribution to the development of `Magento 2 Easy Template Path Hints` is highly welcome.
117 | The best possibility to provide any code is to open a [pull request on GitHub](https://github.com/MagePsycho/magento2-easy-template-path-hints/pulls).
118 |
119 | ## Need Support?
120 | If you encounter any problems or bugs, please create an issue on [GitHub](https://github.com/MagePsycho/magento2-easy-template-path-hints/issues).
121 |
122 | Please [visit our store](https://www.magepsycho.com/extensions/magento-2.html) for more FREE / paid extensions OR [contact us](https://magepsycho.com/contact) for customization / development services.
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "magepsycho/magento2-easy-template-path-hints",
3 | "description": "Easy Template Path Hints for Magento 2",
4 | "keywords": ["magento", "magento2 extension", "magento 2 extension", "extension", "module", "magento2 module", "magento 2 module", "debug", "template path hint", "development"],
5 | "type": "magento2-module",
6 | "version": "1.1.3",
7 | "homepage": "https://www.magepsycho.com/magento-2-easy-template-path-hints.html",
8 | "authors": [
9 | {
10 | "name": "Raj KB",
11 | "email": "magepsycho@gmail.com",
12 | "homepage": "https://www.magepsycho.com"
13 | }
14 | ],
15 | "license": [
16 | "OSL-3.0"
17 | ],
18 | "autoload": {
19 | "files": [
20 | "src/registration.php"
21 | ],
22 | "psr-4": {
23 | "MagePsycho\\Easypathhints\\": "src"
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/docs/Changelog.txt:
--------------------------------------------------------------------------------
1 | Version 1.0.2 - 1.1.0 (2017-06-16)
2 | - Refactored the code (Logger, Cookie, Config etc.)
3 | - Fixed template path hints not working for Magento versions 2.1.3+
4 |
5 | Version 1.0.1 - 1.0.2 (2016-04-03)
6 | - Fixed template path hints for admin.
7 | - Refactored code.
8 |
9 | Version 1.0.0 - 1.0.1 (2016-04-03)
10 | - Fixed relative XSD path of xml configurations.
11 | - Added modman file.
12 | - Refactored code.
13 |
14 | Version 1.0.0 (2015-10-30)
15 | - Initial Release.
--------------------------------------------------------------------------------
/docs/Description.html:
--------------------------------------------------------------------------------
1 |
Introduction
2 |
Magento 2 Easy Template Path Hints extension is used to turn on the template path hints for both frontend & backend on the fly just by using query strings.
3 |
4 | (This is the ported version of Magento 1 Easy Template Path Hints for Magento 2)
5 |
6 |
7 |
Key Features
8 |
Turn on Template Path Hints for Frontend
9 |
You can easily turn on the template path hints for frontend just by appending query string: ?tp=1&code=[access-code]
10 | This feature gives you the power to turn on/off the template path hints on the fly without going back and forth with System > Developer Settings.
11 |
12 |
13 |
Turn on Template Path Hints for Backend
14 |
Similar to frontend, You can easily turn on the template path hints for backend just by appending query string: ?tp=1&code=[access-code]
15 |
16 |
17 |
18 |
Save settings in Cookie
19 |
20 | You can save the settings in cookie so that you don't have to append query string again and again in order to turn on the template path hints.
21 | This feature is really helpful while debugging form post pages, transactional email templates etc.
22 |
23 |
24 |
Installation
25 |
26 | 1. Download the extension .zip file and extract it.
27 | 2. Copy the extension files from src/ folder to the {your-magento2-dir}/app/code/MagePsycho/Easypathhints
28 | 3. Once you have copied all the extension files to the proper directory, run the following commands:
29 | php bin/magento module:enable MagePsycho_Easypathhints --clear-static-content
30 | php bin/magento setup:upgrade
31 | 4. Go to Admin > Stores > Configuration > MagePsycho > Easy Template Path Hints > Configure your settings here...
32 |
33 |
34 |
35 |
Live Demo
36 |
Coming Soon.
37 |
38 |
Changelog
39 |
40 | Version 1.0.2 - 1.1.0 (2017-06-16)
41 | - Refactored the code (Logger, Cookie, Config etc.)
42 | - Fixed template path hints not working for Magento versions 2.1.3+
56 |
--------------------------------------------------------------------------------
/docs/backend-settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MagePsycho/magento2-easy-template-path-hints/e90ab3c1ca4c095d9650b293339939bec5669f96/docs/backend-settings.png
--------------------------------------------------------------------------------
/docs/magento-2-easy-template-path-hints-frontend.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MagePsycho/magento2-easy-template-path-hints/e90ab3c1ca4c095d9650b293339939bec5669f96/docs/magento-2-easy-template-path-hints-frontend.png
--------------------------------------------------------------------------------
/modman:
--------------------------------------------------------------------------------
1 | src/ app/code/MagePsycho/Easypathhints/
--------------------------------------------------------------------------------
/src/Block/System/Config/Form/Field/Version.php:
--------------------------------------------------------------------------------
1 |
13 | * @website https://www.magepsycho.com
14 | */
15 | class Version extends \Magento\Config\Block\System\Config\Form\Field
16 | {
17 | const EXTENSION_URL = 'https://www.magepsycho.com/magento-2-easy-template-path-hints.html';
18 |
19 | /**
20 | * @var \MagePsycho\Easypathhints\Helper\Data $helper
21 | */
22 | protected $_helper;
23 |
24 | /**
25 | * @param \Magento\Backend\Block\Template\Context $context
26 | * @param \MagePsycho\Easypathhints\Helper\Data $helper
27 | */
28 | public function __construct(
29 | \Magento\Backend\Block\Template\Context $context,
30 | \MagePsycho\Easypathhints\Helper\Data $helper
31 | ) {
32 | $this->_helper = $helper;
33 | parent::__construct($context);
34 | }
35 |
36 | /**
37 | * @param AbstractElement $element
38 | * @return string
39 | */
40 | protected function _getElementHtml(AbstractElement $element)
41 | {
42 | $extensionVersion = $this->_helper->getExtensionVersion();
43 | $extensionTitle = 'Easy Template Path Hints';
44 | $versionLabel = sprintf(
45 | '%s',
46 | self::EXTENSION_URL,
47 | $extensionTitle,
48 | $extensionVersion
49 | );
50 | $element->setValue($versionLabel);
51 |
52 | return $element->getValue();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/Block/System/Config/Form/Fieldset/Support.php:
--------------------------------------------------------------------------------
1 |
11 | * @website https://www.magepsycho.com
12 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
13 | */
14 | class Support extends \Magento\Backend\Block\Template implements RendererInterface
15 | {
16 | /**
17 | * @var string
18 | */
19 | protected $_template = 'MagePsycho_Easypathhints::system/config/form/fieldset/support.phtml';
20 |
21 | /**
22 | * @var \Magento\Framework\App\ProductMetadataInterface
23 | */
24 | protected $_metaData;
25 |
26 | /**
27 | * @var \Magento\Framework\Module\ModuleList\Loader
28 | */
29 | protected $_loader;
30 |
31 | public function __construct(
32 | \Magento\Backend\Block\Template\Context $context,
33 | \Magento\Framework\App\ProductMetadataInterface $productMetaData,
34 | \Magento\Framework\Module\ModuleList\Loader $loader,
35 | array $data = []
36 | ) {
37 | parent::__construct($context, $data);
38 | $this->_metaData = $productMetaData;
39 | $this->_loader = $loader;
40 | }
41 |
42 | /**
43 | * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
44 | * @return mixed
45 | */
46 | public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
47 | {
48 | return $this->toHtml();
49 | }
50 |
51 | public function getMageVersion()
52 | {
53 | $mageVersion = $this->_metaData->getVersion();
54 | $mageEdition = $this->_metaData->getEdition();
55 | switch ($mageEdition) {
56 | case 'Community':
57 | $mageEdition = 'CE';
58 | break;
59 | case 'Enterprise':
60 | $mageEdition = 'EE';
61 | break;
62 | }
63 |
64 | return $mageEdition . ' ' . $mageVersion;
65 | }
66 |
67 | public function getModuleVersion()
68 | {
69 | $modules = $this->_loader->load();
70 | $v = "";
71 | if (isset($modules['MagePsycho_Easypathhints'])) {
72 | $v = $modules['MagePsycho_Easypathhints']['setup_version'];
73 | }
74 | return $v;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/Helper/Config.php:
--------------------------------------------------------------------------------
1 |
9 | * @website https://www.magepsycho.com
10 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
11 | */
12 | class Config
13 | {
14 | const XML_PATH_ENABLED = 'magepsycho_easypathhints/general/enabled';
15 | const XML_PATH_DEBUG = 'magepsycho_easypathhints/general/debug';
16 | const XML_PATH_ACCESS_CODE = 'magepsycho_easypathhints/general/access_code';
17 | const XML_PATH_SAVE_COOKIE = 'magepsycho_easypathhints/general/save_in_cookie';
18 | const XML_PATH_PROFILER = 'magepsycho_easypathhints/general/show_profiler';
19 |
20 | const XML_PATH_DEBUG_TEMPLATE_FRONT = 'dev/debug/template_hints_storefront';
21 | const XML_PATH_DEBUG_TEMPLATE_ADMIN = 'dev/debug/template_hints_admin';
22 | const XML_PATH_DEBUG_BLOCKS = 'dev/debug/template_hints_blocks';
23 |
24 | /**
25 | * @var \Magento\Framework\App\Config\ScopeConfigInterface
26 | */
27 | protected $scopeConfig;
28 |
29 | public function __construct(
30 | \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
31 | ) {
32 | $this->scopeConfig = $scopeConfig;
33 | }
34 |
35 | public function getConfigValue($xmlPath, $storeId = null)
36 | {
37 | return $this->scopeConfig->getValue(
38 | $xmlPath,
39 | \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
40 | $storeId
41 | );
42 | }
43 |
44 | public function isEnabled($storeId = null)
45 | {
46 | return $this->getConfigValue(self::XML_PATH_ENABLED, $storeId);
47 | }
48 |
49 | public function isActive($storeId = null)
50 | {
51 | return $this->isEnabled($storeId);
52 | }
53 |
54 | public function getDebugStatus($storeId = null)
55 | {
56 | return $this->getConfigValue(self::XML_PATH_DEBUG, $storeId);
57 | }
58 |
59 | public function getAccessCode($storeId = null)
60 | {
61 | return $this->getConfigValue(self::XML_PATH_ACCESS_CODE, $storeId);
62 | }
63 |
64 | public function getSaveInCookie($storeId = null)
65 | {
66 | return $this->getConfigValue(self::XML_PATH_SAVE_COOKIE, $storeId);
67 | }
68 |
69 | public function getShowProfiler($storeId = null)
70 | {
71 | return $this->getConfigValue(self::XML_PATH_PROFILER, $storeId);
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/Helper/Data.php:
--------------------------------------------------------------------------------
1 |
14 | * @website https://www.magepsycho.com
15 | */
16 | class Data extends \Magento\Framework\App\Helper\AbstractHelper
17 | {
18 | /**
19 | * @var \MagePsycho\Easypathhints\Logger\Logger
20 | */
21 | protected $customLogger;
22 |
23 | /**
24 | * @var \MagePsycho\Easypathhints\Helper\Config
25 | */
26 | protected $configHelper;
27 |
28 | /**
29 | * @var ModuleListInterface
30 | */
31 | protected $moduleList;
32 |
33 | /**
34 | * @var \MagePsycho\Easypathhints\Model\TemplateHintCookie
35 | */
36 | protected $templateHintCookie;
37 |
38 | /**
39 | * @var \Magento\Framework\App\ProductMetadataInterface
40 | */
41 | protected $mageMetaData;
42 |
43 | public function __construct(
44 | Context $context,
45 | \MagePsycho\Easypathhints\Logger\Logger $customLogger,
46 | \MagePsycho\Easypathhints\Helper\Config $configHelper,
47 | \MagePsycho\Easypathhints\Model\TemplateHintCookie $templateHintCookie,
48 | ModuleListInterface $moduleList,
49 | \Magento\Framework\App\ProductMetadataInterface $mageMetaData
50 | ) {
51 | $this->customLogger = $customLogger;
52 | $this->configHelper = $configHelper;
53 | $this->templateHintCookie = $templateHintCookie;
54 | $this->moduleList = $moduleList;
55 | $this->mageMetaData = $mageMetaData;
56 |
57 | parent::__construct($context);
58 | }
59 |
60 | public function shouldShowTemplatePathHints()
61 | {
62 | if (!$this->configHelper->isActive()) {
63 | return false;
64 | }
65 | $tp = $this->_getRequest()->getParam('tp');
66 | $accessCode = $this->_getRequest()->getParam('code');
67 | $dbAccessCode = $this->configHelper->getAccessCode();
68 | $dbCookieStatus = $this->configHelper->getSaveInCookie();
69 | $cookieStatus = $this->_getRequest()->getParam('cookie', -1);
70 |
71 | $checkAccessCode = true;
72 | if (! empty($dbAccessCode)) {
73 | $checkAccessCode = ($dbAccessCode == $accessCode)
74 | ? true
75 | : false;
76 | }
77 |
78 | // set/delete cookie value
79 | if ($dbCookieStatus) {
80 | if (1 == $cookieStatus) {
81 | $this->templateHintCookie->set(1);
82 | } elseif (0 == $cookieStatus) {
83 | $this->templateHintCookie->delete();
84 | }
85 | }
86 |
87 | if (($tp && $checkAccessCode)
88 | || $this->templateHintCookie->get()
89 | ) {
90 | return true;
91 | }
92 |
93 | return false;
94 | }
95 |
96 | public function getExtensionVersion()
97 | {
98 | $moduleCode = 'MagePsycho_Easypathhints';
99 | $moduleInfo = $this->moduleList->getOne($moduleCode);
100 | return $moduleInfo['setup_version'];
101 | }
102 |
103 | public function getMagentoVersion()
104 | {
105 | return $this->mageMetaData->getVersion();
106 | }
107 |
108 | /**
109 | * Logging Utility
110 | *
111 | * @param $message
112 | * @param bool|false $useSeparator
113 | */
114 | public function log($message, $useSeparator = false)
115 | {
116 | if ($this->configHelper->getDebugStatus()) {
117 | if ($useSeparator) {
118 | $this->customLogger->customLog(str_repeat('=', 100));
119 | }
120 |
121 | $this->customLogger->customLog($message);
122 | }
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/src/LICENSE.txt:
--------------------------------------------------------------------------------
1 |
2 | Open Software License ("OSL") v. 3.0
3 |
4 | This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
5 |
6 | Licensed under the Open Software License version 3.0
7 |
8 | 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
9 |
10 | 1. to reproduce the Original Work in copies, either alone or as part of a collective work;
11 |
12 | 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
13 |
14 | 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License;
15 |
16 | 4. to perform the Original Work publicly; and
17 |
18 | 5. to display the Original Work publicly.
19 |
20 | 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
21 |
22 | 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
23 |
24 | 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
25 |
26 | 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
27 |
28 | 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
29 |
30 | 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
31 |
32 | 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
33 |
34 | 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
35 |
36 | 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
37 |
38 | 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
39 |
40 | 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
41 |
42 | 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
43 |
44 | 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
45 |
46 | 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
47 |
48 | 16. Modification of This License. This License is Copyright � 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
--------------------------------------------------------------------------------
/src/Logger/Handler.php:
--------------------------------------------------------------------------------
1 |
11 | * @website https://www.magepsycho.com
12 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
13 | */
14 | class Handler extends Base
15 | {
16 | /**
17 | * @var string
18 | */
19 | protected $fileName = '/var/log/magepsycho_easypathhints.log';
20 |
21 | /**
22 | * @var int
23 | */
24 | protected $loggerType = \Monolog\Logger::INFO;
25 | }
26 |
--------------------------------------------------------------------------------
/src/Logger/Logger.php:
--------------------------------------------------------------------------------
1 |
9 | * @website https://www.magepsycho.com
10 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
11 | */
12 | class Logger extends \Monolog\Logger
13 | {
14 | public function customLog($message)
15 | {
16 | try {
17 | if ($message === null) {
18 | $message = "NULL";
19 | }
20 | if (is_array($message)) {
21 | $message = json_encode($message, JSON_PRETTY_PRINT);
22 | }
23 | if (is_object($message)) {
24 | $message = json_encode($message, JSON_PRETTY_PRINT);
25 | }
26 | if (!empty(json_last_error())) {
27 | $message = (string)json_last_error();
28 | }
29 | $message = (string)$message;
30 | } catch (\Exception $e) {
31 | $message = "INVALID MESSAGE";
32 | }
33 | $message .= PHP_EOL;
34 | $this->info($message);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Model/Cookie.php:
--------------------------------------------------------------------------------
1 |
14 | * @website https://www.magepsycho.com
15 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16 | */
17 | class Cookie
18 | {
19 | /**
20 | * CookieManager
21 | *
22 | * @var CookieManagerInterface
23 | */
24 | private $cookieManager;
25 |
26 | /**
27 | * @var CookieMetadataFactory
28 | */
29 | private $cookieMetadataFactory;
30 |
31 | /**
32 | * @var SessionManagerInterface
33 | */
34 | private $sessionManager;
35 |
36 | /**
37 | * @param CookieManagerInterface $cookieManager
38 | * @param CookieMetadataFactory $cookieMetadataFactory
39 | * @param SessionManagerInterface $sessionManager
40 | */
41 | public function __construct(
42 | CookieManagerInterface $cookieManager,
43 | CookieMetadataFactory $cookieMetadataFactory,
44 | SessionManagerInterface $sessionManager
45 | ) {
46 | $this->cookieManager = $cookieManager;
47 | $this->cookieMetadataFactory = $cookieMetadataFactory;
48 | $this->sessionManager = $sessionManager;
49 | }
50 |
51 | /**
52 | * Get form key cookie
53 | *
54 | * @return string
55 | */
56 | public function get()
57 | {
58 | return $this->cookieManager->getCookie(static::COOKIE_NAME);
59 | }
60 |
61 | public function set($value, $duration = 86400)
62 | {
63 | $publicCookieMetadata = $this->cookieMetadataFactory
64 | ->createPublicCookieMetadata()
65 | ->setDuration($duration)
66 | ->setPath($this->sessionManager->getCookiePath())
67 | ->setDomain($this->sessionManager->getCookieDomain());
68 |
69 | $this->cookieManager->setPublicCookie(
70 | static::COOKIE_NAME,
71 | $value,
72 | $publicCookieMetadata
73 | );
74 | }
75 |
76 | public function delete()
77 | {
78 | $publicCookieMetadata = $this->cookieMetadataFactory
79 | ->createPublicCookieMetadata()
80 | ->setPath($this->sessionManager->getCookiePath())
81 | ->setDomain($this->sessionManager->getCookieDomain());
82 | $this->cookieManager->deleteCookie(
83 | static::COOKIE_NAME,
84 | $publicCookieMetadata
85 | );
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/Model/TemplateHintCookie.php:
--------------------------------------------------------------------------------
1 |
9 | * @website https://www.magepsycho.com
10 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
11 | */
12 | class TemplateHintCookie extends Cookie
13 | {
14 | /**
15 | * Name of cookie that holds private content version
16 | */
17 | const COOKIE_NAME = 'magepsycho_easypathhints_active';
18 | }
19 |
--------------------------------------------------------------------------------
/src/Observer/ControllerActionPredispatch.php:
--------------------------------------------------------------------------------
1 |
18 | * @website https://www.magepsycho.com
19 | */
20 | class ControllerActionPredispatch implements ObserverInterface
21 | {
22 | /**
23 | * @var EasypathhintsHelper $helper
24 | */
25 | protected $_helper;
26 |
27 | /**
28 | * @var MutableScopeConfigInterface
29 | */
30 | protected $_mutableConfig;
31 |
32 | /**
33 | * @param EasypathhintsHelper $helper
34 | * @param MutableScopeConfigInterface $mutableConfig
35 | */
36 | public function __construct(
37 | EasypathhintsHelper $helper,
38 | MutableScopeConfigInterface $mutableConfig
39 | ) {
40 | $this->_helper = $helper;
41 | $this->_mutableConfig = $mutableConfig;
42 | }
43 |
44 | public function execute(Observer $observer)
45 | {
46 | if (version_compare($this->_helper->getMagentoVersion(), '2.1.3', '>=')) {
47 | return $this;
48 | }
49 |
50 | if ($this->_helper->shouldShowTemplatePathHints()) {
51 |
52 | $this->_mutableConfig->setValue(
53 | EasypathhintsConfigHelper::XML_PATH_DEBUG_TEMPLATE_FRONT,
54 | 1,
55 | ScopeInterface::SCOPE_STORE
56 | );
57 |
58 | $this->_mutableConfig->setValue(
59 | EasypathhintsConfigHelper::XML_PATH_DEBUG_TEMPLATE_ADMIN,
60 | 1,
61 | ScopeInterface::SCOPE_STORE
62 | );
63 |
64 | $this->_mutableConfig->setValue(
65 | EasypathhintsConfigHelper::XML_PATH_DEBUG_BLOCKS,
66 | 1,
67 | ScopeInterface::SCOPE_STORE
68 | );
69 | }
70 | return $this;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/Plugin/TemplateEngine/DebugHints.php:
--------------------------------------------------------------------------------
1 |
14 | * @website https://www.magepsycho.com
15 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16 | */
17 | class DebugHints
18 | {
19 | /**
20 | * @var EasyPathHintsHelper
21 | */
22 | private $easyPathHintsHelper;
23 |
24 | /**
25 | * @var DebugHintsFactory
26 | */
27 | protected $debugHintsFactory;
28 |
29 | public function __construct(
30 | EasyPathHintsHelper $easyPathHintsHelper,
31 | DebugHintsFactory $debugHintsFactory
32 | ) {
33 | $this->easyPathHintsHelper = $easyPathHintsHelper;
34 | $this->debugHintsFactory = $debugHintsFactory;
35 | }
36 |
37 | public function afterCreate(
38 | TemplateEngineFactory $subject,
39 | TemplateEngineInterface $invocationResult
40 | ) {
41 | if ($this->easyPathHintsHelper->shouldShowTemplatePathHints()) {
42 | $showBlockHints = 1;
43 | return $this->debugHintsFactory->create([
44 | 'subject' => $invocationResult,
45 | 'showBlockHints' => $showBlockHints,
46 | ]);
47 | }
48 | return $invocationResult;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "magepsycho/magento2-easy-template-path-hints",
3 | "description": "Easy Template Path Hints for Magento 2",
4 | "keywords": ["magento", "magento2 extension", "magento 2 extension", "extension", "module", "magento2 module", "magento 2 module", "debug", "template path hint", "development"],
5 | "type": "magento2-module",
6 | "version": "1.1.3",
7 | "homepage": "https://www.magepsycho.com/magento-2-easy-template-path-hints.html",
8 | "authors": [
9 | {
10 | "name": "Raj KB",
11 | "email": "magepsycho@gmail.com",
12 | "homepage": "https://www.magepsycho.com"
13 | }
14 | ],
15 | "license": [
16 | "OSL-3.0"
17 | ],
18 | "autoload": {
19 | "files": [
20 | "registration.php"
21 | ],
22 | "psr-4": {
23 | "MagePsycho\\Easypathhints\\": ""
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/etc/acl.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/src/etc/adminhtml/system.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | magepsycho
18 |
19 | MagePsycho_Easypathhints::config
20 |
21 |
22 | MagePsycho\Easypathhints\Block\System\Config\Form\Fieldset\Support
23 |
24 |
25 |
26 |
27 |
28 |
29 | MagePsycho\Easypathhints\Block\System\Config\Form\Field\Version
30 |
31 |
32 |
33 | Magento\Config\Model\Config\Source\Yesno
34 |
35 |
36 |
37 | Not Empty Access Code: /?tp=1&code=[access-code]
38 | Empty Access Code: /?tp=1
39 | Note that this works both for frontend and admin pages.]]>
40 |
41 |
42 |
43 | Magento\Config\Model\Config\Source\Yesno
44 |
45 | To Enable Cookie: /?tp=1&code=[access-code]&cookie=1
46 | To Clear cookies: /?tp=1&code=[access-code]&cookie=0 OR clear browser cookies
47 | (Especially useful for debugging post form pages, transactional email templates etc.)]]>
48 |
49 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/src/etc/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
15 | 0
16 | 0
17 | mage2
18 | 0
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/etc/di.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
15 | Magento\Framework\Filesystem\Driver\File
16 |
17 |
18 |
19 |
20 | MagePsychoEasypathhintsLogger
21 |
22 | MagePsycho\Easypathhints\Logger\Handler
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/etc/events.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/etc/module.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/registration.php:
--------------------------------------------------------------------------------
1 |
2 |