You are here

public function Delete::deleteItems in IMCE 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/ImcePlugin/Delete.php \Drupal\imce\Plugin\ImcePlugin\Delete::deleteItems()

Deletes a list of imce items and returns succeeded ones.

1 call to Delete::deleteItems()
Delete::opDelete in src/Plugin/ImcePlugin/Delete.php
Operation handler: delete.

File

src/Plugin/ImcePlugin/Delete.php, line 63

Class

Delete
Defines Imce Delete plugin.

Namespace

Drupal\imce\Plugin\ImcePlugin

Code

public function deleteItems(ImceFM $fm, array $items) {
  $success = [];
  $ignore_usage = $fm
    ->getConf('ignore_usage', FALSE);
  foreach ($items as $item) {
    if ($uri = $item
      ->getUri()) {
      $result = $item->type === 'folder' ? $this
        ->deleteFolderUri($uri, $ignore_usage, !$item
        ->getPermission('delete_files')) : $this
        ->deleteFileUri($uri, $ignore_usage);
      if ($result) {
        $item
          ->removeFromJs();
        $item
          ->remove();
        $success[] = $item;
      }
    }
  }
  return $success;
}