Skip to content

Commit 855573c

Browse files
author
Bohdan Korablov
committed
MAGETWO-43285: If you change page layout on grid, then the node of this page will be removed from hierarchy and Custom Theme will be changed to "Magento Blank"
1 parent bfa0d42 commit 855573c

File tree

6 files changed

+63
-47
lines changed

6 files changed

+63
-47
lines changed

app/code/Magento/Cms/Controller/Adminhtml/Page/InlineEdit.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function execute()
6666
/** @var \Magento\Cms\Model\Page $page */
6767
$page = $this->pageRepository->getById($pageId);
6868
try {
69-
$pageData = $this->dataProcessor->filter($postItems[$pageId]);
69+
$pageData = $this->filterPost($postItems[$pageId]);
7070
$this->validatePost($pageData, $page, $error, $messages);
7171
$extendedPageData = $page->getData();
7272
$this->setCmsPageData($page, $extendedPageData, $pageData);
@@ -92,6 +92,22 @@ public function execute()
9292
]);
9393
}
9494

95+
/**
96+
* Filtering posted data.
97+
*
98+
* @param array $postData
99+
* @return array
100+
*/
101+
protected function filterPost($postData = [])
102+
{
103+
$pageData = $this->dataProcessor->filter($postData);
104+
$pageData['custom_theme'] = isset($pageData['custom_theme']) ? $pageData['custom_theme'] : null;
105+
$pageData['custom_root_template'] = isset($pageData['custom_root_template'])
106+
? $pageData['custom_root_template']
107+
: null;
108+
return $pageData;
109+
}
110+
95111
/**
96112
* Validate post data
97113
*

app/code/Magento/Cms/Model/Page/Source/ThemeFilter.php renamed to app/code/Magento/Cms/Model/Page/Source/CustomLayout.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
namespace Magento\Cms\Model\Page\Source;
77

88
/**
9-
* Theme filter source
9+
* Custom layout source
1010
*/
11-
class ThemeFilter extends Theme
11+
class CustomLayout extends PageLayout
1212
{
1313
/**
1414
* {@inheritdoc}
1515
*/
1616
public function toOptionArray()
1717
{
18-
return array_merge([['label' => '', 'value' => '']], parent::toOptionArray());
18+
return array_merge([['label' => 'Default', 'value' => '']], parent::toOptionArray());
1919
}
2020
}

app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/InlineEditTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ public function prepareMocksForTestExecute()
9090
$postData = [
9191
1 => [
9292
'title' => '404 Not Found',
93-
'identifier' => 'no-route'
93+
'identifier' => 'no-route',
94+
'custom_theme' => '1',
95+
'custom_root_template' => '2'
9496
]
9597
];
9698
$this->request->expects($this->any())
@@ -138,7 +140,9 @@ public function prepareMocksForTestExecute()
138140
->with([
139141
'layout' => '1column',
140142
'title' => '404 Not Found',
141-
'identifier' => 'no-route'
143+
'identifier' => 'no-route',
144+
'custom_theme' => '1',
145+
'custom_root_template' => '2'
142146
]);
143147
$this->jsonFactory->expects($this->once())
144148
->method('create')
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Cms\Test\Unit\Model\Page\Source;
7+
8+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
9+
10+
class CustomLayoutTest extends PageLayoutTest
11+
{
12+
/**
13+
* @return string
14+
*/
15+
protected function getSourceClassName()
16+
{
17+
return 'Magento\Cms\Model\Page\Source\CustomLayout';
18+
}
19+
20+
/**
21+
* {@inheritdoc}
22+
*/
23+
public function getOptionsDataProvider()
24+
{
25+
return [
26+
[
27+
[],
28+
[['label' => 'Default', 'value' => '']],
29+
],
30+
[
31+
['testStatus' => 'testValue'],
32+
[['label' => 'Default', 'value' => ''], ['label' => 'testValue', 'value' => 'testStatus']],
33+
],
34+
];
35+
}
36+
}

app/code/Magento/Cms/Test/Unit/Model/Page/Source/ThemeFilterTest.php

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

app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@
354354
</column>
355355
<column name="custom_root_template">
356356
<argument name="data" xsi:type="array">
357-
<item name="options" xsi:type="object">Magento\Cms\Model\Page\Source\PageLayout</item>
357+
<item name="options" xsi:type="object">Magento\Cms\Model\Page\Source\CustomLayout</item>
358358
<item name="config" xsi:type="array">
359359
<item name="filter" xsi:type="string">select</item>
360360
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item>

0 commit comments

Comments
 (0)