Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function getOperations(EntityInterface $entity)
 {
     $operations = parent::getOperations($entity);
     $destination = drupal_get_destination();
     $default = $entity->isDefault();
     $id = $entity->id();
     // Get CSRF token service.
     $token_generator = \Drupal::csrfToken();
     // @TODO: permission checks.
     if ($entity->status() && !$default) {
         $operations['disable'] = array('title' => $this->t('Disable'), 'url' => Url::fromRoute('domain.inline_action', array('op' => 'disable', 'domain' => $id)), 'weight' => 50);
     } elseif (!$default) {
         $operations['enable'] = array('title' => $this->t('Enable'), 'url' => Url::fromRoute('domain.inline_action', array('op' => 'enable', 'domain' => $id)), 'weight' => 40);
     }
     if (!$default) {
         $operations['default'] = array('title' => $this->t('Make default'), 'url' => Url::fromRoute('domain.inline_action', array('op' => 'default', 'domain' => $id)), 'weight' => 30);
         $operations['delete'] = array('title' => $this->t('Delete'), 'url' => Url::fromRoute('entity.domain.delete_form', array('domain' => $id)), 'weight' => 20);
     }
     // @TODO: inject this service?
     $operations += \Drupal::moduleHandler()->invokeAll('domain_operations', array($entity));
     foreach ($operations as $key => $value) {
         if (isset($value['query']['token'])) {
             $operations[$key]['query'] += $destination;
         }
     }
     $default = \Drupal::service('domain.loader')->loadDefaultDomain();
     // Deleting the site default domain is not allowed.
     if ($id == $default->id()) {
         unset($operations['delete']);
     }
     return $operations;
 }