Unverified Commit f98f93d4 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3501237 by nikolay shapovalov, nicxvan: Improve HookCollectorPass test

(cherry picked from commit b66ca108)
parent 87dd3ddf
Loading
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1632,13 +1632,13 @@
 * - On a method, use the attribute with the hook name:
 *   @code
 *   #[Hook('user_cancel')]
 *   public method userCancel(...)
 *   public function userCancel(...) {}
 *   @endcode
 * - On a class, specify the method name as well as the hook name:
 *   @code
 *   #[Hook('user_cancel', method: 'userCancel')]
 *   class Hooks {
 *     method userCancel(...) {}
 *     public function userCancel(...) {}
 *   }
 *   @endcode
 * - On a class with an __invoke method, which is taken to be the hook
@@ -1646,7 +1646,7 @@
 *   @code
 *   #[Hook('user_cancel')]
 *   class Hooks {
 *     method __invoke(...) {}
 *     public function __invoke(...) {}
 *   }
 *   @endcode
 *
+3 −3
Original line number Diff line number Diff line
@@ -12,13 +12,13 @@
 * - On a method, use this attribute with the hook name:
 *   @code
 *   #[Hook('user_cancel')]
 *   public method userCancel(...)
 *   public function userCancel(...) {}
 *   @endcode
 * - On a class, specifying the method name:
 *   @code
 *   #[Hook('user_cancel', method: 'userCancel')]
 *   class Hooks {
 *     method userCancel(...) {}
 *     public function userCancel(...) {}
 *   }
 *   @endcode
 * - On a class with an __invoke method, which is taken to be the hook
@@ -26,7 +26,7 @@
 *   @code
 *   #[Hook('user_cancel')]
 *   class Hooks {
 *     method __invoke(...) {}
 *     public function __invoke(...) {}
 *   }
 *   @endcode
 *
+5 −0
Original line number Diff line number Diff line
name: 'Test Hook attribute'
type: module
description: 'Test Hook attribute with named arguments, and class with invoke method'
package: Testing
version: VERSION
+23 −0
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

namespace Drupal\hook_collector_hook_attribute\Hook;

use Drupal\Core\Hook\Attribute\Hook;

/**
 * Test Hook attribute named arguments.
 */
#[Hook('cache_flush')]
class HookAttributeInvokeHook {

  /**
   * Implements hook_cache_flush().
   */
  public function __invoke(): void {
    // Set a global value we can check in test code.
    $GLOBALS['hook_invoke_method'] = 'hook_invoke_method';
  }

}
+23 −0
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

namespace Drupal\hook_collector_hook_attribute\Hook;

use Drupal\Core\Hook\Attribute\Hook;

/**
 * Test Hook attribute named arguments.
 */
#[Hook(hook: 'cache_flush', method: 'flush')]
class HookAttributeNamedArgumentsHook {

  /**
   * Implements hook_cache_flush().
   */
  public function flush(): void {
    // Set a global value we can check in test code.
    $GLOBALS['hook_named_arguments'] = 'hook_named_arguments';
  }

}
Loading