function HookCollectorPass::hasAnyAttribute

Returns whether the existing attributes match any of the expected ones.

Parameters

array $existingAttributes: List of attribute classes.

array $attributesLookingFor: List of expected attribute classes.

Return value

bool Whether an expected attribute class exists.

1 call to HookCollectorPass::hasAnyAttribute()
HookCollectorPass::collectModuleHookImplementations in core/lib/Drupal/Core/Hook/HookCollectorPass.php
Collects procedural and Attribute hook implementations.

File

core/lib/Drupal/Core/Hook/HookCollectorPass.php, line 583

Class

HookCollectorPass
Collects and registers hook implementations.

Namespace

Drupal\Core\Hook

Code

public static function hasAnyAttribute(array $existingAttributes, array $attributesLookingFor) : bool {
  foreach ($existingAttributes as $existingAttribute) {
    foreach ($attributesLookingFor as $attributeLookingFor) {
      if (is_a($existingAttribute, $attributeLookingFor, TRUE)) {
        return TRUE;
      }
    }
  }
  return FALSE;
}

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