Require and call middleware classes.

@return null
554281
protected static function middleware()
    {
        foreach (self::fetch('http/middleware') as $file) {
            Bus::need($file);
        }

        Middleware::ini();
    }
935806
public function requiresPlugins()
    {
        $has     = class_uses_recursive(get_called_class());
        $check   = array_combine(func_get_args(), func_get_args());
        $missing = array_values(array_diff($check, $has));
        if (isset($missing[ 0 ])) {
            $plugin = collect(debug_backtrace())->where('function', 'requiresPlugins')->first();
            throw ProviderPluginDependencyException::plugin($plugin[ 'file' ], implode(', ', $missing));
        }
    }
705101
public function call()
    {

        $env = $this->app->environment;

        // The Slim error handler doesn't work for middleware, so we have to wrap everything in a try/catch.
        // See https://github.com/codeguy/Slim/issues/841
        try {

            // Set up authN/authZ if an URL mapping was given.
            $this->_parseInterceptMap($env);
            // Authenticate and authorize Request
            $this->_authenticate($env);

            // Run inner middleware and application
            $this->next->call();
        } catch (Exception $e) {
            $this->_handleException($e);
        }
    }
56704
function () {

    this.middlewarePaths.forEach(function (mwPath) {

      require(mwPath)(this);

      debug(format('mounted middleware/%s', path.basename(mwPath)));

    }, this);

  }
387507
private function apply_middleware()
    {
        if (empty($this->middleware)) {
            return;
        }

        foreach ($this->middleware as $hook => $args) {
            /**
             * Execute the middleware callback via snap_middleware_{$middleware} filter.
             *
             * This hook can return true to continue processing the route, bail via a redirect,
             * or return false to short circuit and move to the next route.
             *
             * @since  1.0.0
             *
             * @param Request $request The current request for quick access.
             * @return  bool Whether to continue processing this route.
             */
            if (\apply_filters($hook, Container::get('request'), ...$args) !== true) {
                $this->shortcircuit = true;
            }
        }
    }
238947
public function getPostprocessor(): MiddlewareInterface
    {
        if (is_null($this->postProcessor)) {
            if (method_exists($this, 'resolve')) {
                $this->setPostprocessor($this->resolve(Middleware::class));
            } else {
                $this->setPostprocessor(new Middleware());
            }
        }

        return $this->postProcessor;
    }
1144281
public function loadConfiguration(): void
	{
		$builder = $this->getContainerBuilder();
		$config = $this->validateConfig($this->defaults);

		Validators::assertField($config, 'middlewares', 'array');

		// Register middleware chain builder
		$chain = $builder->addDefinition($this->prefix('chain'))
			->setAutowired(false);

		if ($config['debug'] !== true) {
			$chain->setFactory(ChainBuilder::class);
		} else {
			$chain->setFactory(DebugChainBuilder::class);

			$builder->addDefinition($this->prefix('middlewaresPanel'))
				->setFactory(MiddlewaresPanel::class, [$chain]);
		}
	}
1320252
private function cliIO()
    {
        $services = [
            'Cli\Input'  => 'input',
            'Cli\Output' => 'output',
        ];

        foreach ($services as $className => $classOffset) {
            $this->services->load($className, $classOffset);
        }
    }
275959
public function instantiateClasses()
    {
        $data = $this->getData();

        // Always load these
        if (isset($data['always']))
        {
            $this->instantiateGroup($data['always']);
        }

        // These only in admin
        if (is_admin() && isset($data['admin']))
        {
            $this->instantiateGroup($data['admin']);
        }

        // These only in frontend
        if ( !is_admin() && isset($data['frontend']))
        {
            $this->instantiateGroup($data['frontend']);
        }
    }
214809
public function call($params = null)
    {
        $method = $this->method;

        if (!empty($this->constructor_arguments)) {
            $instance = new $this->class($this->constructor_arguments);
        } else {
            $instance = new $this->class();
        }
        if (!is_null($params)) {
            return $instance->$method($params);
        }
        return $instance->$method();
    }
324525
private function call() {

        if(null === $this -> driver) {
            return trigger_error('Driver is not set. Set the driver with the setDriver() method', E_USER_ERROR);
        }

        if(null === $this -> image) {
        	return trigger_error('Image has not been set. Set the image with the setImage() method', E_USER_ERROR);
        }

        if(null === $this -> driverInstance) {
        	$this -> driverInstance = new $this -> driver($this -> image);
        }

        return $this -> driverInstance;
    }
969097
private function middlewareGenerator()
    {
        $middlewares = $this->middleware;
        ksort($middlewares);

        foreach ($middlewares as $priorityGroup) {
            foreach ($priorityGroup as $middleware) {
                yield $middleware;
            }
        }
    }
526233
public function middleware($middlewares)
    {
        $middlewares = (array) $middlewares;

        $this->middlewares = [];

        foreach ($middlewares as $middleware) {
            if (is_callable($middleware)) {
                $this->middlewares[] = $middleware;
            } elseif (class_exists($middleware, true)) {
                $this->middlewares[] = [new $middleware, 'process'];
            } else {
                $this->middlewares[] = $middleware;
            }
        }

        return $this;
    }
1134176
public function loadPluginConfiguration(): void
	{
		$builder = $this->getContainerBuilder();
		$global = $this->compiler->getExtension()->getConfig();
		$config = $this->getConfig();

		if ($config['tracy'] === true) {
			$builder->addDefinition($this->prefix('tracy'))
				->setFactory(TracyMiddleware::class . '::factory', [$global['debug']])
				->addTag(MiddlewaresExtension::MIDDLEWARE_TAG, ['priority' => 100]);
		}

		if ($config['autobasepath'] === true) {
			$builder->addDefinition($this->prefix('autobasepath'))
				->setFactory(AutoBasePathMiddleware::class)
				->addTag(MiddlewaresExtension::MIDDLEWARE_TAG, ['priority' => 200]);
		}

		$builder->addDefinition($this->prefix('api'))
			->setFactory(ApiMiddleware::class)
			->addTag(MiddlewaresExtension::MIDDLEWARE_TAG, ['priority' => 500]);
	}
158577
protected static function load()
    {
        need(root().'app/http/Filter.php');

        $filter = instance(\App\Http\Filter::class);

        self::$filters['app'] = $filter::$middleware;
        self::$filters['route'] = $filter::$routeMiddleware;

        return self::$filters;
    }
897373
public function middleware($middleware = null)
    {
        if (is_null($middleware)) {
            return (array) ($this->action['middleware'] ?? []);
        }

        if (is_string($middleware)) {
            $middleware = func_get_args();
        }

        $this->action['middleware'] = array_merge(
            (array) ($this->action['middleware'] ?? []), $middleware
        );

        return $this;
    }
16020
public static function getAppliedFilters()
    {
        $classMethods = get_class_methods(get_class());
        $calledClassMethods = get_class_methods(get_called_class());

        $filteredMethods = array_filter(
            $calledClassMethods, function ($calledClassMethod) use ($classMethods) {
                return !in_array($calledClassMethod, $classMethods, true);
            }
        );

        return \Illuminate\Support\Facades\Request::only($filteredMethods);
    }