You are here

ReusableBlockDelete.php in Gutenberg 8

Same filename and directory in other branches
  1. 8.2 src/Plugin/Action/ReusableBlockDelete.php

File

src/Plugin/Action/ReusableBlockDelete.php
View source
<?php

namespace Drupal\gutenberg\Plugin\Action;

use Drupal\Core\Action\ActionBase;
use Drupal\Core\Session\AccountInterface;

/**
 * Delete reusable block.
 *
 * @Action(
 *   id = "reusable_block_delete_action",
 *   label = @Translation("Delete reusable block"),
 *   type = "block_content"
 * )
 */
class ReusableBlockDelete extends ActionBase {

  /**
   * {@inheritdoc}
   */
  public function execute($entity = NULL) {

    /** @var \Drupal\block_content\BlockContentInterface $entity */
    $entity
      ->delete();
  }

  /**
   * {@inheritdoc}
   */
  public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {

    /** @var \Drupal\block_content\BlockContentInterface $object */
    return $object
      ->access('delete', $account, $return_as_object);
  }

}

Classes

Namesort descending Description
ReusableBlockDelete Delete reusable block.