function BundleEntityDeleteForm::getContentEntityCount

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Entity/Form/BundleEntityDeleteForm.php \Drupal\Core\Entity\Form\BundleEntityDeleteForm::getContentEntityCount()

Gets the count of content entities of this form's bundle.

This is handled separately from additional reasons to make it easier for entity types to customize.

Return value

int The number of entities.

File

core/lib/Drupal/Core/Entity/Form/BundleEntityDeleteForm.php, line 99

Class

BundleEntityDeleteForm
A generic entity delete form for entities which are bundles.

Namespace

Drupal\Core\Entity\Form

Code

protected function getContentEntityCount() : int {
  $bundle_entity_type = $this->entity
    ->getEntityType();
  $content_entity_type_id = $bundle_entity_type->getBundleOf();
  $content_entity_type = $this->entityTypeManager
    ->getDefinition($content_entity_type_id);
  $num_content_entities = $this->entityTypeManager
    ->getStorage($content_entity_type_id)
    ->getQuery()
    ->accessCheck(FALSE)
    ->condition($content_entity_type->getKey('bundle'), $this->entity
    ->id())
    ->count()
    ->execute();
  return $num_content_entities;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.