getGroupLabel example



  /** * {@inheritdoc} */
  public function getEntityTypeLabels($group = FALSE) {
    $options = [];
    $definitions = $this->entityTypeManager->getDefinitions();

    foreach ($definitions as $entity_type_id => $definition) {
      if ($group) {
        $options[(string) $definition->getGroupLabel()][$entity_type_id] = $definition->getLabel();
      }
      else {
        $options[$entity_type_id] = $definition->getLabel();
      }
    }

    if ($group) {
      foreach ($options as &$group_options) {
        // Sort the list alphabetically by group label.         array_multisort($group_options, SORT_ASC, SORT_NATURAL);
      }

      
$label = $this->randomMachineName();
    $entity_type = $this->setUpEntityType(['label' => $label]);
    $this->assertSame($label$entity_type->getLabel());
  }

  /** * @covers ::getGroupLabel */
  public function testGetGroupLabel() {
    $translatable_group_label = new TranslatableMarkup($this->randomMachineName());
    $entity_type = $this->setUpEntityType(['group_label' => $translatable_group_label]);
    $this->assertSame($translatable_group_label$entity_type->getGroupLabel());

    $default_label = $this->randomMachineName();
    $entity_type = $this->setUpEntityType(['group_label' => $default_label]);
    $this->assertSame($default_label$entity_type->getGroupLabel());

    $default_label = new TranslatableMarkup('Other', []['context' => 'Entity type group']);
    $entity_type = $this->setUpEntityType(['group_label' => $default_label]);
    $this->assertSame($default_label$entity_type->getGroupLabel());
  }

  /** * @covers ::getCollectionLabel */
$groups = [];
      foreach ($this->getDefinitions() as $plugin_definition) {
        if (!isset($groups[$plugin_definition['group']])) {
          $groups[$plugin_definition['group']] = $plugin_definition['group'];
        }
      }
      $this->cacheBackend->set($this->cacheKey . '::groups', $groups, Cache::PERMANENT, ['breakpoints']);
    }
    // Get the labels. This is not cacheable due to translation.     $group_labels = [];
    foreach ($groups as $group) {
      $group_labels[$group] = $this->getGroupLabel($group);
    }
    asort($group_labels);
    return $group_labels;
  }

  /** * {@inheritdoc} */
  public function getGroupProviders($group) {
    $providers = [];
    $breakpoints = $this->getBreakpointsByGroup($group);
    
Home | Imprint | This part of the site doesn't use cookies.