Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/EntityType.php \Drupal\Core\Entity\EntityType::getCountLabel()
  2. 9 core/lib/Drupal/Core/Entity/EntityType.php \Drupal\Core\Entity\EntityType::getCountLabel()

Gets the label's definite article form for use with a count of entities.

This label should be used when the quantity of entities is provided. The name should be returned in a form usable with a count of the entities. For example: "1 opportunity", "5 opportunities", "1 child", "6 children", "1 content item", "25 content items".

Parameters

int $count: The item count to display if the plural form was requested.

Return value

string|\Drupal\Core\StringTranslation\TranslatableMarkup The count label.

Overrides EntityTypeInterface::getCountLabel

File

core/lib/Drupal/Core/Entity/EntityType.php, line 789

Class

EntityType
Provides an implementation of an entity type and its metadata.

Namespace

Drupal\Core\Entity

Code

public function getCountLabel($count) {
  if (empty($this->label_count)) {
    return $this
      ->formatPlural($count, '@count @label', '@count @label entities', [
      '@label' => $this
        ->getSingularLabel(),
    ], [
      'context' => 'Entity type label',
    ]);
  }
  $options = [];
  if (isset($this->label_count['context'])) {
    $options['context'] = $this->label_count['context'];
  }
  return $this
    ->formatPlural($count, $this->label_count['singular'], $this->label_count['plural'], [], $options);
}