public function ContentDeleteController::getContentToDelete in Delete all 8
Same name and namespace in other branches
- 2.x src/Controller/ContentDeleteController.php \Drupal\delete_all\Controller\ContentDeleteController::getContentToDelete()
Get nids of the nodes to delete.
Parameters
array $roles: Array of roles.
Return value
array Array of nids of nodes to delete.
File
- src/
Controller/ ContentDeleteController.php, line 20
Class
- ContentDeleteController
- Returns responses for devel module routes.
Namespace
Drupal\delete_all\ControllerCode
public function getContentToDelete($content_types = FALSE) {
$nodes_to_delete = [];
// Delete content by content type.
if ($content_types !== FALSE) {
$nodes_to_delete = [];
foreach ($content_types as $content_type) {
if ($content_type) {
$nids = $this->connection
->select('node', 'n')
->fields('n', [
'nid',
])
->condition('type', $content_type)
->execute()
->fetchCol('nid');
$nodes_to_delete = array_merge($nodes_to_delete, $nids);
}
}
}
else {
$nodes_to_delete = FALSE;
}
return $nodes_to_delete;
}