File tree Expand file tree Collapse file tree 6 files changed +57
-9
lines changed
dev/tests/integration/testsuite/Magento/Framework/View
_files/layout_directives_test
lib/internal/Magento/Framework/View Expand file tree Collapse file tree 6 files changed +57
-9
lines changed Original file line number Diff line number Diff line change @@ -198,6 +198,18 @@ public function testRemove()
198
198
$ this ->assertTrue ($ layout ->isBlock ('child_block2 ' ));
199
199
}
200
200
201
+ /**
202
+ * @magentoAppIsolation enabled
203
+ */
204
+ public function testRemoveCancellation ()
205
+ {
206
+ $ layout = $ this ->_getLayoutModel ('remove_cancellation.xml ' );
207
+ $ this ->assertTrue ($ layout ->isContainer ('container1 ' ));
208
+ $ this ->assertTrue ($ layout ->isBlock ('child_block1 ' ));
209
+ $ this ->assertTrue ($ layout ->isBlock ('no_name2 ' ));
210
+ $ this ->assertFalse ($ layout ->getBlock ('not_exist ' ));
211
+ }
212
+
201
213
/**
202
214
* @magentoAppIsolation enabled
203
215
*/
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" ?>
2
+ <!--
3
+ /**
4
+ * Copyright © Magento, Inc. All rights reserved.
5
+ * See COPYING.txt for license details.
6
+ */
7
+ -->
8
+ <layout >
9
+ <container name =" container1" label =" Container 1" >
10
+ <block class =" Magento\Framework\View\Element\Text" name =" no_name2" />
11
+ </container >
12
+ <referenceContainer name =" container1" remove =" true" />
13
+ <referenceBlock name =" child_block1" remove =" true" />
14
+ <block class =" Magento\Framework\View\Element\Text" name =" block_container" as =" block.container" >
15
+ <block class =" Magento\Framework\View\Element\Text" name =" child_block1" />
16
+ <block class =" Magento\Framework\View\Element\Text" name =" child_block2" />
17
+ </block >
18
+ <referenceContainer name =" not_exist" remove =" false" />
19
+ <referenceContainer name =" container1" remove =" false" />
20
+ <referenceBlock name =" child_block1" remove =" false" />
21
+ </layout >
Original file line number Diff line number Diff line change @@ -207,13 +207,15 @@ protected function scheduleReference(
207
207
$ elementRemove = filter_var ($ currentElement ->getAttribute ('remove ' ), FILTER_VALIDATE_BOOLEAN );
208
208
if ($ elementRemove ) {
209
209
$ scheduledStructure ->setElementToRemoveList ($ elementName );
210
- } else {
211
- $ data = $ scheduledStructure ->getStructureElementData ($ elementName , []);
212
- $ data ['attributes ' ] = $ this ->mergeBlockAttributes ($ data , $ currentElement );
213
- $ this ->updateScheduledData ($ currentElement , $ data );
214
- $ this ->evaluateArguments ($ currentElement , $ data );
215
- $ scheduledStructure ->setStructureElementData ($ elementName , $ data );
210
+ return ;
211
+ } elseif ($ currentElement ->getAttribute ('remove ' )) {
212
+ $ scheduledStructure ->unsetElementFromListToRemove ($ elementName );
216
213
}
214
+ $ data = $ scheduledStructure ->getStructureElementData ($ elementName , []);
215
+ $ data ['attributes ' ] = $ this ->mergeBlockAttributes ($ data , $ currentElement );
216
+ $ this ->updateScheduledData ($ currentElement , $ data );
217
+ $ this ->evaluateArguments ($ currentElement , $ data );
218
+ $ scheduledStructure ->setStructureElementData ($ elementName , $ data );
217
219
}
218
220
219
221
/**
Original file line number Diff line number Diff line change @@ -141,11 +141,12 @@ protected function containerReference(
141
141
) {
142
142
$ containerName = $ currentElement ->getAttribute ('name ' );
143
143
$ containerRemove = filter_var ($ currentElement ->getAttribute ('remove ' ), FILTER_VALIDATE_BOOLEAN );
144
-
145
144
if ($ containerRemove ) {
146
145
$ scheduledStructure ->setElementToRemoveList ($ containerName );
147
- } else {
148
- $ this ->mergeContainerAttributes ($ scheduledStructure , $ currentElement );
146
+ return ;
147
+ } elseif ($ currentElement ->getAttribute ('remove ' )) {
148
+ $ scheduledStructure ->unsetElementFromListToRemove ($ containerName );
149
149
}
150
+ $ this ->mergeContainerAttributes ($ scheduledStructure , $ currentElement );
150
151
}
151
152
}
Original file line number Diff line number Diff line change @@ -188,6 +188,12 @@ public function testProcessReference(
188
188
$ setCondition ,
189
189
$ setRemoveCondition
190
190
) {
191
+ if ($ literal == 'referenceBlock ' && $ remove == 'false ' ) {
192
+ $ this ->scheduledStructure ->expects ($ this ->once ())
193
+ ->method ('unsetElementFromListToRemove ' )
194
+ ->with ($ literal );
195
+ }
196
+
191
197
$ this ->context ->expects ($ this ->once ())->method ('getScheduledStructure ' )
192
198
->will ($ this ->returnValue ($ this ->scheduledStructure ));
193
199
Original file line number Diff line number Diff line change @@ -102,6 +102,12 @@ public function testProcess(
102
102
->with ($ contextMock , $ elementCurrent )
103
103
->willReturnSelf ();
104
104
105
+ if ($ elementCurrent ->getAttribute ('remove ' ) == 'false ' ) {
106
+ $ scheduledStructureMock ->expects ($ this ->once ())
107
+ ->method ('unsetElementFromListToRemove ' )
108
+ ->with ($ elementCurrent ->getAttribute ('name ' ));
109
+ }
110
+
105
111
$ this ->container ->interpret ($ contextMock , $ elementCurrent );
106
112
}
107
113
You can’t perform that action at this time.
0 commit comments