comparison modules/contrib/migrate_tools/src/Controller/MigrationGroupListBuilder.php @ 0:4c8ae668cc8c

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