Skip to content

Commit 0a9f3b7

Browse files
committed
Fixed deprecated usage of <% control %>
1 parent b8a51c3 commit 0a9f3b7

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

forms/CompositeField.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function __construct($children = null) {
6161
}
6262

6363
/**
64-
* Returns all the sub-fields, suitable for <% control FieldList %>
64+
* Returns all the sub-fields, suitable for <% loop FieldList %>
6565
*
6666
* @return FieldList
6767
*/

forms/Form.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ public function callfieldmethod($data) {
12271227
* Return a rendered version of this form.
12281228
*
12291229
* This is returned when you access a form as $FormObject rather
1230-
* than <% control FormObject %>
1230+
* than <% with FormObject %>
12311231
*/
12321232
public function forTemplate() {
12331233
$return = $this->renderWith(array_merge(

tests/view/SSViewerCacheBlockTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public function testNestedBlocks() {
206206

207207
public function testNoErrorMessageForControlWithinCached() {
208208
$this->_reset(true);
209-
$this->assertNotNull($this->_runtemplate('<% cached %><% control Foo %>$Bar<% end_control %><% end_cached %>'));
209+
$this->assertNotNull($this->_runtemplate('<% cached %><% with Foo %>$Bar<% end_with %><% end_cached %>'));
210210
}
211211

212212
/**
@@ -215,13 +215,13 @@ public function testNoErrorMessageForControlWithinCached() {
215215
public function testErrorMessageForCachedWithinControlWithinCached() {
216216
$this->_reset(true);
217217
$this->_runtemplate(
218-
'<% cached %><% control Foo %><% cached %>$Bar<% end_cached %><% end_control %><% end_cached %>');
218+
'<% cached %><% with Foo %><% cached %>$Bar<% end_cached %><% end_with %><% end_cached %>');
219219
}
220220

221221
public function testNoErrorMessageForCachedWithinControlWithinUncached() {
222222
$this->_reset(true);
223223
$this->assertNotNull($this->_runtemplate(
224-
'<% uncached %><% control Foo %><% cached %>$Bar<% end_cached %><% end_control %><% end_uncached %>'));
224+
'<% uncached %><% with Foo %><% cached %>$Bar<% end_cached %><% end_with %><% end_uncached %>'));
225225
}
226226

227227
/**

tests/view/SSViewerTest.php

+17-17
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,12 @@ public function testEscapedArguments() {
275275
);
276276
}
277277

278-
public function testControlWhitespace() {
278+
public function testLoopWhitespace() {
279279
$this->assertEquals(
280280
'before[out:SingleItem.Test]after
281281
beforeTestafter',
282-
$this->render('before<% control SingleItem %>$Test<% end_control %>after
283-
before<% control SingleItem %>Test<% end_control %>after')
282+
$this->render('before<% loop SingleItem %>$Test<% end_loop %>after
283+
before<% loop SingleItem %>Test<% end_loop %>after')
284284
);
285285

286286
// The control tags are removed from the output, but no whitespace
@@ -293,9 +293,9 @@ public function testControlWhitespace() {
293293
294294
after',
295295
$this->render('before
296-
<% control SingleItem %>
296+
<% loop SingleItem %>
297297
$ItemOnItsOwnLine
298-
<% end_control %>
298+
<% end_loop %>
299299
after')
300300
);
301301

@@ -313,9 +313,9 @@ public function testControlWhitespace() {
313313
314314
after',
315315
$this->render('before
316-
<% control Loop3 %>
316+
<% loop Loop3 %>
317317
$ItemOnItsOwnLine
318-
<% end_control %>
318+
<% end_loop %>
319319
after')
320320
);
321321
}
@@ -328,28 +328,28 @@ public function testControls() {
328328
[out:Foo(Arg1).Item]
329329
[out:Foo(Arg1,Arg2).Item]
330330
[out:Foo(Arg1,Arg2,Arg3).Item]',
331-
$this->render('<% control Foo.Bar %>a{$Item}b<% end_control %>
332-
<% control Foo.Bar(Arg1) %>$Item<% end_control %>
333-
<% control Foo(Arg1) %>$Item<% end_control %>
334-
<% control Foo(Arg1, Arg2) %>$Item<% end_control %>
335-
<% control Foo(Arg1, Arg2, Arg3) %>$Item<% end_control %>')
331+
$this->render('<% with Foo.Bar %>a{$Item}b<% end_with %>
332+
<% with Foo.Bar(Arg1) %>$Item<% end_with %>
333+
<% with Foo(Arg1) %>$Item<% end_with %>
334+
<% with Foo(Arg1, Arg2) %>$Item<% end_with %>
335+
<% with Foo(Arg1, Arg2, Arg3) %>$Item<% end_with %>')
336336
);
337337

338338
// Loop controls
339339
$this->assertEquals('a[out:Foo.Loop2.Item]ba[out:Foo.Loop2.Item]b',
340-
$this->render('<% control Foo.Loop2 %>a{$Item}b<% end_control %>'));
340+
$this->render('<% loop Foo.Loop2 %>a{$Item}b<% end_loop %>'));
341341

342342
$this->assertEquals('[out:Foo.Loop2(Arg1).Item][out:Foo.Loop2(Arg1).Item]',
343-
$this->render('<% control Foo.Loop2(Arg1) %>$Item<% end_control %>'));
343+
$this->render('<% loop Foo.Loop2(Arg1) %>$Item<% end_loop %>'));
344344

345345
$this->assertEquals('[out:Loop2(Arg1).Item][out:Loop2(Arg1).Item]',
346-
$this->render('<% control Loop2(Arg1) %>$Item<% end_control %>'));
346+
$this->render('<% loop Loop2(Arg1) %>$Item<% end_loop %>'));
347347

348348
$this->assertEquals('[out:Loop2(Arg1,Arg2).Item][out:Loop2(Arg1,Arg2).Item]',
349-
$this->render('<% control Loop2(Arg1, Arg2) %>$Item<% end_control %>'));
349+
$this->render('<% loop Loop2(Arg1, Arg2) %>$Item<% end_loop %>'));
350350

351351
$this->assertEquals('[out:Loop2(Arg1,Arg2,Arg3).Item][out:Loop2(Arg1,Arg2,Arg3).Item]',
352-
$this->render('<% control Loop2(Arg1, Arg2, Arg3) %>$Item<% end_control %>'));
352+
$this->render('<% loop Loop2(Arg1, Arg2, Arg3) %>$Item<% end_loop %>'));
353353

354354
}
355355

view/SSTemplateParser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3544,7 +3544,7 @@ function ClosedBlock_Handle_Loop(&$res) {
35443544
* @deprecated
35453545
*/
35463546
function ClosedBlock_Handle_Control(&$res) {
3547-
Deprecation::notice('3.1', 'Use <% with %> or <% loop %> instead.');
3547+
Deprecation::notice('3.1', '<% control %> is deprecated. Use <% with %> or <% loop %> instead.');
35483548
return $this->ClosedBlock_Handle_Loop($res);
35493549
}
35503550

0 commit comments

Comments
 (0)