You are here

public function ChildEntityWarning::getWarning in Entity Reference Hierarchy 8.2

Same name and namespace in other branches
  1. 3.x src/Information/ChildEntityWarning.php \Drupal\entity_hierarchy\Information\ChildEntityWarning::getWarning()

Gets warning message for deleting a parent.

Return value

\Drupal\Core\StringTranslation\PluralTranslatableMarkup Warning message.

File

src/Information/ChildEntityWarning.php, line 79

Class

ChildEntityWarning
Defines a value object for a child entity warning.

Namespace

Drupal\entity_hierarchy\Information

Code

public function getWarning() {
  if ($this->parent) {
    return new PluralTranslatableMarkup($this->relatedEntities
      ->count() - 1, 'This Test entity has 1 child, deleting this item will change its parent to be @parent.', 'This Test entity has @count children, deleting this item will change their parent to be @parent.', [
      '@parent' => $this->relatedEntities
        ->offsetGet($this->parent)
        ->label(),
    ]);
  }
  return new PluralTranslatableMarkup($this->relatedEntities
    ->count(), 'This Test entity has 1 child, deleting this item will move that item to the root of the hierarchy.', 'This Test entity has @count children, deleting this item will move those items to the root of the hierarchy.');
}