buildOperations example

$row['type'] = node_get_type_label($entity);
    $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);
  }

}
/** * Builds a row for a mapper in the mapper listing. * * @param \Drupal\config_translation\ConfigMapperInterface $mapper * The mapper. * * @return array * A render array structure of fields for this mapper. */
  public function buildRow(ConfigMapperInterface $mapper) {
    $row['label'] = $mapper->getTypeLabel();
    $row['operations']['data'] = $this->buildOperations($mapper);
    return $row;
  }

  /** * Builds the header row for the mapper listing. * * @return array * A render array structure of header strings. */
  public function buildHeader() {
    $row['Label'] = $this->t('Label');
    
$row['theme'] = [
      'data' => $this->themes[$theme]->info['name'],
      'class' => 'table-filter-text-source',
    ];

    $row['category'] = [
      'data' => $plugin_definition['category'],
      'class' => 'table-filter-text-source',
    ];

    $row['operations']['data'] = $this->buildOperations($entity);

    return $row;
  }

  /** * {@inheritdoc} */
  public function buildHeader() {
    $header['label'] = $this->t('Block');
    $header['theme'] = $this->t('Theme');
    $header['category'] = $this->t('Category');
    

          $form[$entity_id]['weight'] = [
            '#type' => 'weight',
            '#default_value' => $info['weight'],
            '#delta' => $weight_delta,
            '#title' => $this->t('Weight for @block block', ['@block' => $info['label']]),
            '#title_display' => 'invisible',
            '#attributes' => [
              'class' => ['block-weight', 'block-weight-' . $region],
            ],
          ];
          $form[$entity_id]['operations'] = $this->buildOperations($info['entity']);
        }
      }
    }

    // Do not allow disabling the main system content block when it is present.     if (isset($form['system_main']['region'])) {
      $form['system_main']['region']['#required'] = TRUE;
    }
    return $form;
  }

  

  public function buildRow(EntityInterface $entity) {
    $row['operations']['data'] = $this->buildOperations($entity);
    return $row;
  }

  /** * Builds a renderable list of operation links for the entity. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity on which the linked operations will be performed. * * @return array * A renderable array of operation links. * * @see \Drupal\Core\Entity\EntityListBuilder::buildRow() */
$row['data']['path']['data'] = [
      '#type' => 'link',
      '#title' => $path,
      '#url' => $url,
    ];

    if ($this->languageManager->isMultilingual()) {
      $row['data']['language_name'] = $this->languageManager->getLanguageName($langcode);
    }

    $row['data']['operations']['data'] = $this->buildOperations($entity);

    // If the system path maps to a different URL alias, highlight this table     // row to let the user know of old aliases.     if ($alias != $this->aliasManager->getAliasByPath($path$langcode)) {
      $row['class'] = ['warning'];
    }

    return $row;
  }

}
// Test buildHeader() method.     $expected_items = [
      'label' => 'Label',
      'id' => 'Machine name',
      'operations' => 'Operations',
    ];
    $actual_items = $controller->buildHeader();
    $this->assertEquals($expected_items$actual_items, 'Return value from buildHeader matches expected.');

    // Test buildRow() method.     $build_operations = $controller->buildOperations($entity);
    $expected_items = [
      'label' => 'Default',
      'id' => 'dotted.default',
      'operations' => [
        'data' => $build_operations,
      ],
    ];
    $actual_items = $controller->buildRow($entity);
    $this->assertEquals($expected_items$actual_items, 'Return value from buildRow matches expected.');
    // Test sorting.     $storage = $controller->getStorage();
    
Home | Imprint | This part of the site doesn't use cookies.