moderationInfo = $moderation_info; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { return new static( $configuration, $plugin_id, $plugin_definition, $container->get('content_moderation.moderation_information') ); } /** * {@inheritdoc} */ public function access($entity, AccountInterface $account = NULL, $return_as_object = FALSE) { /** @var \Drupal\node\NodeInterface $entity */ if ($entity && $this->moderationInfo->isModeratedEntity($entity)) { drupal_set_message($this->t("@bundle @label were skipped as they are under moderation and may not be directly published.", ['@bundle' => node_get_type_label($entity), '@label' => $entity->getEntityType()->getPluralLabel()]), 'warning'); $result = AccessResult::forbidden(); return $return_as_object ? $result : $result->isAllowed(); } return parent::access($entity, $account, $return_as_object); } }