Commit 06825048 authored by Marcin Grabias's avatar Marcin Grabias
Browse files

Allowed non Batch API operations to use context as well; coding standards fixes.

parent f5748662
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ class ActionsPermissionsEventSubscriber implements EventSubscriberInterface {

  // Subscribe to the VBO event with low priority
  // to let other modules alter requirements first.
  const PRIORITY = -999;
  private const PRIORITY = -999;

  /**
   * {@inheritdoc}
+3 −3
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ class ViewsBulkOperationExampleAction extends ViewsBulkOperationsActionBase impl
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state): array {
    $form['example_config_setting'] = [
      '#title' => \t('Example setting pre-execute'),
      '#title' => $this->t('Example setting pre-execute'),
      '#type' => 'textfield',
      '#default_value' => $form_state->getValue('example_config_setting'),
    ];
@@ -107,8 +107,8 @@ class ViewsBulkOperationExampleAction extends ViewsBulkOperationsActionBase impl
   * {@inheritdoc}
   */
  public function access($object, ?AccountInterface $account = NULL, $return_as_object = FALSE) {
    // If certain fields are updated, access should be checked against them as well.
    // @see Drupal\Core\Field\FieldUpdateActionBase::access().
    // If certain fields are updated, access should be checked against them
    // as well. @see Drupal\Core\Field\FieldUpdateActionBase::access().
    return $object->access('update', $account, $return_as_object);
  }

+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ class ViewsBulkOperationsAccess implements AccessInterface {
   * @param \Drupal\Core\Routing\RouteMatch $routeMatch
   *   The matched route.
   */
  public function access(AccountInterface $account, RouteMatch $routeMatch) {
  public function access(AccountInterface $account, RouteMatch $routeMatch): AccessResult {
    $parameters = $routeMatch->getParameters()->all();

    if ($view = Views::getView($parameters['view_id'])) {
+4 −4
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ abstract class ViewsBulkOperationsActionBase extends ActionBase implements Views
  /**
   * Action context.
   *
   * @var array
   * Contains view data and optionally batch operation context.
   */
  protected array $context;
@@ -35,6 +34,7 @@ abstract class ViewsBulkOperationsActionBase extends ActionBase implements Views
   * Configuration array.
   *
   * @var array
   *   NOTE: Don't add a type hint due to parent declaration unless changed.
   */
  protected $configuration;

@@ -88,7 +88,7 @@ abstract class ViewsBulkOperationsActionBase extends ActionBase implements Views
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The form state object.
   */
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state): void {

  }

@@ -103,7 +103,7 @@ abstract class ViewsBulkOperationsActionBase extends ActionBase implements Views
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The form state object.
   */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state): void {
    $form_state->cleanValues();
    foreach ($form_state->getValues() as $key => $value) {
      $this->configuration[$key] = $value;
+3 −2
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Drupal\views_bulk_operations\Action;

use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Symfony\Component\HttpFoundation\RedirectResponse;

/**
@@ -15,7 +16,7 @@ trait ViewsBulkOperationsActionCompletedTrait {
   *
   * @see \Drupal\Core\Messenger\MessengerInterface
   */
  public static function message($message = NULL, $type = 'status', $repeat = TRUE) {
  public static function message($message = NULL, $type = 'status', $repeat = TRUE): void {
    \Drupal::messenger()->addMessage($message, $type, $repeat);
  }

@@ -24,7 +25,7 @@ trait ViewsBulkOperationsActionCompletedTrait {
   *
   * @see \Drupal\Core\StringTranslation\TranslationInterface:translate()
   */
  public static function translate($string, array $args = [], array $options = []) {
  public static function translate($string, array $args = [], array $options = []): TranslatableMarkup {
    return \Drupal::translation()->translate($string, $args, $options);
  }

Loading