Generate a callback function that iterates over
all BeforeInterface middleware.

@return callable
771089
protected function createBeforeFilter() {
    $before = $this->before;

    // closure that iterates over all before filters
    return function ($request) use ($before) {
      foreach ($before as $filter) {
        $response = $filter->onBefore($request);
        if (!is_null($response)) {
          return $response;
        }
      }

      return null;
    };
  }
684239
public function dispatch()
    {
        foreach ($this->middleware as $mw) {
            call_user_func_array($mw, array($this));
        }

        $return = call_user_func_array($this->getCallable(), array_values($this->getParams()));
        return ($return === false) ? false : true;
    }
87378
protected function resolveBefore($before)
    {
        $getBefore = $this->resolveMiddleware($before);

        return function (Request $request, Application $app) use ($getBefore) {
            $callback = $getBefore($request);
            if (!is_callable($callback)) {
                return null;
            }

            return $callback($request, $app);
        };
    }
464696
protected function prepareCallbacks(callable $callback/*, ... */) {
		list($init, $done, $then) = $this->getCallbacks();
		
		$context = $init();
		foreach (func_get_args() as $cb) {
			$then($context, $cb);
		}
		
		return array($context, function($result) use ($context, $done) {
			$done($context, $result);
		});
	}
496815
protected function runCallable()
    {
        $parameters = $this->resolveMethodDependencies(
            $this->getParametersWithoutNulls(), new ReflectionFunction($this->action['uses'])
        );

        $callable = $this->action['uses'];

        return call_user_func_array($callable, $parameters);
    }
147289
protected function callAfterDispatchCallbacks()
    {
        try {
            foreach ($this->after_filter_callbacks as $callback) {
                if (is_callable($callback)) {
                    if (is_string($callback)) {
                        $callback($this);

                    } else {
                        call_user_func($callback, $this);

                    }
                }
            }
        } catch (Throwable $e) { // PHP 7 compatibility
            $this->error($e);
        } catch (Exception $e) { // TODO: Remove this catch block once PHP 5.x support is no longer necessary.
            $this->error($e);
        }
    }
607886
private function preUse(Middleware $call)
    {
        $class = get_class($call);
        if (in_array($class, $this->preMiddlewareArr)) {
            throw new Exception($class . ' Pre-Middleware has loaded');
        }
        $this->preMiddlewareArr[] = $class;
        if ($this->preMiddleware) {
            $call->nextMiddleware($this->preMiddleware);
        }
        $call->setVitex($this);
        $this->preMiddleware = $call;
        return $this;
    }
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;
    }
1214530
public function after($callback)
    {
        $callbacks = $this->getOption('_after_middlewares');
        $callbacks[] = $callback;
        $this->setOption('_after_middlewares', $callbacks);

        return $this;
    }
26361
public function getCallbackFunction()
    {
        if ($this->callbackFunction)
            return $this->callbackFunction;
        if ($this->getParent())
            return $this->getParent()->getCallbackFunction();
        return null;
    }
308430
public function uiRegister() : Closure
  {
    return function($exception, $inspector, $run) {
      $appHandler = new \App\Exceptions\Handler();

      if ($exception instanceof Exception) {
        return $appHandler->render(
          $this->getRequest() ?? new Request(array_merge($_POST, $_FILES)),
          $exception
        );
      }

      Events::trigger('internal.error', [$exception]);
    };
  }
1100572
public function callback()
    {
        $generator = $this->getGenerator();
        try {
            $this->io->write('<info>Generating OXID eShop unified namespace classes ... </info>', false);
            $generator->cleanupOutputDirectory();
            $generator->generate();
            $this->io->write('<info>Done</info>');
        } catch (\Exception $exception) {
            $this->io->writeError('<error>Failed</error>');
            $this->io->writeError('<error>Error: ' . $exception->getMessage() . '</error>');
            $this->io->writeError('<error>Code: ' . $exception->getCode() . '</error>');
            $this->io->writeError('<error>Stacktrace: ' . PHP_EOL . $exception->getTraceAsString() . '</error>');
        }
    }
1126959
public static function getCaller()
    {
        $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
        if (isset($backtrace[2])) {
            $caller = '';
            if (isset($backtrace[2]['class'])) {
                $caller = $backtrace[2]['class'] . $backtrace[2]['type'];
            }
            $caller .= $backtrace[2]['function'];
            return $caller;
        }
        return '{null}';
    }
1225751
public function append(MiddlewareInterface $middleware){
        if($this->isAlreadyRegistered($middleware)){
            throw new Exception\MiddlewareAlreadyRegisteredException(
                static::createMsgAlreadyRegisterd($middleware)
            );
        }

        $this->registerd[$middleware]   = true;

        $this->queue->push($middleware);

        return $this;
    }
362739
public function get_callback_reflection() {
		if ( is_array( $this->callback ) ) {
			return new \ReflectionMethod( $this->callback[0], $this->callback[1] );
		} else {
			return new \ReflectionFunction( $this->callback );
		}
	}
437248
public static function generateStepItem($context = null, $callback = null)
    {
        return new class ($context, $callback) {
            public $context;
            public $callback;
            
            public function __construct($context, $callback)
            {
                $this->context  = $context;
                $this->callback = $callback;
            }
        };
    }
1025470
public function getCreateCallback() {
		if ($this->_createCallback === null) {
			$this->_createCallback = function($path) {
				return new Dummy();
			};
		}
		
		return $this->_createCallback;
	}