You are here

class SemaphoreStorage in Lightweight Directory Access Protocol (LDAP) 8.3

Management of the semaphore.

This helps us to not run the same operation multiple times per request per user.

Hierarchy

Expanded class hierarchy of SemaphoreStorage

4 files declare their use of SemaphoreStorage
DrupalUserProcessor.php in ldap_user/src/Processor/DrupalUserProcessor.php
InitSubscriber.php in ldap_user/src/EventSubscriber/InitSubscriber.php
LdapUserAdminForm.php in ldap_user/src/Form/LdapUserAdminForm.php
SemaphoreStorageTests.php in ldap_user/tests/src/Unit/SemaphoreStorageTests.php

File

ldap_user/src/Helper/SemaphoreStorage.php, line 11

Namespace

Drupal\ldap_user\Helper
View source
class SemaphoreStorage {
  private static $accounts = [];

  /**
   * Set value.
   *
   * @param string $action
   *   Action to apply on (e.g. 'sync').
   * @param string $identifier
   *   User identifier.
   */
  public static function set($action, $identifier) {
    self::$accounts[$action][$identifier] = TRUE;
  }

  /**
   * Get value.
   *
   * @param string $action
   *   Action to apply on (e.g. 'sync').
   * @param string $identifier
   *   User identifier.
   *
   * @return bool
   *   Boolean answer whether identifier present for action.
   */
  public static function get($action, $identifier) {
    if (isset(self::$accounts[$action], self::$accounts[$action][$identifier])) {
      return TRUE;
    }
    else {
      return FALSE;
    }
  }

  /**
   * Flush saved data for account.
   *
   * @param string $action
   *   Action to apply on (e.g. 'sync').
   * @param string $identifier
   *   User identifier.
   */
  public static function flushValue($action, $identifier) {
    unset(self::$accounts[$action][$identifier]);
  }

  /**
   * Flush all values.
   */
  public static function flushAllValues() {
    self::$accounts = [];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SemaphoreStorage::$accounts private static property
SemaphoreStorage::flushAllValues public static function Flush all values.
SemaphoreStorage::flushValue public static function Flush saved data for account.
SemaphoreStorage::get public static function Get value.
SemaphoreStorage::set public static function Set value.