Yaffs site version 1.1
[yaffs-website] / web / modules / contrib / linkit / src / ProfileListBuilder.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\linkit\ProfileListBuilder.
6  */
7
8 namespace Drupal\linkit;
9
10 use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
11 use Drupal\Core\Entity\EntityInterface;
12 use Drupal\Core\Url;
13
14 /**
15  * Defines a class to build a listing of profile entities.
16  *
17  * @see \Drupal\linkit\Entity\Profile
18  */
19 class ProfileListBuilder extends ConfigEntityListBuilder {
20
21   /**
22    * {@inheritdoc}
23    */
24   public function buildHeader() {
25       $header['title'] = t('Profile');
26       $header['description'] = [
27           'data' => t('Description'),
28           'class' => [RESPONSIVE_PRIORITY_MEDIUM],
29       ];
30     return $header + parent::buildHeader();
31   }
32
33   /**
34    * {@inheritdoc}
35    */
36   public function buildRow(EntityInterface $entity) {
37     /** @var \Drupal\linkit\ProfileInterface $linkitProfile */
38     $linkitProfile = $entity;
39     $row['label'] = $linkitProfile->label();
40     $row['description']['data'] = ['#markup' => $linkitProfile->getDescription()];
41     return $row + parent::buildRow($entity);
42   }
43
44   /**
45    * {@inheritdoc}
46    */
47   public function getDefaultOperations(EntityInterface $entity) {
48     $operations = parent::getDefaultOperations($entity);
49
50     if (isset($operations['edit'])) {
51       $operations['edit']['title'] = t('Edit profile');
52     }
53
54     $operations['matchers'] = [
55       'title' => t('Manage matchers'),
56       'weight' => 10,
57       'url' => Url::fromRoute('linkit.matchers', [
58         'linkit_profile' => $entity->id()
59       ]),
60     ];
61
62     $operations['attributes'] = [
63       'title' => t('Manage attributes'),
64       'weight' => 20,
65       'url' => Url::fromRoute('linkit.attributes', [
66         'linkit_profile' => $entity->id()
67       ]),
68     ];
69
70     return $operations;
71   }
72
73 }