Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. HandlerStack.php

function HandlerStack::splice

Splices a function into the middleware list at a specific position.

2 calls to HandlerStack::splice()
HandlerStack::after in vendor/guzzlehttp/guzzle/src/HandlerStack.php
Add a middleware after another middleware by name.
HandlerStack::before in vendor/guzzlehttp/guzzle/src/HandlerStack.php
Add a middleware before another middleware by name.

File

vendor/guzzlehttp/guzzle/src/HandlerStack.php, line 234

Class

HandlerStack
Creates a composed Guzzle handler function by stacking middlewares on top of an HTTP handler function.

Namespace

GuzzleHttp

Code

private function splice(string $findName, string $withName, callable $middleware, bool $before) : void {
    $this->cached = null;
    $idx = $this->findByName($findName);
    $tuple = [
        $middleware,
        $withName,
    ];
    if ($before) {
        if ($idx === 0) {
            \array_unshift($this->stack, $tuple);
        }
        else {
            $replacement = [
                $tuple,
                $this->stack[$idx],
            ];
            \array_splice($this->stack, $idx, 1, $replacement);
        }
    }
    elseif ($idx === \count($this->stack) - 1) {
        $this->stack[] = $tuple;
    }
    else {
        $replacement = [
            $this->stack[$idx],
            $tuple,
        ];
        \array_splice($this->stack, $idx, 1, $replacement);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal