/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); $form['contact_storage_disabled_form_message'] = [ '#type' => 'textfield', '#title' => t('Default disabled contact form message'), '#description' => t('Default message to display if the contact form is disabled. It will be saved when clicking "Disable".'), '#default_value' => $this->getEntity()->getThirdPartySetting('contact_storage', 'disabled_form_message', $this->t('This contact form has been disabled.')), ]; return $form; }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); if ($this->entity->id() == 'default') { $form['#title'] = $this->t('The default optionset cannot be deleted.'); $form['description'] = array('#markup' => t('Please click Cancel to go back to the list of optionsets.')); $form['actions']['submit']['#access'] = FALSE; } return $form; }
/** * {@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>' . format_plural($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); }
/** * {@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>' . format_plural(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_nodes = $this->database->query("SELECT COUNT(*) FROM {crm_core_contact} WHERE type = :type", array(':type' => $this->entity->id()))->fetchField(); if ($num_nodes) { $caption = \Drupal::translation()->formatPlural($num_nodes, '%type is used by one contact on your site. You can not remove this contact type until you have removed all of the %type contacts.', '%type is used by @count contacts on your site. You may not remove %type until you have removed all of the %type contacts.', array('%type' => $this->entity->label())); $form['#title'] = $this->getQuestion(); $form['description'] = array('#markup' => '<p>' . $caption . '</p>'); return $form; } return parent::buildForm($form, $form_state); }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $count = $this->entityManager->getStorage('registration')->getQuery()->condition('type', $this->entity->id())->count()->execute(); if ($count == 0) { return parent::buildForm($form, $form_state); } drupal_set_message($this->t('Cannot delete registration type.'), 'warning'); $form['#title'] = $this->getQuestion(); $form['description'] = array('#markup' => $this->formatPlural($count, 'Unable to delete registration type. It is used by @count registration.', 'Unable to delete registration type. It is used by @count registrations.')); return $form; }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $num_nodes = $this->database->query("SELECT COUNT(*) FROM {node} WHERE type = :type", array(':type' => $this->entity->id()))->fetchField(); if ($num_nodes) { $caption = '<p>' . format_plural($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); }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { // Check if any entity of this type already exists. $content_number = $this->queryFactory->get($this->entity->getEntityType()->getBundleOf())->condition('type', $this->entity->id())->count()->execute(); if (!empty($content_number)) { $warning_message = '<p>' . $this->formatPlural($content_number, '%type is used by 1 entity on your site. You can not remove this entity type until you have removed all of the %type entities.', '%type is used by @count entities on your site. You may not remove %type until you have removed all of the %type entities.', array('%type' => $this->entity->label())) . '</p>'; $form['#title'] = $this->getQuestion(); $form['description'] = array('#markup' => $warning_message); return $form; } return parent::buildForm($form, $form_state); }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); $entity = $this->getEntity(); // Only do dependency processing for configuration entities. Whilst it is // possible for a configuration entity to be dependent on a content entity, // these dependencies are soft and content delete permissions are often // given to more users. This method should not make assumptions that $entity // is a configuration entity in case we decide to remove the following // condition. if (!$entity instanceof ConfigEntityInterface) { return $form; } $this->addDependencyListsToForm($form, $entity->getConfigDependencyKey(), [$entity->getConfigDependencyName()], $this->getConfigManager(), $this->entityManager); return $form; }
/** * {@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>' . format_plural($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); }
/** * {@inheritdoc} */ public function buildForm(array $form, array &$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->deleted) { $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); } }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); if ($this->getBlocksForGroup()) { // If there are blocks in this group then // create a dropdown to let the user choose what to do with blocks. $options[static::UNSET_BLOCKS] = $this->t('Unset visibility group'); $labels = $this->getBlockVisibilityLabels($this->entityManager->getStorage('block_visibility_group')); unset($labels[$this->entity->id()]); foreach ($labels as $type => $label) { $options[$type] = $this->t('Move blocks to group: <em>@label</em>', ['@label' => $label]); } $options[static::DELETE_BLOCKS] = $this->t('Delete all blocks'); $form['blocks_op'] = [ '#type' => 'select', '#title' => $this->t('Current blocks'), '#options' => $options, '#description' => $this->t('What do you want to do with the current blocks in this group?'), ]; } else { // No blocks in this group. $form['no_blocks'] = [ '#markup' => '<p>' . $this->t('There no blocks assigned to this group.') . '</p>', ]; } return $form; }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $langcode = $this->entity->id(); // Warn and redirect user when attempting to delete the default language. if (language_default()->id == $langcode) { drupal_set_message($this->t('The default language cannot be deleted.')); $url = $this->urlGenerator->generateFromPath('admin/config/regional/language', array('absolute' => TRUE)); return new RedirectResponse($url); } // Throw a 404 when attempting to delete a non-existing language. $languages = language_list(); if (!isset($languages[$langcode])) { throw new NotFoundHttpException(); } return parent::buildForm($form, $form_state); }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $store = $this->tempStoreFactory->get($this->entity->getEntityTypeId()); if (!$store->getMetadata($this->entity->id())) { $form['message']['#markup'] = $this->t('There is no lock on rule %name to break.', ['%name' => $this->entity->id()]); return $form; } return parent::buildForm($form, $form_state); }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { return parent::buildForm($form, $form_state); }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { if (!$this->tempStore->getMetadata($this->entity->id())) { $form['message']['#markup'] = $this->t('There is no lock on view %name to break.', array('%name' => $this->entity->id())); return $form; } return parent::buildForm($form, $form_state); }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $count = $this->queryFactory->get('crop') ->condition('type', $this->entity->id()) ->count() ->execute(); if ($count) { $form['#title'] = $this->getQuestion(); $form['description'] = [ '#prefix' => '<p>', '#markup' => $this->translation->formatPlural($count, '%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())), '#suffix' => '</p>', ]; return $form; } return parent::buildForm($form, $form_state); }