EntityDeleteAction.php in Views Bulk Operations (VBO) 8.2
File
src/Plugin/Action/EntityDeleteAction.php
View source
<?php
namespace Drupal\views_bulk_operations\Plugin\Action;
use Drupal\views_bulk_operations\Action\ViewsBulkOperationsActionBase;
use Drupal\Core\Session\AccountInterface;
class EntityDeleteAction extends ViewsBulkOperationsActionBase {
public function execute($entity = NULL) {
$entity
->delete();
return $this
->t('Delete entities');
}
public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
$access = $object
->access('delete', $account, TRUE);
if ($object
->getEntityType() === 'node') {
$access
->andIf($object->status
->access('delete', $account, TRUE));
}
return $return_as_object ? $access : $access
->isAllowed();
}
}