getEndMiddleware

@return  Psr7InvokableInterface|callable
543469
protected function getEndMiddleware()
    {
        if (!$this->endMiddleware) {
            $this->endMiddleware = new Psr7Middleware(
                function ($request, $response) {
                    return $response;
                }
            );
        }

        return $this->endMiddleware;
    }
451304
private function decorate($middleware): MiddlewareInterface
    {
        if ($middleware instanceof MiddlewareInterface) {
            return $middleware;
        } elseif ($middleware instanceof RequestHandlerInterface) {
            return new RequestHandlerMiddleware($middleware);
        } elseif ($middleware instanceof ResponseInterface) {
            return new FixedResponseMiddleware($middleware);
        } elseif (is_callable($middleware)) {
            return new CallableMiddleware($middleware);
        } elseif (is_string($middleware)) {
            return new LazyLoadingMiddleware($middleware, $this->container);
        } else {
            throw new InvalidArgumentException(sprintf(
                'Middleware "%s" is neither a string service name, an autoloadable class name, a PHP callable, or an instance of %s/%s/%s',
                is_object($middleware) ? get_class($middleware) : gettype($middleware),
                MiddlewareInterface::class, ResponseInterface::class, RequestHandlerInterface::class
            ));
        }
    }
77657
protected function retryMiddleware()
    {
        return Middleware::retry(function (
            $retries,
            RequestInterface $request,
            ResponseInterface $response = null,
            RequestException $exception = null
        ) {
            // Max retry count is 3
            if ($retries > 2) {
                return false;
            }

            // Connection failed
            if ($exception instanceof ConnectException) {
                return true;
            }

            return false;
        });
    }
1199347
protected function currentStackMiddleware() : MiddlewareStorage
    {
        // add current object as first middleware middleware
        if (count($this->middleware) === 0) {
            $middleware = method_exists($this, '__invoke')
                ? $this
                : new FakeMiddlewareInvokable();
            $this->middleware[] = new MiddlewareStorage($middleware);
        }

        $middleware = end($this->middleware);
        return $middleware;
    }
629313
protected function registerCmsWebGroupMiddleware()
    {
        $this->router->middlewareGroup($this->getConfiguredWebGroupName(), []);

        foreach ($this->getGlobalWebMiddleware() as $middleware) {

            // Don't add if the middleware is already globally enabled in the kernel
            if ($this->kernel->hasMiddleware($middleware)) {
                // @codeCoverageIgnoreStart
                continue;
                // @codeCoverageIgnoreEnd
            }

            $this->router->pushMiddlewareToGroup($this->getConfiguredWebGroupName(), $middleware);
        }

        return $this;
    }
476911
public function getMiddlewareForMethod($method)
    {
        $middleware = [];

        foreach ($this->middleware as $name => $options) {
            if (isset($options['only']) && ! \in_array($method, (array) $options['only'])) {
                continue;
            }

            if (isset($options['except']) && \in_array($method, (array) $options['except'])) {
                continue;
            }

            $middleware[] = $name;
        }

        return $middleware;
    }
338206
protected function marshalMiddleware($middleware)
    {
        if (!$middleware instanceof Psr7InvokableInterface) {
            $middleware = new Psr7Middleware($middleware);
        }

        return parent::marshalMiddleware($middleware);
    }
870005
private function curlSend()
    {
        $arguments = func_get_args();

        $httpMethod = array_shift($arguments);

        $data = array_shift($arguments);

        $endPointUrl = array_shift($arguments);

        $curlHandle = $this->curlInit();

        curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, $httpMethod);
        curl_setopt($curlHandle, CURLOPT_POSTFIELDS, (string)$data);
        curl_setopt($curlHandle, CURLOPT_HTTPHEADER, array_merge(array('Content-Type: application/json'), $this->childauth));

        return $this->curlExec(
            $curlHandle,
            $endPointUrl
        );
    }
439206
protected function getApiKeyMiddleware()
    {
        $handleRequest = function (RequestInterface $request) {
            return $request->withUri(Uri::withQueryValue(
                $request->getUri(),
                static::PARAM_API_KEY,
                $this->apiKey
            ));
        };

        return Middleware::mapRequest($handleRequest);
    }
1047702
public static function getBackend()
    {
        if(!is_object(self::$backend))
        {
            self::$backend = new \Monolog\Logger(self::$name);
            self::$backend->pushHandler(self::getStreamHandler());
            self::setLogFormat(self::$logFormat);
        }
        return self::$backend;
    }
913914
protected function getHandler()
    {
        $stack = HandlerStack::create();

        foreach ($this->middlewares as $middleware) {
            $stack->push($middleware);
        }

        if (isset(static::$defaults['handler']) && is_callable(static::$defaults['handler'])) {
            $stack->push(static::$defaults['handler'], self::USER_DEFINED_HANDLER);
        }

        return $stack;
    }
434981
public function getSubscription()
    {
        if ($this->getGateway() instanceof GatewayInterface) {
            return $this->getGateway()->getSubscriptionByReference($this->getSubscriptionReference());
        }

        throw new RuntimeException('Gateway is not set');
    }
270899
public function getErrorProcessor(): MiddlewareInterface
    {
        if (is_null($this->errorProcessor)) {
            if (method_exists($this, 'resolve')) {
                $this->setErrorProcessor($this->resolve(Middleware::class));
            } else {
                $this->setErrorProcessor(new Middleware());
            }
        }

        return $this->errorProcessor;
    }
864455
protected function getComposer()
    {
        if (!$this->composer) {
            // Set composer environment variables
            putenv('COMPOSER_HOME=' . $this->app['path_resolver']->resolve('%cache%/composer'));

            // Set working directory
            chdir($this->getOptions()->baseDir());

            try {
                // Use the factory to get a new Composer object
                $this->composer = Factory::create($this->getIO(), $this->getOptions()->composerJson()->getPath(), false);
            } catch (\InvalidArgumentException $e) {
                throw new PackageManagerException($e->getMessage(), $e->getCode(), $e);
            } catch (\Exception $e) {
                $this->app['logger.system']->critical($e->getMessage(), ['event' => 'exception', 'exception' => $e]);
                throw $e;
            }

            // Add the event subscriber
            $this->composer->getEventDispatcher()->addSubscriber($this->app['extend.listener']);

            if (!$this->app['extend.manager']->useSsl()) {
                $this->setAllowSslDowngrade(true);
            }
        }

        return $this->composer;
    }
530863
protected function getMiddlewareChain()
    {
        $middlewares = array_reverse(iterator_to_array(clone $this->middlewares));

        $chain = new ChainBuilder();

        foreach ($middlewares as $middleware) {
            // If is class name, just create it.
            if (is_string($middleware) && is_subclass_of($middleware, AbstractControllerMiddleware::class)) {
                $middleware = $this->container->newInstance($middleware, ['controller' => $this]);
            } elseif ($middleware instanceof \Closure) {
                // If is closure, we bind $this to current object
                $middleware->bindTo($this);
            }

            $chain->add($middleware);
        }

        return $chain;
    }
525722
public function getActiveEndpoint()
    {
        // try to get endpoint with status active
        $active = $this->getEndpoints()->filter(function (Endpoint $endpoint) {
            return $endpoint->isActive();
        });

        // when empty, try other endpoints
        if ($active->isEmpty() === true) {
            $active = $this->getEndpoints()->filter(function (Endpoint $endpoint) {
                return $this->canBeActivated($endpoint);
            });
        }

        if ($active->isEmpty() === true) {
            throw new NoServerAvailableException('No active server available');
        }

        /** @var Endpoint $endpoint */
        $endpoint = $active->first();
        $endpoint->setStatus(Endpoint::STATUS_ACTIVE);

        return $endpoint;
    }
462795
public function getMultiExtendObjectBuilder()
    {
        if (!isset($this->multiExtendObjectBuilder)) {
            $this->multiExtendObjectBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'objectmultiextend');
        }

        return $this->multiExtendObjectBuilder;
    }