function CommonTestHooks::drupalAlterAlter

Implements hook_TYPE_alter().

Attributes

#[Hook('drupal_alter_alter')]

File

core/modules/system/tests/modules/common_test/src/Hook/CommonTestHooks.php, line 17

Class

CommonTestHooks
Hook implementations for common_test.

Namespace

Drupal\common_test\Hook

Code

public function drupalAlterAlter(&$data, &$arg2 = NULL, &$arg3 = NULL) : void {
  // Alter first argument.
  if (is_array($data)) {
    $data['foo'] = 'Drupal';
  }
  elseif (is_object($data)) {
    $data->foo = 'Drupal';
  }
  // Alter second argument, if present.
  if (isset($arg2)) {
    if (is_array($arg2)) {
      $arg2['foo'] = 'Drupal';
    }
    elseif (is_object($arg2)) {
      $arg2->foo = 'Drupal';
    }
  }
  // Try to alter third argument, if present.
  if (isset($arg3)) {
    if (is_array($arg3)) {
      $arg3['foo'] = 'Drupal';
    }
    elseif (is_object($arg3)) {
      $arg3->foo = 'Drupal';
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.