Skip to content

Commit 5cce5b1

Browse files
committed
Merge remote-tracking branch 'origin/MC-41018' into 2.4.3-develop-pr132
2 parents fab0005 + a243294 commit 5cce5b1

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutValidator.php

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,8 @@ public function __construct(
4848
*/
4949
public function validate(array $data) : bool
5050
{
51-
$layoutUpdate = isset($data['layout_update_xml']) ? $data['layout_update_xml'] : null;
52-
$customLayoutUpdate = isset($data['custom_layout_update_xml']) ? $data['custom_layout_update_xml'] : null;
51+
[$layoutUpdate, $customLayoutUpdate, $oldLayoutUpdate, $oldCustomLayoutUpdate] = $this->getLayoutUpdates($data);
5352
if (isset($data['page_id'])) {
54-
$page = $this->pageFactory->getById($data['page_id']);
55-
$oldLayoutUpdate = $page->getId() ? $page->getLayoutUpdateXml() : null;
56-
$oldCustomLayoutUpdate = $page->getId() ? $page->getCustomLayoutUpdateXml() : null;
5753
if ($layoutUpdate && $oldLayoutUpdate !== $layoutUpdate
5854
|| $customLayoutUpdate && $oldCustomLayoutUpdate !== $customLayoutUpdate
5955
) {
@@ -66,4 +62,26 @@ public function validate(array $data) : bool
6662
}
6763
return true;
6864
}
65+
66+
/**
67+
* Gets page layout update values
68+
*
69+
* @param array $data
70+
* @return array
71+
* @throws \Magento\Framework\Exception\NoSuchEntityException
72+
*/
73+
private function getLayoutUpdates(array $data) : array
74+
{
75+
$layoutUpdate = $data['layout_update_xml'] ?? null;
76+
$customLayoutUpdate = $data['custom_layout_update_xml'] ?? null;
77+
$oldLayoutUpdate = null;
78+
$oldCustomLayoutUpdate = null;
79+
if (isset($data['page_id'])) {
80+
$page = $this->pageFactory->getById($data['page_id']);
81+
$oldLayoutUpdate = $page->getId() ? $page->getLayoutUpdateXml() : null;
82+
$oldCustomLayoutUpdate = $page->getId() ? $page->getCustomLayoutUpdateXml() : null;
83+
}
84+
85+
return [$layoutUpdate, $customLayoutUpdate, $oldLayoutUpdate, $oldCustomLayoutUpdate];
86+
}
6987
}

0 commit comments

Comments
 (0)