LogMarkAsPending.php in Log entity 2.x
File
src/Plugin/Action/LogMarkAsPending.php
View source
<?php
namespace Drupal\log\Plugin\Action;
use Drupal\Core\Action\ActionBase;
use Drupal\Core\Session\AccountInterface;
use Drupal\log\Entity\LogInterface;
class LogMarkAsPending extends ActionBase {
public function execute(LogInterface $log = NULL) {
if ($log) {
$log
->get('status')
->first()
->applyTransitionById('to_pending');
$log
->setNewRevision(TRUE);
$log
->save();
}
}
public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
$result = $object
->get('status')
->access('edit', $account, TRUE)
->andIf($object
->access('update', $account, TRUE));
return $return_as_object ? $result : $result
->isAllowed();
}
}