queryFactory = $query_factory; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( $container->get('entity.query') ); } /** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $num_paragraphs = $this->queryFactory->get('paragraph') ->condition('type', $this->entity->id()) ->count() ->execute(); if ($num_paragraphs) { $caption = '

' . $this->formatPlural($num_paragraphs, '%type Paragraphs type is used by 1 piece of content on your site. You can not remove this %type Paragraphs type until you have removed all from the content.', '%type Paragraphs type is used by @count pieces of content on your site. You may not remove %type Paragraphs type until you have removed all from the content.', ['%type' => $this->entity->label()]) . '

'; $form['#title'] = $this->getQuestion(); $form['description'] = ['#markup' => $caption]; return $form; } return parent::buildForm($form, $form_state); } }