class InlineEditingDisabler in Workbench Moderation 8
Same name and namespace in other branches
- 8.2 src/InlineEditingDisabler.php \Drupal\workbench_moderation\InlineEditingDisabler
Disables the inline editing for entities with forward revisions.
Hierarchy
- class \Drupal\workbench_moderation\InlineEditingDisabler
Expanded class hierarchy of InlineEditingDisabler
1 string reference to 'InlineEditingDisabler'
1 service uses InlineEditingDisabler
File
- src/
InlineEditingDisabler.php, line 11
Namespace
Drupal\workbench_moderationView source
class InlineEditingDisabler {
/**
* The moderation info.
*
* @var \Drupal\workbench_moderation\ModerationInformationInterface
*/
protected $moderationInfo;
/**
* Creates a new InlineEditingDisabler instance.
*
* @param \Drupal\workbench_moderation\ModerationInformationInterface $moderation_info
* The moderation info.
*/
public function __construct(ModerationInformationInterface $moderation_info) {
$this->moderationInfo = $moderation_info;
}
/**
* Implements hook_entity_view_alter().
*/
public function entityViewAlter(&$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
if ($this->moderationInfo
->isModeratableEntity($entity) && !$this->moderationInfo
->isLatestRevision($entity)) {
// Hide quickedit, because its super confusing for the user to not edit
// the live revision.
unset($build['#attributes']['data-quickedit-entity-id']);
}
}
/**
* Implements hook_module_implements_alter().
*/
public function moduleImplementsAlter(&$implementations, $hook) {
if ($hook == 'entity_view_alter') {
// Find the quickedit implementation and move workbench after it.
unset($implementations['workbench_moderation']);
$implementations['workbench_moderation'] = FALSE;
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
InlineEditingDisabler:: |
protected | property | The moderation info. | |
InlineEditingDisabler:: |
public | function | Implements hook_entity_view_alter(). | |
InlineEditingDisabler:: |
public | function | Implements hook_module_implements_alter(). | |
InlineEditingDisabler:: |
public | function | Creates a new InlineEditingDisabler instance. |