[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/guzzlehttp/guzzle/src/Event/ -> RequestEvents.php (source)

   1  <?php
   2  namespace GuzzleHttp\Event;
   3  
   4  /**
   5   * Contains methods used to manage the request event lifecycle.
   6   */
   7  final class RequestEvents
   8  {
   9      // Generic event priorities
  10      const EARLY = 10000;
  11      const LATE = -10000;
  12  
  13      // "before" priorities
  14      const PREPARE_REQUEST = -100;
  15      const SIGN_REQUEST = -10000;
  16  
  17      // "complete" and "error" response priorities
  18      const VERIFY_RESPONSE = 100;
  19      const REDIRECT_RESPONSE = 200;
  20  
  21      /**
  22       * Converts an array of event options into a formatted array of valid event
  23       * configuration.
  24       *
  25       * @param array $options Event array to convert
  26       * @param array $events  Event names to convert in the options array.
  27       * @param mixed $handler Event handler to utilize
  28       *
  29       * @return array
  30       * @throws \InvalidArgumentException if the event config is invalid
  31       * @internal
  32       */
  33      public static function convertEventArray(
  34          array $options,
  35          array $events,
  36          $handler
  37      ) {
  38          foreach ($events as $name) {
  39              if (!isset($options[$name])) {
  40                  $options[$name] = [$handler];
  41              } elseif (is_callable($options[$name])) {
  42                  $options[$name] = [$options[$name], $handler];
  43              } elseif (is_array($options[$name])) {
  44                  if (isset($options[$name]['fn'])) {
  45                      $options[$name] = [$options[$name], $handler];
  46                  } else {
  47                      $options[$name][] = $handler;
  48                  }
  49              } else {
  50                  throw new \InvalidArgumentException('Invalid event format');
  51              }
  52          }
  53  
  54          return $options;
  55      }
  56  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1