entity_generic-8.x-3.x-dev/src/Plugin/Action/UnmarkDeletedAction.php
src/Plugin/Action/UnmarkDeletedAction.php
<?php namespace Drupal\entity_generic\Plugin\Action; use Drupal\Core\Action\Plugin\Action\EntityActionBase; use Drupal\Core\Session\AccountInterface; use Drupal\entity_generic\Entity\GenericInterface; /** * @Action( * id = "entity:unmark_deleted_action", * label = @Translation("Unmark entity as deleted"), * deriver = "Drupal\entity_generic\Plugin\Action\Derivative\UnmarkDeletedActionDeriver", * ) */ class UnmarkDeletedAction extends EntityActionBase { /** * {@inheritdoc} */ public function execute($entity = NULL) { $entity->setDeleted(GenericInterface::ENTITY_GENERIC_UNDELETED); $entity->save(); } /** * {@inheritdoc} */ public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) { $result = $object->access('update', $account, TRUE); return $return_as_object ? $result : $result->isAllowed(); } }