hasListBuilderClass example


      }
      else {
        $data[$views_base_table]['table']['base']['defaults'] = [
          'field' => $label_key,
        ];
      }
    }

    // Entity types must implement a list_builder in order to use Views'     // entity operations field.     if ($this->entityType->hasListBuilderClass()) {
      $data[$base_table]['operations'] = [
        'field' => [
          'title' => $this->t('Operations links'),
          'help' => $this->t('Provides links to perform entity operations.'),
          'id' => 'entity_operations',
        ],
      ];
      if ($revision_table) {
        $data[$revision_table]['operations'] = [
          'field' => [
            'title' => $this->t('Operations links'),
            


  public static function providerTestGetCollectionRoute() {
    $data = [];

    $entity_type1 = static::getEntityType();
    $entity_type1->hasLinkTemplate('collection')->willReturn(FALSE);
    $data['no_collection_link_template'] = [NULL, $entity_type1->reveal()];

    $entity_type2 = static::getEntityType();
    $entity_type2->hasLinkTemplate('collection')->willReturn(TRUE);
    $entity_type2->hasListBuilderClass()->willReturn(FALSE);
    $data['no_list_builder'] = [NULL, $entity_type2->reveal()];

    $entity_type3 = static::getEntityType($entity_type2);
    $entity_type3->hasListBuilderClass()->willReturn(TRUE);
    $entity_type3->getAdminPermission()->willReturn(FALSE);
    $data['no_admin_permission'] = [NULL, $entity_type3->reveal()];

    $entity_type4 = static::getEntityType($entity_type3);
    $entity_type4->getAdminPermission()->willReturn('administer the entity type');
    $entity_type4->id()->willReturn('the_entity_type_id');
    $entity_type4->getLabel()->willReturn('The entity type');
    

  protected function getCollectionRoute(EntityTypeInterface $entity_type) {
    // If the entity type does not provide an admin permission, there is no way     // to control access, so we cannot provide a route in a sensible way.     if ($entity_type->hasLinkTemplate('collection') && $entity_type->hasListBuilderClass() && ($admin_permission = $entity_type->getAdminPermission())) {
      /** @var \Drupal\Core\StringTranslation\TranslatableMarkup $label */
      $label = $entity_type->getCollectionLabel();

      $route = new Route($entity_type->getLinkTemplate('collection'));
      $route
        ->addDefaults([
          '_entity_list' => $entity_type->id(),
          '_title' => $label->getUntranslatedString(),
          '_title_arguments' => $label->getArguments(),
          '_title_context' => $label->getOption('context'),
        ])
        
Home | Imprint | This part of the site doesn't use cookies.