/**
  * {@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);
     }
 }