You are here

public function DeleteContent::getEntityIds in Drush Delete All 3.x

Same name and namespace in other branches
  1. 8.2 src/DeleteContent.php \Drupal\drush_delete\DeleteContent::getEntityIds()

Provides the Entity Ids of the given type.

Parameters

string $type: Entity type.

Return value

array|Null The array of all the nids.

1 call to DeleteContent::getEntityIds()
DeleteContent::deleteAllEntityType in src/DeleteContent.php
Function that provides the deleteing content functionality.

File

src/DeleteContent.php, line 89

Class

DeleteContent
Delete content service class.

Namespace

Drupal\drush_delete

Code

public function getEntityIds($type) {
  $nids = [];
  $result = $this->connection
    ->select('node', 'n')
    ->fields('n', [
    'nid',
  ])
    ->condition('type', $type, '=')
    ->execute()
    ->fetchall();
  if (empty($result)) {
    return NULL;
  }
  else {
    foreach ($result as $item) {
      $nids[] = $item->nid;
    }
  }
  return $nids;
}