You are here

protected function CasAttributesSubscriber::checkRoleMatchExactSingle in CAS Attributes 8

Same name and namespace in other branches
  1. 2.x src/Subscriber/CasAttributesSubscriber.php \Drupal\cas_attributes\Subscriber\CasAttributesSubscriber::checkRoleMatchExactSingle()

Check if attributes match using the 'exact_single' method.

This method checks that the the attribute values match exactly. The attribute is expected to be a single value, and not a multi value attribute.

Parameters

array $attributeValue: The actual attribute value.

string $valueToMatch: The attribute value to compare against.

Return value

bool TRUE if there's a match, FALSE otherwise.

1 call to CasAttributesSubscriber::checkRoleMatchExactSingle()
CasAttributesSubscriber::doRoleMapCheck in src/Subscriber/CasAttributesSubscriber.php
Determine which roles should be added/removed based on attributes.

File

src/Subscriber/CasAttributesSubscriber.php, line 262

Class

CasAttributesSubscriber
Provides a CasAttributesSubscriber.

Namespace

Drupal\cas_attributes\Subscriber

Code

protected function checkRoleMatchExactSingle(array $attributeValue, $valueToMatch) {

  // The expectation for this method is that the attribute is not multi-value.
  if (count($attributeValue) > 1) {
    return FALSE;
  }
  $value = array_shift($attributeValue);
  if ($value === $valueToMatch) {
    return TRUE;
  }
  return FALSE;
}