@@ -48,12 +48,8 @@ public function __construct(
48
48
*/
49
49
public function validate (array $ data ) : bool
50
50
{
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 );
53
52
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 ;
57
53
if ($ layoutUpdate && $ oldLayoutUpdate !== $ layoutUpdate
58
54
|| $ customLayoutUpdate && $ oldCustomLayoutUpdate !== $ customLayoutUpdate
59
55
) {
@@ -66,4 +62,26 @@ public function validate(array $data) : bool
66
62
}
67
63
return true ;
68
64
}
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
+ }
69
87
}
0 commit comments