Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DebugHints.php
Go to the documentation of this file.
1 <?php
10 
18 {
22  private $_subject;
23 
27  private $_showBlockHints;
28 
33  public function __construct(\Magento\Framework\View\TemplateEngineInterface $subject, $showBlockHints)
34  {
35  $this->_subject = $subject;
36  $this->_showBlockHints = $showBlockHints;
37  }
38 
44  public function render(\Magento\Framework\View\Element\BlockInterface $block, $templateFile, array $dictionary = [])
45  {
46  $result = $this->_subject->render($block, $templateFile, $dictionary);
47  if ($this->_showBlockHints) {
48  $result = $this->_renderBlockHints($result, $block);
49  }
50  $result = $this->_renderTemplateHints($result, $templateFile);
51  return $result;
52  }
53 
61  protected function _renderTemplateHints($blockHtml, $templateFile)
62  {
63  // @codingStandardsIgnoreStart
64  return <<<HTML
65 <div class="debugging-hints" style="position: relative; border: 1px dotted red; margin: 6px 2px; padding: 18px 2px 2px 2px;">
66 <div class="debugging-hint-template-file" style="position: absolute; top: 0; padding: 2px 5px; font: normal 11px Arial; background: red; left: 0; color: white; white-space: nowrap;" onmouseover="this.style.zIndex = 999;" onmouseout="this.style.zIndex = 'auto';" title="{$templateFile}">{$templateFile}</div>
67 {$blockHtml}
68 </div>
69 HTML;
70  // @codingStandardsIgnoreEnd
71  }
72 
80  protected function _renderBlockHints($blockHtml, \Magento\Framework\View\Element\BlockInterface $block)
81  {
82  $blockClass = get_class($block);
83  // @codingStandardsIgnoreStart
84  return <<<HTML
85 <div class="debugging-hint-block-class" style="position: absolute; top: 0; padding: 2px 5px; font: normal 11px Arial; background: red; right: 0; color: blue; white-space: nowrap;" onmouseover="this.style.zIndex = 999;" onmouseout="this.style.zIndex = 'auto';" title="{$blockClass}">{$blockClass}</div>
86 {$blockHtml}
87 HTML;
88  // @codingStandardsIgnoreEnd
89  }
90 }
_renderBlockHints($blockHtml, \Magento\Framework\View\Element\BlockInterface $block)
Definition: DebugHints.php:80
$block
Definition: block.php:8
__construct(\Magento\Framework\View\TemplateEngineInterface $subject, $showBlockHints)
Definition: DebugHints.php:33
render(\Magento\Framework\View\Element\BlockInterface $block, $templateFile, array $dictionary=[])
Definition: DebugHints.php:44