Skip to content

Commit

Permalink
Merge branch '5' into 6
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Forms/GridField/GridFieldDataColumns.php
#	src/Model/ModelData.php
#	src/View/SSViewer.php
#	src/View/SSViewer_DataPresenter.php
#	src/View/SSViewer_FromString.php
#	src/View/SSViewer_Scope.php
  • Loading branch information
GuySartorelli committed Oct 22, 2024
2 parents ba97de9 + 165f72f commit 8e08b1c
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 13 deletions.
3 changes: 3 additions & 0 deletions src/Forms/GridField/GridFieldDataColumns.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use InvalidArgumentException;
use LogicException;
use SilverStripe\Model\ModelData;
use SilverStripe\Dev\Deprecation;

/**
* @see GridField
Expand Down Expand Up @@ -228,9 +229,11 @@ public function getColumnMetadata($gridField, $column)
* @param ModelData $record
* @param string $columnName
* @return string|null - returns null if it could not found a value
* @deprecated 5.4.0 Will be removed without equivalent functionality to replace it.
*/
protected function getValueFromRelation($record, $columnName)
{
Deprecation::notice('5.4.0', 'Will be removed without equivalent functionality to replace it.');
$fieldNameParts = explode('.', $columnName ?? '');
$tmpItem = clone($record);
for ($idx = 0; $idx < sizeof($fieldNameParts ?? []); $idx++) {
Expand Down
18 changes: 18 additions & 0 deletions src/Model/ModelData.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\Debug;
use SilverStripe\Core\ArrayLib;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Model\List\ArrayList;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\ORM\FieldType\DBHTMLText;
Expand Down Expand Up @@ -385,9 +386,12 @@ protected function defaultCastingHelper(string $field): string

/**
* Get the class name a field on this object will be casted to.
*
* @deprecated 5.4.0 Will be removed without equivalent functionality to replace it.
*/
public function castingClass(string $field): string
{
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be removed without equivalent functionality to replace it.');
// Strip arguments
$spec = $this->castingHelper($field);
return trim(strtok($spec ?? '', '(') ?? '');
Expand All @@ -397,9 +401,11 @@ public function castingClass(string $field): string
* Return the string-format type for the given field.
*
* @return string 'xml'|'raw'
* @deprecated 5.4.0 Will be removed without equivalent functionality to replace it.
*/
public function escapeTypeForField(string $field): string
{
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be removed without equivalent functionality to replace it.');
$class = $this->castingClass($field) ?: $this->config()->get('default_cast');

/** @var DBField $type */
Expand Down Expand Up @@ -445,9 +451,11 @@ public function renderWith($template, ModelData|array|null $customFields = null)
* @param string $fieldName Name of field
* @param array $arguments List of optional arguments given
* @return string
* @deprecated 5.4.0 Will be made private
*/
protected function objCacheName($fieldName, $arguments)
{
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be made private');
return $arguments
? $fieldName . ":" . var_export($arguments, true)
: $fieldName;
Expand Down Expand Up @@ -506,6 +514,9 @@ public function obj(
bool $cache = false,
?string $cacheName = null
): ?object {
if ($cacheName !== null) {
Deprecation::noticeWithNoReplacment('5.4.0', 'The $cacheName parameter has been deprecated and will be removed');
}
$hasObj = false;
if (!$cacheName && $cache) {
$cacheName = $this->objCacheName($fieldName, $arguments);
Expand Down Expand Up @@ -569,9 +580,11 @@ public function obj(
* without re-running the method.
*
* @return Object|DBField
* @deprecated 5.4.0 use obj() instead
*/
public function cachedCall(string $fieldName, array $arguments = [], ?string $cacheName = null): object
{
Deprecation::notice('5.4.0', 'Use obj() instead');
return $this->obj($fieldName, $arguments, true, $cacheName);
}

Expand All @@ -591,9 +604,12 @@ public function hasValue(string $field, array $arguments = [], bool $cache = tru
/**
* Get the string value of a field on this object that has been suitable escaped to be inserted directly into a
* template.
*
* @deprecated 5.4.0 Will be removed without equivalent functionality to replace it
*/
public function XML_val(string $field, array $arguments = [], bool $cache = false): string
{
Deprecation::noticeWithNoReplacment('5.4.0');
$result = $this->obj($field, $arguments, $cache);
if (!$result) {
return '';
Expand All @@ -606,9 +622,11 @@ public function XML_val(string $field, array $arguments = [], bool $cache = fals
* Get an array of XML-escaped values by field name
*
* @param array $fields an array of field names
* @deprecated 5.4.0 Will be removed without equivalent functionality to replace it
*/
public function getXMLValues(array $fields): array
{
Deprecation::noticeWithNoReplacment('5.4.0');
$result = [];

foreach ($fields as $field) {
Expand Down
2 changes: 1 addition & 1 deletion src/View/SSTemplateParser.peg
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ class SSTemplateParser extends Parser implements TemplateParser
$arguments = $res['arguments'];

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

if ($this->includeDebuggingComments) { // Add include filename comments on dev sites
Expand Down
2 changes: 1 addition & 1 deletion src/View/SSTemplateParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3897,7 +3897,7 @@ function Include__finalise(&$res)
$arguments = $res['arguments'];

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

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

0 comments on commit 8e08b1c

Please sign in to comment.