getPluralLabel example

/** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->migration = $this->prophesize(MigrationInterface::class);
    $this->storage = $this->prophesize(EntityStorageInterface::class);

    $this->entityType = $this->prophesize(EntityTypeInterface::class);
    $this->entityType->getPluralLabel()->willReturn('foo');
    $this->storage->getEntityType()->willReturn($this->entityType->reveal());
    $this->storage->getEntityTypeId()->willReturn('foo');

    $this->entityFieldManager = $this->prophesize(EntityFieldManagerInterface::class);
  }

}

/** * Stub class for BaseFieldDefinition. */
$entity_type->setStringTranslation($this->getStringTranslationStub());
    $this->assertEquals('entity test singular', $entity_type->getSingularLabel());
  }

  /** * @covers ::getPluralLabel */
  public function testGetPluralLabel() {
    $translatable_label = new TranslatableMarkup('entity test plural', [][]$this->getStringTranslationStub());
    $entity_type = $this->setUpEntityType(['label_plural' => $translatable_label]);
    $entity_type->setStringTranslation($this->getStringTranslationStub());
    $this->assertEquals('entity test plural', $entity_type->getPluralLabel());
  }

  /** * @covers ::getPluralLabel */
  public function testGetPluralLabelDefault() {
    $entity_type = $this->setUpEntityType(['label' => 'Entity test Plural']);
    $entity_type->setStringTranslation($this->getStringTranslationStub());
    $this->assertEquals('entity test plural entities', $entity_type->getPluralLabel());
  }

  
$migration,
      $container->get('entity_type.manager'),
      $container->get('entity_field.manager'),
      $container->get('entity_type.bundle.info')
    );
  }

  /** * {@inheritdoc} */
  public function __toString() {
    return (string) $this->entityType->getPluralLabel();
  }

  /** * Initializes the iterator with the source data. * * @return \Generator * A data generator for this source. */
  protected function initializeIterator() {
    $ids = $this->query()->execute();
    return $this->yieldEntities($ids);
  }

  protected function assertIdConflictForm(array $entity_types) {
    $session = $this->assertSession();
    /** @var \Drupal\Core\Entity\EntityTypeManager $entity_type_manager */
    $entity_type_manager = \Drupal::service('entity_type.manager');

    $session->pageTextContains('WARNING: Content may be overwritten on your new site.');
    $session->pageTextContains('There is conflicting content of these types:');
    $this->assertNotEmpty($entity_types);
    foreach ($entity_types as $entity_type) {
      $label = $entity_type_manager->getDefinition($entity_type)->getPluralLabel();
      $session->pageTextContains($label);
    }
    $session->pageTextContainsOnce('content items');
    $session->pageTextContains('There is translated content of these types:');
  }

  /** * Helper to assert content on the Review form. * * @param array|null $available_paths * An array of modules that will be upgraded. Defaults to * $this->getAvailablePaths(). * @param array|null $missing_paths * An array of modules that will not be upgraded. Defaults to * $this->getMissingPaths(). * * @throws \Behat\Mink\Exception\ExpectationException */
/** * {@inheritdoc} */
  public function access($entity, AccountInterface $account = NULL, $return_as_object = FALSE) {
    /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
    if ($entity && $this->moderationInfo->isModeratedEntity($entity)) {
      $bundle_info = $this->bundleInfo->getBundleInfo($entity->getEntityTypeId());
      $bundle_label = $bundle_info[$entity->bundle()]['label'];
      $this->messenger->addWarning($this->t("@bundle @label were skipped as they are under moderation and may not be directly unpublished.", [
        '@bundle' => $bundle_label,
        '@label' => $entity->getEntityType()->getPluralLabel(),
      ]));
      $result = AccessResult::forbidden('Cannot directly unpublish moderated entities.');
      return $return_as_object ? $result : $result->isAllowed();
    }
    return parent::access($entity$account$return_as_object);
  }

}
$permissions = [];

    /** @var \Drupal\layout_builder\Entity\LayoutEntityDisplayInterface[] $entity_displays */
    $entity_displays = $this->entityTypeManager->getStorage('entity_view_display')->loadByProperties(['third_party_settings.layout_builder.allow_custom' => TRUE]);
    foreach ($entity_displays as $entity_display) {
      $entity_type_id = $entity_display->getTargetEntityTypeId();
      $entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
      $bundle = $entity_display->getTargetBundle();
      $args = [
        '%entity_type' => $entity_type->getCollectionLabel(),
        '@entity_type_singular' => $entity_type->getSingularLabel(),
        '@entity_type_plural' => $entity_type->getPluralLabel(),
        '%bundle' => $this->bundleInfo->getBundleInfo($entity_type_id)[$bundle]['label'],
      ];
      // These permissions are generated on behalf of $entity_display entity       // display, therefore add this entity display as a config dependency.       $dependencies = [
        $entity_display->getConfigDependencyKey() => [
          $entity_display->getConfigDependencyName(),
        ],
      ];
      if ($entity_type->hasKey('bundle')) {
        $permissions["configure all $bundle $entity_type_id layout overrides"] = [
          
'type' => $bundle['label'],
        ];
        // Add the bundle to the list of default values if it's enabled on this         // workflow.         $defaults[$bundle_id] = $workflow_moderation_enabled;
      }
    }

    if (!empty($options)) {
      $bundles_header = $this->t('All @entity_type types', ['@entity_type' => $this->entityType->getLabel()]);
      if ($bundle_entity_type_id = $this->entityType->getBundleEntityType()) {
        $bundles_header = $this->t('All @entity_type_plural_label', ['@entity_type_plural_label' => $this->entityTypeManager->getDefinition($bundle_entity_type_id)->getPluralLabel()]);
      }
      $form['bundles'] = [
        '#type' => 'tableselect',
        '#header' => [
          'type' => $bundles_header,
        ],
        '#options' => $options,
        '#default_value' => $defaults,
        '#attributes' => ['class' => ['no-highlight']],
      ];
    }

    
'#size' => 40,
      '#maxlength' => 255,
      '#default_value' => $domain,
      '#description' => $this->t('Enter a different domain from which to serve oEmbed content, including the <em>http://</em> or <em>https://</em> prefix. This domain needs to point back to this site, or existing oEmbed content may not display correctly, or at all.'),
    ];

    $form['security']['standalone_url'] = [
      '#prefix' => '<hr>',
      '#type' => 'checkbox',
      '#title' => $this->t('Standalone media URL'),
      '#default_value' => $this->config('media.settings')->get('standalone_url'),
      '#description' => $this->t("Allow users to access @media-entities at /media/{id}.", ['@media-entities' => $this->entityTypeManager->getDefinition('media')->getPluralLabel()]),
    ];
    return parent::buildForm($form$form_state);
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->config('media.settings')
      ->set('iframe_domain', $form_state->getValue('iframe_domain'))
      ->set('standalone_url', $form_state->getValue('standalone_url'))
      

  protected function buildMessage(EntityInterface $entity, OverridesSectionStorageInterface $section_storage) {
    $entity_type = $entity->getEntityType();
    $bundle_info = $this->entityTypeBundleInfo->getBundleInfo($entity->getEntityTypeId());

    $variables = [
      '@bundle' => $bundle_info[$entity->bundle()]['label'],
      '@singular_label' => $entity_type->getSingularLabel(),
      '@plural_label' => $entity_type->getPluralLabel(),
    ];

    $defaults_link = $section_storage
      ->getDefaultSectionStorage()
      ->getLayoutBuilderUrl();

    if ($defaults_link->access($this->currentUser())) {
      $variables[':link'] = $defaults_link->toString();
      if ($entity_type->hasKey('bundle')) {
        $message = $this->t('You are editing the layout for this @bundle @singular_label. <a href=":link">Edit the template for all @bundle @plural_label instead.</a>', $variables);
      }
      
    // called.     $entity_type_id = $this->getRouteMatch()->getParameter('entity_type_id');
    return $entity_type_id . '_delete_multiple_confirm_form';
  }

  /** * {@inheritdoc} */
  public function getQuestion() {
    return $this->formatPlural(count($this->selection), 'Are you sure you want to delete this @item?', 'Are you sure you want to delete these @items?', [
      '@item' => $this->entityType->getSingularLabel(),
      '@items' => $this->entityType->getPluralLabel(),
    ]);
  }

  /** * {@inheritdoc} */
  public function getCancelUrl() {
    if ($this->entityType->hasLinkTemplate('collection')) {
      return new Url('entity.' . $this->entityTypeId . '.collection');
    }
    else {
      

  public function render() {
    $build['table'] = [
      '#type' => 'table',
      '#header' => $this->buildHeader(),
      '#title' => $this->getTitle(),
      '#rows' => [],
      '#empty' => $this->t('There are no @label yet.', ['@label' => $this->entityType->getPluralLabel()]),
      '#cache' => [
        'contexts' => $this->entityType->getListCacheContexts(),
        'tags' => $this->entityType->getListCacheTags(),
      ],
    ];
    foreach ($this->load() as $entity) {
      if ($row = $this->buildRow($entity)) {
        $build['table']['#rows'][$entity->id()] = $row;
      }
    }

    
/** * {@inheritdoc} */
  public function validate($module) {
    $entity_types = $this->entityTypeManager->getDefinitions();
    $reasons = [];
    foreach ($entity_types as $entity_type) {
      if ($module == $entity_type->getProvider() && $entity_type instanceof ContentEntityTypeInterface && $this->entityTypeManager->getStorage($entity_type->id())->hasData()) {
        $reasons[] = $this->t('There is content for the entity type: @entity_type. <a href=":url">Remove @entity_type_plural</a>.', [
          '@entity_type' => $entity_type->getLabel(),
          '@entity_type_plural' => $entity_type->getPluralLabel(),
          ':url' => Url::fromRoute('system.prepare_modules_entity_uninstall', ['entity_type_id' => $entity_type->id()])->toString(),
        ]);
      }
    }
    return $reasons;
  }

}

  protected function buildMessage(LayoutEntityDisplayInterface $entity) {
    $entity_type_id = $entity->getTargetEntityTypeId();
    $entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
    $bundle_info = $this->entityTypeBundleInfo->getBundleInfo($entity_type_id);

    $args = [
      '@bundle' => $bundle_info[$entity->getTargetBundle()]['label'],
      '@plural_label' => $entity_type->getPluralLabel(),
    ];
    if ($entity_type->hasKey('bundle')) {
      $message = $this->t('You are editing the layout template for all @bundle @plural_label.', $args);
    }
    else {
      $message = $this->t('You are editing the layout template for all @plural_label.', $args);
    }
    return [
      '#type' => 'container',
      '#attributes' => [
        'class' => [
          

  public function __construct(array $configuration$plugin_id$plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles) {
    $plugin_definition += [
      'label' => $storage->getEntityType()->getPluralLabel(),
    ];

    parent::__construct($configuration$plugin_id$plugin_definition$migration);
    $this->storage = $storage;
    $this->bundles = $bundles;
    $this->supportsRollback = TRUE;
  }

  /** * {@inheritdoc} */
  

  protected function setUp(): void {
    parent::setUp();

    // Setup mocks to be used when creating a revision destination.     $this->migration = $this->prophesize(MigrationInterface::class);
    $this->storage = $this->prophesize('\Drupal\Core\Entity\EntityStorageInterface');

    $entity_type = $this->prophesize(EntityTypeInterface::class);
    $entity_type->getSingularLabel()->willReturn('crazy');
    $entity_type->getPluralLabel()->willReturn('craziness');
    $this->storage->getEntityType()->willReturn($entity_type->reveal());

    $this->entityFieldManager = $this->prophesize('\Drupal\Core\Entity\EntityFieldManagerInterface');
    $this->fieldTypeManager = $this->prophesize('\Drupal\Core\Field\FieldTypePluginManagerInterface');
    $this->accountSwitcher = $this->prophesize(AccountSwitcherInterface::class);
  }

  /** * Tests that passed old destination values are used by default. * * @covers ::getEntity */
Home | Imprint | This part of the site doesn't use cookies.