Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\migrate_tools\Controller;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
|
Chris@0
|
6 use Drupal\Core\Entity\EntityInterface;
|
Chris@0
|
7 use Drupal\Core\Url;
|
Chris@0
|
8
|
Chris@0
|
9 /**
|
Chris@0
|
10 * Provides a listing of migration group entities.
|
Chris@0
|
11 *
|
Chris@0
|
12 * @package Drupal\migrate_tools\Controller
|
Chris@0
|
13 *
|
Chris@0
|
14 * @ingroup migrate_tools
|
Chris@0
|
15 */
|
Chris@0
|
16 class MigrationGroupListBuilder extends ConfigEntityListBuilder {
|
Chris@0
|
17
|
Chris@0
|
18 /**
|
Chris@0
|
19 * Builds the header row for the entity listing.
|
Chris@0
|
20 *
|
Chris@0
|
21 * @return array
|
Chris@0
|
22 * A render array structure of header strings.
|
Chris@0
|
23 *
|
Chris@0
|
24 * @see Drupal\Core\Entity\EntityListController::render()
|
Chris@0
|
25 */
|
Chris@0
|
26 public function buildHeader() {
|
Chris@0
|
27 $header['label'] = $this->t('Migration Group');
|
Chris@0
|
28 $header['machine_name'] = $this->t('Machine Name');
|
Chris@0
|
29 $header['description'] = $this->t('Description');
|
Chris@0
|
30 $header['source_type'] = $this->t('Source Type');
|
Chris@0
|
31 return $header + parent::buildHeader();
|
Chris@0
|
32 }
|
Chris@0
|
33
|
Chris@0
|
34 /**
|
Chris@0
|
35 * Builds a row for an entity in the entity listing.
|
Chris@0
|
36 *
|
Chris@0
|
37 * @param EntityInterface $entity
|
Chris@0
|
38 * The entity for which to build the row.
|
Chris@0
|
39 *
|
Chris@0
|
40 * @return array
|
Chris@0
|
41 * A render array of the table row for displaying the entity.
|
Chris@0
|
42 *
|
Chris@0
|
43 * @see Drupal\Core\Entity\EntityListController::render()
|
Chris@0
|
44 */
|
Chris@0
|
45 public function buildRow(EntityInterface $entity) {
|
Chris@0
|
46 $row['label'] = $entity->label();
|
Chris@0
|
47 $row['machine_name'] = $entity->id();
|
Chris@0
|
48 $row['description'] = $entity->get('description');
|
Chris@0
|
49 $row['source_type'] = $entity->get('source_type');
|
Chris@0
|
50
|
Chris@0
|
51 return $row + parent::buildRow($entity);
|
Chris@0
|
52 }
|
Chris@0
|
53
|
Chris@0
|
54 /**
|
Chris@0
|
55 * {@inheritdoc}
|
Chris@0
|
56 */
|
Chris@0
|
57 public function getDefaultOperations(EntityInterface $entity) {
|
Chris@0
|
58 $operations = parent::getDefaultOperations($entity);
|
Chris@0
|
59 $operations['list'] = [
|
Chris@0
|
60 'title' => $this->t('List migrations'),
|
Chris@0
|
61 'weight' => 0,
|
Chris@0
|
62 'url' => Url::fromRoute('entity.migration.list', ['migration_group' => $entity->id()]),
|
Chris@0
|
63 ];
|
Chris@0
|
64
|
Chris@0
|
65 return $operations;
|
Chris@0
|
66 }
|
Chris@0
|
67
|
Chris@0
|
68 }
|