BreakLock.php in Content locking (anti-concurrent editing) 8
File
src/Plugin/Action/BreakLock.php
View source
<?php
namespace Drupal\content_lock\Plugin\Action;
use Drupal\content_lock\ContentLock\ContentLock;
use Drupal\Core\Action\ActionBase;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Session\AccountInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class BreakLock extends ActionBase implements ContainerFactoryPluginInterface {
protected $lockService;
public function __construct(array $configuration, $plugin_id, $plugin_definition, ContentLock $contentLock) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->lockService = $contentLock;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('content_lock'));
}
public function execute(ContentEntityInterface $entity = NULL) {
$this->lockService
->release($entity
->id(), $entity
->language(), NULL, NULL, $entity
->getEntityTypeId());
}
public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
return $object
->access('update', $account, $return_as_object);
}
}
Classes
Name |
Description |
BreakLock |
Provides an action that can break a lock. |