entityTypeManager->getStorage('node')->getQuery() ->condition('type', $this->entity->id()) ->count() ->execute(); if ($num_nodes) { $caption = '

' . $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.', ['%type' => $this->entity->label()]) . '

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