Skip to content

Commit c183a1c

Browse files
author
Yuri Kovsher
committed
Merge remote-tracking branch 'tango-ce/MAGETWO-36563' into MAGETWO-37436
2 parents 1ce0880 + 4abbb01 commit c183a1c

File tree

5 files changed

+56
-74
lines changed

5 files changed

+56
-74
lines changed

app/code/Magento/Developer/Model/View/Layout/Plugin.php

Lines changed: 0 additions & 61 deletions
This file was deleted.

app/code/Magento/Developer/etc/di.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
<type name="Magento\Framework\View\TemplateEngineFactory">
1111
<plugin name="debug_hints" type="Magento\Developer\Model\TemplateEngine\Plugin\DebugHints" sortOrder="10"/>
1212
</type>
13-
<type name="Magento\Framework\View\Layout">
14-
<plugin name="exception_handler" type="Magento\Developer\Model\View\Layout\Plugin" sortOrder="10"/>
15-
</type>
1613
<type name="Magento\Framework\View\Result\Page">
1714
<arguments>
1815
<argument name="pageConfigRendererFactory" xsi:type="object">Magento\Developer\Model\View\Page\Config\RendererFactory</argument>

dev/tests/integration/testsuite/Magento/Review/Controller/ProductTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ProductTest extends \Magento\TestFramework\TestCase\AbstractController
1414
public function testListActionDesign($productId, $expectedDesign)
1515
{
1616
$this->getRequest()->setParam('id', $productId);
17-
$this->dispatch('review/product/list');
17+
$this->dispatch('review/product/listAction');
1818
$result = $this->getResponse()->getBody();
1919
$this->assertContains("static/frontend/{$expectedDesign}/en_US/Magento_Theme/favicon.ico", $result);
2020
}

lib/internal/Magento/Framework/View/Layout.php

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
use Magento\Framework\Message\ManagerInterface as MessageManagerInterface;
1111
use Magento\Framework\View\Layout\Element;
1212
use Magento\Framework\View\Layout\ScheduledStructure;
13+
use Magento\Framework\App\State as AppState;
14+
use Psr\Log\LoggerInterface as Logger;
15+
use Magento\Framework\Exception\LocalizedException;
1316

1417
/**
1518
* Layout model
@@ -152,6 +155,16 @@ class Layout extends \Magento\Framework\Simplexml\Config implements \Magento\Fra
152155
*/
153156
protected $readerContext;
154157

158+
/**
159+
* @var \Magento\Framework\App\State
160+
*/
161+
protected $appState;
162+
163+
/**
164+
* @var \Psr\Log\LoggerInterface
165+
*/
166+
protected $logger;
167+
155168
/**
156169
* @param Layout\ProcessorFactory $processorFactory
157170
* @param ManagerInterface $eventManager
@@ -163,6 +176,8 @@ class Layout extends \Magento\Framework\Simplexml\Config implements \Magento\Fra
163176
* @param FrontendInterface $cache
164177
* @param Layout\Reader\ContextFactory $readerContextFactory
165178
* @param Layout\Generator\ContextFactory $generatorContextFactory
179+
* @param \Magento\Framework\App\State $appState
180+
* @param \Psr\Log\LoggerInterface $logger
166181
* @param bool $cacheable
167182
*/
168183
public function __construct(
@@ -176,6 +191,8 @@ public function __construct(
176191
FrontendInterface $cache,
177192
Layout\Reader\ContextFactory $readerContextFactory,
178193
Layout\Generator\ContextFactory $generatorContextFactory,
194+
AppState $appState,
195+
Logger $logger,
179196
$cacheable = true
180197
) {
181198
$this->_elementClass = 'Magento\Framework\View\Layout\Element';
@@ -190,9 +207,10 @@ public function __construct(
190207
$this->generatorPool = $generatorPool;
191208
$this->cacheable = $cacheable;
192209
$this->cache = $cache;
193-
194210
$this->readerContextFactory = $readerContextFactory;
195211
$this->generatorContextFactory = $generatorContextFactory;
212+
$this->appState = $appState;
213+
$this->logger = $logger;
196214
}
197215

198216
/**
@@ -467,15 +485,25 @@ public function renderElement($name, $useCache = true)
467485
*
468486
* @param string $name
469487
* @return string
488+
* @throws \Exception
470489
*/
471490
public function renderNonCachedElement($name)
472491
{
473-
if ($this->isUiComponent($name)) {
474-
$result = $this->_renderUiComponent($name);
475-
} elseif ($this->isBlock($name)) {
476-
$result = $this->_renderBlock($name);
477-
} else {
478-
$result = $this->_renderContainer($name);
492+
$result = '';
493+
try {
494+
if ($this->isUiComponent($name)) {
495+
$result = $this->_renderUiComponent($name);
496+
} elseif ($this->isBlock($name)) {
497+
$result = $this->_renderBlock($name);
498+
} else {
499+
$result = $this->_renderContainer($name);
500+
}
501+
} catch (\Exception $e) {
502+
if ($this->appState->getMode() === AppState::MODE_DEVELOPER) {
503+
throw $e;
504+
}
505+
$message = ($e instanceof LocalizedException) ? $e->getLogMessage() : $e->getMessage();
506+
$this->logger->critical($message);
479507
}
480508
return $result;
481509
}

lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ class LayoutTest extends \PHPUnit_Framework_TestCase
8686
*/
8787
protected $generatorContextFactoryMock;
8888

89+
/**
90+
* @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject
91+
*/
92+
protected $appStateMock;
93+
94+
/**
95+
* @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject
96+
*/
97+
protected $loggerMock;
98+
8999
protected function setUp()
90100
{
91101
$this->structureMock = $this->getMockBuilder('Magento\Framework\View\Layout\Data\Structure')
@@ -136,8 +146,14 @@ protected function setUp()
136146
->getMock();
137147
$this->generatorContextFactoryMock = $this->getMockBuilder(
138148
'Magento\Framework\View\Layout\Generator\ContextFactory'
139-
)->disableOriginalConstructor()
140-
->getMock();
149+
)
150+
->disableOriginalConstructor()
151+
->getMock();
152+
$this->appStateMock = $this->getMockBuilder('Magento\Framework\App\State')
153+
->disableOriginalConstructor()
154+
->getMock();
155+
$this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface')
156+
->getMock();
141157

142158
$this->model = new \Magento\Framework\View\Layout(
143159
$this->processorFactoryMock,
@@ -150,6 +166,8 @@ protected function setUp()
150166
$this->cacheMock,
151167
$this->readerContextFactoryMock,
152168
$this->generatorContextFactoryMock,
169+
$this->appStateMock,
170+
$this->loggerMock,
153171
true
154172
);
155173
}

0 commit comments

Comments
 (0)