Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
DebugHints Class Reference

Public Member Functions

 __construct (ScopeConfigInterface $scopeConfig, StoreManagerInterface $storeManager, DevHelper $devHelper, DebugHintsFactory $debugHintsFactory, $debugHintsPath, Http $http=null, $debugHintsWithParam=null, $debugHintsParameter=null)
 
 afterCreate (TemplateEngineFactory $subject, TemplateEngineInterface $invocationResult)
 

Data Fields

const XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS = 'dev/debug/template_hints_blocks'
 

Protected Attributes

 $scopeConfig
 
 $storeManager
 
 $devHelper
 
 $debugHintsFactory
 
 $debugHintsPath
 

Detailed Description

Definition at line 19 of file DebugHints.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( ScopeConfigInterface  $scopeConfig,
StoreManagerInterface  $storeManager,
DevHelper  $devHelper,
DebugHintsFactory  $debugHintsFactory,
  $debugHintsPath,
Http  $http = null,
  $debugHintsWithParam = null,
  $debugHintsParameter = null 
)
Parameters
ScopeConfigInterface$scopeConfig
StoreManagerInterface$storeManager
DevHelper$devHelper
DebugHintsFactory$debugHintsFactory
string$debugHintsPath
Http$http
string$debugHintsWithParam
string$debugHintsParameter

Definition at line 85 of file DebugHints.php.

94  {
95  $this->scopeConfig = $scopeConfig;
96  $this->storeManager = $storeManager;
97  $this->devHelper = $devHelper;
98  $this->debugHintsFactory = $debugHintsFactory;
99  $this->debugHintsPath = $debugHintsPath;
100  $this->http = $http ?: \Magento\Framework\App\ObjectManager::getInstance()->get(
101  \Magento\Framework\App\Request\Http::class
102  );
103  $this->debugHintsWithParam = $debugHintsWithParam;
104  $this->debugHintsParameter = $debugHintsParameter;
105  }

Member Function Documentation

◆ afterCreate()

afterCreate ( TemplateEngineFactory  $subject,
TemplateEngineInterface  $invocationResult 
)

Wrap template engine instance with the debugging hints decorator, depending of the store configuration

Parameters
TemplateEngineFactory$subject
TemplateEngineInterface$invocationResult
Returns
TemplateEngineInterface @SuppressWarnings(PHPMD.UnusedFormalParameter)

Definition at line 116 of file DebugHints.php.

119  {
120  $storeCode = $this->storeManager->getStore()->getCode();
121  if ($this->scopeConfig->getValue($this->debugHintsPath, ScopeInterface::SCOPE_STORE, $storeCode)
122  && $this->devHelper->isDevAllowed()) {
123  $debugHintsWithParam = $this->scopeConfig->getValue(
124  $this->debugHintsWithParam,
126  $storeCode
127  );
128  $debugHintsParameter = $this->scopeConfig->getValue(
129  $this->debugHintsParameter,
131  $storeCode
132  );
133  $debugHintsParameterInUrl = $this->http->getParam('templatehints');
134 
135  $showHints = false;
136  if (!$debugHintsWithParam) {
137  $showHints = true;
138  }
139  if ($debugHintsWithParam && $debugHintsParameter == $debugHintsParameterInUrl) {
140  $showHints = true;
141  }
142 
143  if ($showHints) {
144  $showBlockHints = $this->scopeConfig->getValue(
145  self::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS,
147  $storeCode
148  );
149  return $this->debugHintsFactory->create([
150  'subject' => $invocationResult,
151  'showBlockHints' => $showBlockHints,
152  ]);
153  }
154  }
155  return $invocationResult;
156  }
$storeCode
Definition: indexer.php:15

Field Documentation

◆ $debugHintsFactory

$debugHintsFactory
protected

Definition at line 44 of file DebugHints.php.

◆ $debugHintsPath

$debugHintsPath
protected

Definition at line 55 of file DebugHints.php.

◆ $devHelper

$devHelper
protected

Definition at line 39 of file DebugHints.php.

◆ $scopeConfig

$scopeConfig
protected

Definition at line 29 of file DebugHints.php.

◆ $storeManager

$storeManager
protected

Definition at line 34 of file DebugHints.php.

◆ XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS

const XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS = 'dev/debug/template_hints_blocks'

XPath of configuration of the debug block names

Definition at line 24 of file DebugHints.php.


The documentation for this class was generated from the following file: