/** * {@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); }
/** * Gets a translated message from the exception. * * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation * The string translation service. * * @return string */ public function getTranslatedMessage(TranslationInterface $string_translation, $extension) { return $string_translation->formatPlural(count($this->getConfigObjects()), 'Unable to install @extension, %config_names has unmet dependencies.', 'Unable to install @extension, %config_names have unmet dependencies.', ['%config_names' => implode(', ', $this->getConfigObjects()), '@extension' => $extension]); }