private function EntityContext::count in Lightning Core 8.3
Same name and namespace in other branches
- 8.5 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::count()
- 8 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::count()
- 8.2 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::count()
- 8.4 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::count()
Counts the number of entities of a specific type and optional bundle.
Parameters
string $entity_type: The entity type ID.
string $bundle: (optional) The bundle.
Return value
int How many entities exist of the given type and bundle.
1 call to EntityContext::count()
- EntityContext::assertCount in tests/
contexts/ EntityContext.behat.inc - Asserts that entities of a specific type and optional bundle exist.
File
- tests/
contexts/ EntityContext.behat.inc, line 162
Class
- EntityContext
- Contains miscellaneous step definitions for working with Drupal entities.
Namespace
Acquia\LightningExtension\ContextCode
private function count($entity_type, $bundle = NULL) {
$storage = \Drupal::entityTypeManager()
->getStorage($entity_type);
$query = $storage
->getQuery()
->count();
if ($bundle) {
$query
->condition($storage
->getEntityType()
->getKey('bundle'), $bundle);
}
return (int) $query
->execute();
}