Chris@0: getCountLabel(1); Chris@0: * Chris@0: * // Returns: 5 items Chris@0: * $entity_type->getCountLabel(5); Chris@0: * @endcode Chris@0: * Chris@0: * @see \Drupal\Core\Entity\EntityType::getSingularLabel() Chris@0: * @see \Drupal\Core\Entity\EntityType::getPluralLabel() Chris@0: * @see \Drupal\Core\Entity\EntityType::getCountLabel() Chris@0: * Chris@0: * @ingroup plugin_translatable Chris@0: * Chris@0: * @Annotation Chris@0: */ Chris@0: class PluralTranslation extends AnnotationBase { Chris@0: Chris@0: /** Chris@0: * The string for the singular case. Chris@0: * Chris@0: * @var string Chris@0: */ Chris@0: protected $singular; Chris@0: Chris@0: /** Chris@0: * The string for the plural case. Chris@0: * Chris@0: * @var string Chris@0: */ Chris@0: protected $plural; Chris@0: Chris@0: /** Chris@0: * The context the source strings belong to. Chris@0: * Chris@0: * @var string Chris@0: */ Chris@0: protected $context; Chris@0: Chris@0: /** Chris@0: * Constructs a new class instance. Chris@0: * Chris@0: * @param array $values Chris@0: * An associative array with the following keys: Chris@0: * - singular: The string for the singular case. Chris@0: * - plural: The string for the plural case. Chris@0: * - context: The context the source strings belong to. Chris@0: * Chris@0: * @throws \InvalidArgumentException Chris@0: * Thrown when the keys 'singular' or 'plural' are missing from the $values Chris@0: * array. Chris@0: */ Chris@0: public function __construct(array $values) { Chris@0: if (!isset($values['singular'])) { Chris@0: throw new \InvalidArgumentException('Missing "singular" value in the PluralTranslation annotation'); Chris@0: } Chris@0: if (!isset($values['plural'])) { Chris@0: throw new \InvalidArgumentException('Missing "plural" value in the PluralTranslation annotation'); Chris@0: } Chris@0: Chris@0: $this->singular = $values['singular']; Chris@0: $this->plural = $values['plural']; Chris@0: if (isset($values['context'])) { Chris@0: $this->context = $values['context']; Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function get() { Chris@0: return [ Chris@0: 'singular' => $this->singular, Chris@0: 'plural' => $this->plural, Chris@0: 'context' => $this->context, Chris@0: ]; Chris@0: } Chris@0: Chris@0: }