buildRow example

'class' => 'table-filter-text-source',
    ];

    if ($this->displayBundle()) {
      $bundle = $entity->get('bundle');
      $row['bundle'] = [
        'data' => $this->baseEntityBundles[$bundle]['label'],
        'class' => 'table-filter-text-source',
      ];
    }

    return $row + parent::buildRow($entity);
  }

  /** * {@inheritdoc} */
  public function buildHeader() {
    $header['label'] = $this->t('Field');
    if ($this->displayBundle()) {
      $header['bundle'] = $this->baseEntityInfo->getBundleLabel() ?: $this->t('Bundle');
    }
    return $header + parent::buildHeader();
  }
$row['author']['data'] = [
      '#theme' => 'username',
      '#account' => $entity->getOwner(),
    ];
    $row['status'] = $entity->isPublished() ? $this->t('published') : $this->t('not published');
    $row['changed'] = $this->dateFormatter->format($entity->getChangedTime(), 'short');
    $language_manager = \Drupal::languageManager();
    if ($language_manager->isMultilingual()) {
      $row['language_name'] = $language_manager->getLanguageName($entity->language()->getId());
    }
    $row['operations']['data'] = $this->buildOperations($entity);
    return $row + parent::buildRow($entity);
  }

}
'title' => t('List links'),
      'url' => $entity->toUrl('customize-form'),
    ];
    return $operations;
  }

  /** * {@inheritdoc} */
  public function buildRow(EntityInterface $entity) {
    $row['name'] = $entity->label();
    return $row + parent::buildRow($entity);
  }

}

    else {
      $row['form'] = $entity->toLink(NULL, 'canonical')->toString();
      $row['recipients']['data'] = [
        '#theme' => 'item_list',
        '#items' => $entity->getRecipients(),
        '#context' => ['list_style' => 'comma-list'],
      ];
      $default_form = \Drupal::config('contact.settings')->get('default_form');
      $row['selected'] = ($default_form == $entity->id() ? t('Yes') : t('No'));
    }
    return $row + parent::buildRow($entity);
  }

}
$header['label'] = t('Name');
    $header['pattern'] = t('Pattern');
    return $header + parent::buildHeader();
  }

  /** * {@inheritdoc} */
  public function buildRow(EntityInterface $entity) {
    $row['label'] = $entity->label();
    $row['pattern'] = $this->dateFormatter->format(REQUEST_TIME, $entity->id());
    return $row + parent::buildRow($entity);
  }

}
// Setup a view list builder with a mocked buildOperations method,     // because t() is called on there.     $entity_type = $this->createMock('Drupal\Core\Entity\EntityTypeInterface');
    $view_list_builder = new TestViewListBuilder($entity_type$storage$display_manager);
    $view_list_builder->setStringTranslation($this->getStringTranslationStub());

    // Create new view with test values.     $view = new View($values, 'view');

    // Get the row object created by ViewListBuilder for this test view.     $row = $view_list_builder->buildRow($view);

    // Expected output array for view's displays.     $expected_displays = [
      '0' => [
        'display' => 'Embed admin label',
        'path' => FALSE,
      ],
      '1' => [
        'display' => 'Page admin label',
        'path' => '/<object>malformed_path</object>',
      ],
      

  protected function revisionOverview(RevisionableInterface $entity): array {
    $build['entity_revisions_table'] = [
      '#theme' => 'table',
      '#header' => [
        'revision' => ['data' => $this->t('Revision')],
        'operations' => ['data' => $this->t('Operations')],
      ],
    ];

    foreach ($this->loadRevisions($entity) as $revision) {
      $build['entity_revisions_table']['#rows'][$revision->getRevisionId()] = $this->buildRow($revision);
    }

    (new CacheableMetadata())
      // Only dealing with this entity and no external dependencies.       ->addCacheableDependency($entity)
      ->addCacheContexts(['languages:language_content'])
      ->applyTo($build);

    return $build;
  }

  
public function buildHeader() {
    $header = parent::buildHeader();
    $header['status'] = $this->t('Moderation state');

    return $header;
  }

  /** * {@inheritdoc} */
  public function buildRow(EntityInterface $entity) {
    $row = parent::buildRow($entity);
    $row['status'] = $entity->moderation_state->value;

    return $row;
  }

  /** * {@inheritdoc} */
  public function render() {
    $build = parent::render();
    $build['table']['#empty'] = $this->t('There is no moderated @label yet. Only pending versions of @label, such as drafts, are listed here.', ['@label' => $this->entityType->getLabel()]);

    


  /** * {@inheritdoc} */
  public function buildRow(EntityInterface $entity) {
    $row['title'] = [
      'data' => $entity->label(),
      'class' => ['menu-label'],
    ];
    $row['description']['data'] = ['#markup' => $entity->getDescription()];
    return $row + parent::buildRow($entity);
  }

  /** * {@inheritdoc} */
  public function getDefaultOperations(EntityInterface $entity) {
    $operations = parent::getDefaultOperations($entity);
    // Place the edit operation after the operations added by field_ui.module     // which have the weights 15, 20, 25.     if (isset($operations['edit'])) {
      $operations['edit']['weight'] = 30;
    }
$header['type'] = $this->t('Block type');
    $header['description'] = $this->t('Description');
    return $header + parent::buildHeader();
  }

  /** * {@inheritdoc} */
  public function buildRow(EntityInterface $entity) {
    $row['type'] = $entity->toLink(NULL, 'edit-form')->toString();
    $row['description']['data']['#markup'] = $entity->getDescription();
    return $row + parent::buildRow($entity);
  }

  /** * {@inheritdoc} */
  protected function getTitle() {
    return $this->t('Block types');
  }

}

  public function render() {
    $build = [
      '#type' => 'table',
      '#header' => $this->buildHeader(),
      '#rows' => [],
    ];

    $mappers = [];

    foreach ($this->mappers as $mapper) {
      if ($row = $this->buildRow($mapper)) {
        $mappers[$mapper->getWeight()][] = $row;
      }
    }

    // Group by mapper weight and sort by label.     ksort($mappers);
    foreach ($mappers as $weight => $mapper) {
      usort($mapperfunction D$a$b) {
        $a_title = (isset($a['label'])) ? $a['label'] : '';
        $b_title = (isset($b['label'])) ? $b['label'] : '';
        return strnatcasecmp($a_title$b_title);
      });
if ($entity->isIndexable()) {
      $status = $entity->getPlugin()->indexStatus();
      $row['progress']['#markup'] = $this->t('%num_indexed of %num_total indexed', [
        '%num_indexed' => $status['total'] - $status['remaining'],
        '%num_total' => $status['total'],
      ]);
    }
    else {
      $row['progress']['#markup'] = $this->t('Does not use index');
    }

    return $row + parent::buildRow($entity);
  }

  /** * {@inheritdoc} */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form = parent::buildForm($form$form_state);
    $search_settings = $this->config('search.settings');
    // Collect some stats.     $remaining = 0;
    $total = 0;
    
$header['label'] = t('Label');
    $header['id'] = t('Machine name');
    return $header + parent::buildHeader();
  }

  /** * {@inheritdoc} */
  public function buildRow(EntityInterface $entity) {
    $row['label'] = $entity->label();
    $row['id'] = $entity->id();
    return $row + parent::buildRow($entity);
  }

}
$row['data'] = [
      'label' => [
        'data' => [
          '#prefix' => isset($indentation) ? $this->renderer->render($indentation) : '',
          '#type' => 'link',
          '#title' => $entity->label(),
          '#url' => $entity->toUrl(),
        ],
      ],
      'owner' => $entity->getOwner()->getDisplayName(),
    ];
    $row['data'] = $row['data'] + parent::buildRow($entity);

    $active_workspace = $this->workspaceManager->getActiveWorkspace();
    if ($active_workspace && $entity->id() === $active_workspace->id()) {
      $row['class'] = ['active-workspace', 'active-workspace--not-default'];
    }
    return $row;
  }

  /** * {@inheritdoc} */
  
catch (InfoParserException $e) {
      $this->messenger()->addError($this->t('Modules could not be listed due to an error: %error', ['%error' => $e->getMessage()]));
      $modules = [];
    }

    // Iterate over each of the modules.     $form['modules']['#tree'] = TRUE;
    $incompatible_installed = FALSE;
    foreach ($modules as $filename => $module) {
      if (empty($module->info['hidden'])) {
        $package = $module->info['package'];
        $form['modules'][$package][$filename] = $this->buildRow($modules$module$distribution);
        $form['modules'][$package][$filename]['#parents'] = ['modules', $filename];
      }
      if (!$incompatible_installed && $module->status && $module->info['core_incompatible']) {
        $incompatible_installed = TRUE;
        $this->messenger()->addWarning($this->t(
          'There are errors with some installed modules. Visit the <a href=":link">status report page</a> for more information.',
          [':link' => Url::fromRoute('system.status')->toString()]
        ));
      }
    }

    
Home | Imprint | This part of the site doesn't use cookies.