Skip to content

Commit c474606

Browse files
committed
API Deprecations for template layer
1 parent 483e944 commit c474606

17 files changed

+273
-102
lines changed

src/Control/Email/Email.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use SilverStripe\Core\Extensible;
1313
use SilverStripe\Core\Injector\Injectable;
1414
use SilverStripe\Core\Injector\Injector;
15+
use SilverStripe\Dev\Deprecation;
1516
use SilverStripe\ORM\FieldType\DBField;
1617
use SilverStripe\View\ArrayData;
1718
use SilverStripe\View\Requirements;
@@ -402,9 +403,11 @@ public function getHTMLTemplate(): string
402403
return $this->HTMLTemplate;
403404
}
404405

405-
return ThemeResourceLoader::inst()->findTemplate(
406-
SSViewer::get_templates_by_class(static::class, '', Email::class),
407-
SSViewer::get_themes()
406+
return Deprecation::withSuppressedNotice(
407+
fn() => ThemeResourceLoader::inst()->findTemplate(
408+
SSViewer::get_templates_by_class(static::class, '', Email::class),
409+
SSViewer::get_themes()
410+
)
408411
);
409412
}
410413

src/Forms/GridField/GridFieldAddExistingAutocompleter.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use SilverStripe\View\SSViewer;
1818
use LogicException;
1919
use SilverStripe\Control\HTTPResponse_Exception;
20+
use SilverStripe\Dev\Deprecation;
2021

2122
/**
2223
* This class is is responsible for adding objects to another object's has_many
@@ -283,7 +284,7 @@ public function doSearch($gridField, $request)
283284
$json = [];
284285
Config::nest();
285286
SSViewer::config()->set('source_file_comments', false);
286-
$viewer = SSViewer::fromString($this->resultsFormat);
287+
$viewer = Deprecation::withSuppressedNotice(fn() => SSViewer::fromString($this->resultsFormat));
287288
foreach ($results as $result) {
288289
if (!$result->canView()) {
289290
continue;

src/Forms/GridField/GridFieldDataColumns.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use SilverStripe\Core\Convert;
66
use InvalidArgumentException;
77
use LogicException;
8+
use SilverStripe\Dev\Deprecation;
89
use SilverStripe\View\ViewableData;
910

1011
/**
@@ -228,16 +229,18 @@ public function getColumnMetadata($gridField, $column)
228229
* @param ViewableData $record
229230
* @param string $columnName
230231
* @return string|null - returns null if it could not found a value
232+
* @deprecated 5.4.0 Will be removed without equivalent functionality to replace it.
231233
*/
232234
protected function getValueFromRelation($record, $columnName)
233235
{
236+
Deprecation::notice('5.4.0', 'Will be removed without equivalent functionality to replace it.');
234237
$fieldNameParts = explode('.', $columnName ?? '');
235238
$tmpItem = clone($record);
236239
for ($idx = 0; $idx < sizeof($fieldNameParts ?? []); $idx++) {
237240
$methodName = $fieldNameParts[$idx];
238241
// Last mmethod call from $columnName return what that method is returning
239242
if ($idx == sizeof($fieldNameParts ?? []) - 1) {
240-
return $tmpItem->XML_val($methodName);
243+
return Deprecation::withSuppressedNotice(fn() => $tmpItem->XML_val($methodName));
241244
}
242245
// else get the object from this $methodName
243246
$tmpItem = $tmpItem->$methodName();

src/Forms/HTMLEditor/HTMLEditorField.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use SilverStripe\ORM\DataObject;
99
use SilverStripe\ORM\DataObjectInterface;
1010
use Exception;
11+
use SilverStripe\Dev\Deprecation;
1112
use SilverStripe\View\Parsers\HTMLValue;
1213

1314
/**
@@ -129,7 +130,9 @@ public function getAttributes()
129130
*/
130131
public function saveInto(DataObjectInterface $record)
131132
{
132-
if ($record->hasField($this->name) && $record->escapeTypeForField($this->name) != 'xml') {
133+
if ($record->hasField($this->name)
134+
&& Deprecation::withSuppressedNotice(fn () => $record->escapeTypeForField($this->name)) != 'xml'
135+
) {
133136
throw new Exception(
134137
'HTMLEditorField->saveInto(): This field should save into a HTMLText or HTMLVarchar field.'
135138
);

src/View/SSTemplateParser.peg

+1-1
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ class SSTemplateParser extends Parser implements TemplateParser
948948
$arguments = $res['arguments'];
949949

950950
// Note: 'type' here is important to disable subTemplates in SSViewer::getSubtemplateFor()
951-
$res['php'] = '$val .= \\SilverStripe\\View\\SSViewer::execute_template([["type" => "Includes", '.$template.'], '.$template.'], $scope->getItem(), [' .
951+
$res['php'] = '$val .= \\SilverStripe\\View\\SSViewer::execute_template([["type" => "Includes", '.$template.'], '.$template.'], $scope->getCurrentItem(), [' .
952952
implode(',', $arguments)."], \$scope, true);\n";
953953

954954
if ($this->includeDebuggingComments) { // Add include filename comments on dev sites

0 commit comments

Comments
 (0)