Skip to content

Commit

Permalink
Merge pull request #1440 from magento-engcom/develop-prs
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksii Korshenko authored Aug 28, 2017
2 parents b2f688c + 1fda0a6 commit feb1c5a
Show file tree
Hide file tree
Showing 14 changed files with 132 additions and 32 deletions.
16 changes: 16 additions & 0 deletions app/code/Magento/Backend/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,22 @@
<label>Enabled Template Path Hints for Storefront</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="template_hints_storefront_show_with_parameter" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable Hints for Storefront with URL Parameter</label>
<depends>
<field id="*/*/template_hints_storefront">1</field>
</depends>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>Use URL parameter to enable template path hints for Storefront</comment>
</field>
<field id="template_hints_parameter_value" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Parameter Value</label>
<depends>
<field id="*/*/template_hints_storefront">1</field>
<field id="*/*/template_hints_storefront_show_with_parameter">1</field>
</depends>
<comment>Add the following paramater to the URL to show template hints ?templatehints=[parameter_value]</comment>
</field>
<field id="template_hints_admin" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Enabled Template Path Hints for Admin</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Magento\Framework\View\TemplateEngineInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\App\Request\Http;

class DebugHints
{
Expand Down Expand Up @@ -53,25 +54,54 @@ class DebugHints
*/
protected $debugHintsPath;

/**
* XPath of configuration of the debug hints show with parameter
*
* dev/debug/template_hints_storefront_show_with_parameter
*
* @var string
*/
private $debugHintsWithParam;

/**
* XPath of configuration of the debug hints URL parameter
*
* dev/debug/template_hints_parameter_value
*
* @var string
*/
private $debugHintsParameter;

/**
* @param ScopeConfigInterface $scopeConfig
* @param StoreManagerInterface $storeManager
* @param DevHelper $devHelper
* @param DebugHintsFactory $debugHintsFactory
* @param string $debugHintsPath
* @param Http $http
* @param string $debugHintsWithParam
* @param string $debugHintsParameter
*/
public function __construct(
ScopeConfigInterface $scopeConfig,
StoreManagerInterface $storeManager,
DevHelper $devHelper,
DebugHintsFactory $debugHintsFactory,
$debugHintsPath
$debugHintsPath,
Http $http = null,
$debugHintsWithParam = null,
$debugHintsParameter = null
) {
$this->scopeConfig = $scopeConfig;
$this->storeManager = $storeManager;
$this->devHelper = $devHelper;
$this->debugHintsFactory = $debugHintsFactory;
$this->debugHintsPath = $debugHintsPath;
$this->http = $http ?: \Magento\Framework\App\ObjectManager::getInstance()->get(
\Magento\Framework\App\Request\Http::class
);
$this->debugHintsWithParam = $debugHintsWithParam;
$this->debugHintsParameter = $debugHintsParameter;
}

/**
Expand All @@ -90,15 +120,37 @@ public function afterCreate(
$storeCode = $this->storeManager->getStore()->getCode();
if ($this->scopeConfig->getValue($this->debugHintsPath, ScopeInterface::SCOPE_STORE, $storeCode)
&& $this->devHelper->isDevAllowed()) {
$showBlockHints = $this->scopeConfig->getValue(
self::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS,
$debugHintsWithParam = $this->scopeConfig->getValue(
$this->debugHintsWithParam,
ScopeInterface::SCOPE_STORE,
$storeCode
);
$debugHintsParameter = $this->scopeConfig->getValue(
$this->debugHintsParameter,
ScopeInterface::SCOPE_STORE,
$storeCode
);
return $this->debugHintsFactory->create([
'subject' => $invocationResult,
'showBlockHints' => $showBlockHints,
]);
$debugHintsParameterInUrl = $this->http->getParam('templatehints');

$showHints = false;
if (!$debugHintsWithParam) {
$showHints = true;
}
if ($debugHintsWithParam && $debugHintsParameter == $debugHintsParameterInUrl) {
$showHints = true;
}

if ($showHints) {
$showBlockHints = $this->scopeConfig->getValue(
self::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS,
ScopeInterface::SCOPE_STORE,
$storeCode
);
return $this->debugHintsFactory->create([
'subject' => $invocationResult,
'showBlockHints' => $showBlockHints,
]);
}
}
return $invocationResult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ protected function setUp()
* @return void
* @dataProvider afterCreateActiveDataProvider
*/
public function testAfterCreateActive($debugHintsPath, $showBlockHints)
{
public function testAfterCreateActive(
$debugHintsPath,
$showBlockHints,
$debugHintsWithParam,
$debugHintsParameter
) {
$this->devHelperMock->expects($this->once())
->method('isDevAllowed')
->willReturn(true);
Expand All @@ -88,12 +92,17 @@ public function testAfterCreateActive($debugHintsPath, $showBlockHints)
->disableOriginalConstructor()
->getMock();

$this->httpMock = $this->createMock(\Magento\Framework\App\Request\Http::class);

$debugHints = new DebugHints(
$this->scopeConfigMock,
$this->storeManager,
$this->devHelperMock,
$this->debugHintsFactory,
$debugHintsPath
$debugHintsPath,
$this->httpMock,
$debugHintsWithParam,
$debugHintsParameter
);

$this->assertEquals($debugHintsDecorator, $debugHints->afterCreate($subjectMock, $engine));
Expand All @@ -105,10 +114,10 @@ public function testAfterCreateActive($debugHintsPath, $showBlockHints)
public function afterCreateActiveDataProvider()
{
return [
['dev/debug/template_hints_storefront', false],
['dev/debug/template_hints_storefront', true],
['dev/debug/template_hints_admin', false],
['dev/debug/template_hints_admin', true],
['dev/debug/template_hints_storefront', false, false, null],
['dev/debug/template_hints_storefront', true, false, null],
['dev/debug/template_hints_admin', false, false, null],
['dev/debug/template_hints_admin', true, false, null],
];
}

Expand All @@ -119,8 +128,13 @@ public function afterCreateActiveDataProvider()
* @return void
* @dataProvider afterCreateInactiveDataProvider
*/
public function testAfterCreateInactive($debugHintsPath, $isDevAllowed, $showTemplateHints)
{
public function testAfterCreateInactive(
$debugHintsPath,
$isDevAllowed,
$showTemplateHints,
$debugHintsWithParam,
$debugHintsParameter
) {
$this->devHelperMock->expects($this->any())
->method('isDevAllowed')
->willReturn($isDevAllowed);
Expand All @@ -133,12 +147,17 @@ public function testAfterCreateInactive($debugHintsPath, $isDevAllowed, $showTem
->disableOriginalConstructor()
->getMock();

$this->httpMock = $this->createMock(\Magento\Framework\App\Request\Http::class);

$debugHints = new DebugHints(
$this->scopeConfigMock,
$this->storeManager,
$this->devHelperMock,
$this->debugHintsFactory,
$debugHintsPath
$debugHintsPath,
$this->httpMock,
$debugHintsWithParam,
$debugHintsParameter
);

$this->assertSame($engine, $debugHints->afterCreate($subjectMock, $engine));
Expand All @@ -150,12 +169,12 @@ public function testAfterCreateInactive($debugHintsPath, $isDevAllowed, $showTem
public function afterCreateInactiveDataProvider()
{
return [
['dev/debug/template_hints_storefront', false, false],
['dev/debug/template_hints_storefront', false, true],
['dev/debug/template_hints_storefront', true, false],
['dev/debug/template_hints_admin', false, false],
['dev/debug/template_hints_admin', false, true],
['dev/debug/template_hints_admin', true, false],
['dev/debug/template_hints_storefront', false, false, false, null],
['dev/debug/template_hints_storefront', false, true, false, null],
['dev/debug/template_hints_storefront', true, false, false, null],
['dev/debug/template_hints_admin', false, false, false, null],
['dev/debug/template_hints_admin', false, true, false, null],
['dev/debug/template_hints_admin', true, false, false, null],
];
}

Expand Down
2 changes: 2 additions & 0 deletions app/code/Magento/Developer/etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<type name="Magento\Developer\Model\TemplateEngine\Plugin\DebugHints">
<arguments>
<argument name="debugHintsPath" xsi:type="string">dev/debug/template_hints_admin</argument>
<argument name="debugHintsWithParam" xsi:type="string">dev/debug/template_hints_storefront_show_with_parameter</argument>
<argument name="debugHintsParameter" xsi:type="string">dev/debug/template_hints_parameter_value</argument>
</arguments>
</type>
</config>
4 changes: 4 additions & 0 deletions app/code/Magento/Developer/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<dev>
<debug>
<template_hints_storefront_show_with_parameter>0</template_hints_storefront_show_with_parameter>
<template_hints_parameter_value>magento</template_hints_parameter_value>
</debug>
<restrict>
<allow_ips />
</restrict>
Expand Down
2 changes: 2 additions & 0 deletions app/code/Magento/Developer/etc/frontend/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<type name="Magento\Developer\Model\TemplateEngine\Plugin\DebugHints">
<arguments>
<argument name="debugHintsPath" xsi:type="string">dev/debug/template_hints_storefront</argument>
<argument name="debugHintsWithParam" xsi:type="string">dev/debug/template_hints_storefront_show_with_parameter</argument>
<argument name="debugHintsParameter" xsi:type="string">dev/debug/template_hints_parameter_value</argument>
</arguments>
</type>
</config>
2 changes: 2 additions & 0 deletions app/code/Magento/Directory/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
<argument name="countriesWithNotRequiredStates" xsi:type="array">
<item name="FR" xsi:type="string">FR</item>
<item name="DE" xsi:type="string">DE</item>
<item name="AT" xsi:type="string">AT</item>
<item name="FI" xsi:type="string">FI</item>
</argument>
</arguments>
</type>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<container name="product.info.grouped.extra" after="product.info.grouped" before="product.info.grouped" as="product_type_data_extra" label="Product Extra Info"/>
</referenceContainer>
<referenceContainer name="product.info.grouped.extra">
<block class="Magento\GroupedProduct\Block\Stockqty\Type\Grouped" template="Magento_CatalogInventory::stockqty/composite.phtml"/>
<block class="Magento\GroupedProduct\Block\Stockqty\Type\Grouped" name="product.info.grouped.stock-composite" template="Magento_CatalogInventory::stockqty/composite.phtml"/>
</referenceContainer>
<referenceContainer name="product.info.type">
<block class="Magento\GroupedProduct\Block\Product\View\Type\Grouped" as="product.info.grouped" template="Magento_GroupedProduct::product/view/type/default.phtml"/>
<block class="Magento\GroupedProduct\Block\Product\View\Type\Grouped" name="product.info.grouped.stock" as="product.info.grouped" template="Magento_GroupedProduct::product/view/type/default.phtml"/>
</referenceContainer>
</body>
</page>
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@
min-width: 100%;
position: static;

._parent._visible {
position: relative;
}

.action-submenu {
position: absolute;
}
Expand Down
3 changes: 1 addition & 2 deletions lib/internal/Magento/Framework/Phrase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@

use Magento\Framework\Phrase\Renderer\Placeholder as RendererPlaceholder;
use Magento\Framework\Phrase\RendererInterface;
use Zend\Stdlib\JsonSerializable;

/**
* @api
*/
class Phrase implements JsonSerializable
class Phrase implements \JsonSerializable
{
/**
* Default phrase renderer. Allows stacking renderers that "don't know about each other"
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/View/Page/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ public function addRss($title, $href)
*/
public function addBodyClass($className)
{
$className = preg_replace('#[^a-z0-9]+#', '-', strtolower($className));
$className = preg_replace('#[^a-z0-9-_]+#', '-', strtolower($className));
$bodyClasses = $this->getElementAttribute(self::ELEMENT_TYPE_BODY, self::BODY_ATTRIBUTE_CLASS);
$bodyClasses = $bodyClasses ? explode(' ', $bodyClasses) : [];
$bodyClasses[] = $className;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ public function testProcess()
->method('getPageConfigStructure')
->willReturn($structureMock);

$bodyClasses = ['class_1', 'class_2'];
$bodyClasses = ['class_1', 'class--2'];
$structureMock->expects($this->once())
->method('getBodyClasses')
->will($this->returnValue($bodyClasses));
$this->pageConfigMock->expects($this->exactly(2))
->method('addBodyClass')
->withConsecutive(['class_1'], ['class_2']);
->withConsecutive(['class_1'], ['class--2']);

$this->assertEquals(
$this->bodyGenerator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testSetElementAttribute()
public function testSetBodyClass()
{
$class1 = 'class_1';
$class2 = 'class_2';
$class2 = 'class--2';
$expected = [$class1, $class2];
$this->structure->setBodyClass($class1);
$this->structure->setBodyClass($class2);
Expand Down
2 changes: 1 addition & 1 deletion pub/errors/processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public function getHostUrl()
$isSecure = (!empty($_SERVER['HTTPS'])) && ($_SERVER['HTTPS'] != 'off');
$url = ($isSecure ? 'https://' : 'http://') . $host;

if (!empty($_SERVER['SERVER_PORT']) && !in_array($_SERVER['SERVER_PORT'], [80, 433])
if (!empty($_SERVER['SERVER_PORT']) && !in_array($_SERVER['SERVER_PORT'], [80, 443])
&& !preg_match('/.*?\:[0-9]+$/', $url)
) {
$url .= ':' . $_SERVER['SERVER_PORT'];
Expand Down

0 comments on commit feb1c5a

Please sign in to comment.