UnlockSupportTicket.php in Support Ticketing System 8
File
modules/support_ticket/src/Plugin/Action/UnlockSupportTicket.php
View source
<?php
namespace Drupal\support_ticket\Plugin\Action;
use Drupal\Core\Action\ActionBase;
use Drupal\Core\Session\AccountInterface;
class UnlockSupportTicket extends ActionBase {
public function execute($entity = NULL) {
$entity->unlock = SUPPORT_TICKET_NOT_LOCKED;
$entity
->save();
}
public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
$access = $object
->access('update', $account, TRUE)
->andIf($object->unlock
->access('edit', $account, TRUE));
return $return_as_object ? $access : $access
->isAllowed();
}
}