Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function submit(array $form, array &$form_state)
 {
     parent::submit($form, $form_state);
     $entity = $this->entity;
     $entity->delete();
     drupal_set_message(t('%entity_type @id has been deleted.', array('@id' => $entity->id(), '%entity_type' => $entity->getEntityTypeId())));
     $form_state['redirect_route'] = $this->getCancelRoute();
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     parent::submitForm($form, $form_state);
     $entity = $this->entity;
     $entity->delete();
     drupal_set_message(t('%entity_type @id has been deleted.', array('@id' => $entity->id(), '%entity_type' => $entity->getEntityTypeId())));
     $form_state->setRedirectUrl($this->getCancelUrl());
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::buildForm($form, $form_state);
     /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
     $entity = $this->getEntity();
     if ($entity->isDefaultTranslation()) {
         if (count($entity->getTranslationLanguages()) > 1) {
             $languages = [];
             foreach ($entity->getTranslationLanguages() as $language) {
                 $languages[] = $language->getName();
             }
             $form['deleted_translations'] = array('#theme' => 'item_list', '#title' => $this->t('The following @entity-type translations will be deleted:', ['@entity-type' => $entity->getEntityType()->getLowercaseLabel()]), '#items' => $languages);
             $form['actions']['submit']['#value'] = $this->t('Delete all translations');
         }
     } else {
         $form['actions']['submit']['#value'] = $this->t('Delete @language translation', array('@language' => $entity->language()->getName()));
     }
     return $form;
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state)
 {
     $user = $this->currentUser();
     $this->cancelMethods = user_cancel_methods();
     // Display account cancellation method selection, if allowed.
     $admin_access = $user->hasPermission('administer users');
     $form['user_cancel_method'] = array('#type' => 'radios', '#title' => $this->entity->id() == $user->id() ? $this->t('When cancelling your account') : $this->t('When cancelling the account'), '#access' => $admin_access || $user->hasPermission('select account cancellation method'));
     $form['user_cancel_method'] += $this->cancelMethods;
     // Allow user administrators to skip the account cancellation confirmation
     // mail (by default), as long as they do not attempt to cancel their own
     // account.
     $override_access = $admin_access && $this->entity->id() != $user->id();
     $form['user_cancel_confirm'] = array('#type' => 'checkbox', '#title' => $this->t('Require email confirmation to cancel account.'), '#default_value' => !$override_access, '#access' => $override_access, '#description' => $this->t('When enabled, the user must confirm the account cancellation via email.'));
     // Also allow to send account canceled notification mail, if enabled.
     $default_notify = $this->config('user.settings')->get('notify.status_canceled');
     $form['user_cancel_notify'] = array('#type' => 'checkbox', '#title' => $this->t('Notify user when account is canceled.'), '#default_value' => $override_access ? FALSE : $default_notify, '#access' => $override_access && $default_notify, '#description' => $this->t('When enabled, the user will receive an email notification after the account has been canceled.'));
     // Always provide entity id in the same form key as in the entity edit form.
     $form['uid'] = array('#type' => 'value', '#value' => $this->entity->id());
     $form = parent::buildForm($form, $form_state);
     return $form;
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 protected function actions(array $form, FormStateInterface $form_state)
 {
     $actions = parent::actions($form, $form_state);
     $actions['submit']['#disabled'] = $this->entity->isLocked();
     return $actions;
 }
 /**
  * Constructs a new instance.
  *
  * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
  *   The entity manager.
  * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
  *    The string translator.
  */
 function __construct(EntityManagerInterface $entity_manager, TranslationInterface $string_translation)
 {
     parent::__construct($entity_manager);
     $this->stringTranslation = $string_translation;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $instances = $this->entity->getInstances();
     $form['message'] = array('#markup' => format_plural(count($instances), 'This will also remove 1 placed block instance.', 'This will also remove @count placed block instances.'), '#access' => !empty($instances));
     return parent::buildForm($form, $form_state);
 }
Пример #8
0
 /**
  * Constructs a NodeDeleteForm object.
  *
  * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
  *   The entity manager.
  * @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator
  *   The URL generator.
  */
 public function __construct(EntityManagerInterface $entity_manager, UrlGeneratorInterface $url_generator)
 {
     parent::__construct($entity_manager);
     $this->urlGenerator = $url_generator;
 }
 /**
  * Constructs a MenuLinkContentDeleteForm object.
  *
  * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
  *   The entity manager.
  * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory
  *   The logger channel factory.
  */
 public function __construct(EntityManagerInterface $entity_manager, LoggerChannelFactoryInterface $logger_factory)
 {
     parent::__construct($entity_manager);
     $this->logger = $logger_factory->get('menu');
 }
 /**
  * Constructs a new instance.
  *
  * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
  *   The entity manager.
  * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
  *   The string translator.
  * @param \Psr\Log\LoggerInterface $logger
  */
 public function __construct(EntityManagerInterface $entity_manager, TranslationInterface $string_translation, LoggerInterface $logger)
 {
     parent::__construct($entity_manager);
     $this->logger = $logger;
     $this->stringTranslation = $string_translation;
 }