Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $product_count = $this->queryFactory->get('commerce_product')->condition('type', $this->entity->id())->count()->execute();
     if ($product_count) {
         $caption = '<p>' . $this->formatPlural($product_count, '%type is used by 1 product on your site. You can not remove this product type until you have removed all of the %type products.', '%type is used by @count products on your site. You may not remove %type until you have removed all of the %type products.', ['%type' => $this->entity->label()]) . '</p>';
         $form['#title'] = $this->getQuestion();
         $form['description'] = ['#markup' => $caption];
         return $form;
     }
     return parent::buildForm($form, $form_state);
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Save a selected replacement in the image style storage. It will be used
     // later, in the same request, when resolving dependencies.
     if ($replacement = $form_state->getValue('replacement')) {
         /** @var \Drupal\image\ImageStyleStorageInterface $storage */
         $storage = $this->entityTypeManager->getStorage($this->entity->getEntityTypeId());
         $storage->setReplacementId($this->entity->id(), $replacement);
     }
     parent::submitForm($form, $form_state);
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $num_nodes = $this->queryFactory->get('node')->condition('type', $this->entity->id())->count()->execute();
     if ($num_nodes) {
         $caption = '<p>' . $this->formatPlural($num_nodes, '%type is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the %type content.', '%type is used by @count pieces of content on your site. You may not remove %type until you have removed all of the %type content.', array('%type' => $this->entity->label())) . '</p>';
         $form['#title'] = $this->getQuestion();
         $form['description'] = array('#markup' => $caption);
         return $form;
     }
     return parent::buildForm($form, $form_state);
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $bundles = entity_get_bundles($this->entity->id());
     if (!empty($bundles) && empty($bundles[$this->entity->id()])) {
         $warning_message = '<p>' . $this->formatPlural(count($bundles), '%type has 1 bundle. Please delete all %type bundles.', '%type has @count bundles. Please delete all %type bundles.', array('%type' => $this->entity->label())) . '</p>';
         $form['description'] = array('#markup' => $warning_message);
         $form['title'] = $this->getQuestion();
         return $form;
     }
     return parent::buildForm($form, $form_state);
 }
Exemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $blocks = $this->queryFactory->get('block_content')->condition('type', $this->entity->id())->execute();
     if (!empty($blocks)) {
         $caption = '<p>' . $this->formatPlural(count($blocks), '%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', '%label is used by @count custom blocks on your site. You may not remove %label until you have removed all of the %label custom blocks.', array('%label' => $this->entity->label())) . '</p>';
         $form['description'] = array('#markup' => $caption);
         return $form;
     } else {
         return parent::buildForm($form, $form_state);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $num_profiles = $this->queryFactory->get('profile')->condition('type', $this->entity->id())->count()->execute();
     if ($num_profiles) {
         $caption = '<p>' . \Drupal::translation()->formatPlural($num_profiles, '%type is used by 1 profile on your site. You can not remove this profile type until you have removed all of the %type profiles.', '%type is used by @count profiles on your site. You may not remove %type until you have removed all of the %type profiles.', ['%type' => $this->entity->label()]) . '</p>';
         $form['#title'] = $this->entity->label();
         $form['description'] = ['#markup' => $caption];
         return $form;
     }
     return parent::buildForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     // Get the custom entity ID.
     $custom_entity_id = $this->entity->getEntityType()->getBundleOf();
     $entities = $this->queryFactory->get($custom_entity_id)->condition('type', $this->entity->id())->execute();
     if (!empty($entities)) {
         $caption = '<p>' . $this->formatPlural(count($entities), '%label is used by 1 entity on your site. You can not remove this entity type until you have removed all of the %label entities.', '%label is used by @count entities on your site. You may not remove %label until you have removed all of the %label entities.', ['%label' => $this->entity->label()]) . '</p>';
         $form['description'] = array('#markup' => $caption);
         return $form;
     } else {
         return parent::buildForm($form, $form_state);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state) {
   $numPaymentInfo = $this->queryFactory->get('commerce_payment_info')
     ->condition('type', $this->entity->id())
     ->count()
     ->execute();
   if ($numPaymentInfo) {
     $caption = '<p>' . $this->formatPlural($numPaymentInfo, '%type is used by 1 payment information entity on your site. You can not remove this payment information type until you have removed all of the %type payment information entities.', '%type is used by @count payment information entities on your site. You may not remove %type until you have removed all of the %type payment information entities.', array('%type' => $this->entity->label())) . '</p>';
     $form['#title'] = $this->getQuestion();
     $form['description'] = array('#markup' => $caption);
     return $form;
   }
   return parent::buildForm($form, $form_state);
 }
Exemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     // Find out how many users are directly assigned to this shortcut set, and
     // make a message.
     $number = $this->storage->countAssignedUsers($this->entity);
     $info = '';
     if ($number) {
         $info .= '<p>' . $this->formatPlural($number, '1 user has chosen or been assigned to this shortcut set.', '@count users have chosen or been assigned to this shortcut set.') . '</p>';
     }
     // Also, if a module implements hook_shortcut_default_set(), it's possible
     // that this set is being used as a default set. Add a message about that too.
     if ($this->moduleHandler->getImplementations('shortcut_default_set')) {
         $info .= '<p>' . t('If you have chosen this shortcut set as the default for some or all users, they may also be affected by deleting it.') . '</p>';
     }
     $form['info'] = array('#markup' => $info);
     return parent::buildForm($form, $form_state);
 }
Exemplo n.º 10
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Locked menus may not be deleted.
     if ($this->entity->isLocked()) {
         return;
     }
     // Delete all links to the overview page for this menu.
     // @todo Add a more generic helper function to the menu link plugin
     //   manager to remove links to a entity or other ID used as a route
     //   parameter that is being removed. Also, consider moving this to
     //   menu_ui.module as part of a generic response to entity deletion.
     //   https://www.drupal.org/node/2310329
     $menu_links = $this->menuLinkManager->loadLinksByRoute('entity.menu.edit_form', array('menu' => $this->entity->id()), TRUE);
     foreach ($menu_links as $id => $link) {
         $this->menuLinkManager->removeDefinition($id);
     }
     parent::submitForm($form, $form_state);
 }
Exemplo n.º 11
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $comments = $this->queryFactory->get('comment')->condition('comment_type', $this->entity->id())->execute();
     $entity_type = $this->entity->getTargetEntityTypeId();
     $caption = '';
     foreach (array_keys($this->commentManager->getFields($entity_type)) as $field_name) {
         /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */
         if (($field_storage = FieldStorageConfig::loadByName($entity_type, $field_name)) && $field_storage->getSetting('comment_type') == $this->entity->id() && !$field_storage->isDeleted()) {
             $caption .= '<p>' . $this->t('%label is used by the %field field on your site. You can not remove this comment type until you have removed the field.', array('%label' => $this->entity->label(), '%field' => $field_storage->label())) . '</p>';
         }
     }
     if (!empty($comments)) {
         $caption .= '<p>' . $this->formatPlural(count($comments), '%label is used by 1 comment on your site. You can not remove this comment type until you have removed all of the %label comments.', '%label is used by @count comments on your site. You may not remove %label until you have removed all of the %label comments.', array('%label' => $this->entity->label())) . '</p>';
     }
     if ($caption) {
         $form['description'] = array('#markup' => $caption);
         return $form;
     } else {
         return parent::buildForm($form, $form_state);
     }
 }
Exemplo n.º 12
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     return parent::buildForm($form, $form_state);
 }
  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {

    parent::submitForm($form, $form_state);
  }
Exemplo n.º 14
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $this->entity->set('replacementID', $form_state->getValue('replacement'));
     parent::submitForm($form, $form_state);
 }
Exemplo n.º 15
-1
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::buildForm($form, $form_state);
     // If we are adding the field storage as a dependency to delete, then that
     // will list the field as a dependency. That is confusing, so remove it.
     // Also remove the entity type and the whole entity deletions details
     // element if nothing else is in there.
     if (isset($form['entity_deletes']['field_config']['#items']) && isset($form['entity_deletes']['field_config']['#items'][$this->entity->id()])) {
         unset($form['entity_deletes']['field_config']['#items'][$this->entity->id()]);
         if (empty($form['entity_deletes']['field_config']['#items'])) {
             unset($form['entity_deletes']['field_config']);
             if (!Element::children($form['entity_deletes'])) {
                 $form['entity_deletes']['#access'] = FALSE;
             }
         }
     }
     return $form;
 }