Skip to content

Commit

Permalink
API Deprecate BaseElement::getDescription() (#1196)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored May 29, 2024
1 parent 9f27780 commit 35c723d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Models/BaseElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use SilverStripe\View\Requirements;
use SilverStripe\ORM\CMSPreviewable;
use SilverStripe\Core\Config\Config;
use SilverStripe\Dev\Deprecation;
use SilverStripe\ORM\DataObjectSchema;

/**
Expand Down Expand Up @@ -553,7 +554,7 @@ public function getContentForCmsSearch(): string
}
// Allow projects to update contents of third-party elements.
$this->extend('updateContentForCmsSearch', $contents);

// Use |#| to delimit different fields rather than space so that you don't
// accidentally join results of two columns that are next to each other in a table
$content = implode('|#|', array_filter($contents));
Expand Down Expand Up @@ -1142,10 +1143,13 @@ public function getIcon()
/**
* Get a description for this content element, if available
*
* @deprecated 5.3.0 Use the description configuration property and localisation API directly instead.
*
* @return string
*/
public function getDescription()
{
Deprecation::notice('5.3.0', 'Use getTypeNice() or the description configuration property directly instead.');
$description = $this->config()->uninherited('description');
if ($description) {
return _t(__CLASS__ . '.Description', $description);
Expand All @@ -1161,7 +1165,7 @@ public function getDescription()
*/
public function getTypeNice()
{
$description = $this->getDescription();
$description = Deprecation::withNoReplacement(fn () => $this->getDescription());
$desc = ($description) ? ' <span class="element__note"> &mdash; ' . $description . '</span>' : '';

return DBField::create_field(
Expand Down

0 comments on commit 35c723d

Please sign in to comment.