Error: Call to undefined function Drupal\d8module\Batch\entity_delete_multiple

发布于 / bug飞 / 0条评论 / Tags: drupal / 10 次浏览

drupal的批量删除api,entity_delete_multiple,已经被删除
  1. 请使用新的api

     $bookManager = \Drupal::service('book.manager');
     $entity = \Drupal::entityTypeManager()->getStorage('node');
    
     $context['message'] = t('Deleting %title', ['%title' => $queue->title]);
     $query = $entity->getQuery();
     //todo 如果pid不为空,按pid查,否则,按title查
     $id = $query
       ->condition('type', 'book')
       ->condition('title', $queue->title)
       ->execute();
    
     // Load multiples or single item load($id) https://drupalbook.org/drupal/9111-working-entity-fields-programmatically
     $books = $entity->loadMultiple($id);
    
     if (!empty($books)) {
       foreach ($books as $book) {
         if ($bookManager->loadBookLink($book->id())) {
           $bookManager->deleteFromBook($book->id());
         }
    
       }
       $entity->delete($books);
     }

    评论区(暂无评论)