Run the route action and return the response.

@return mixed
513767
protected function runClosure()
    {
        $closure = $this->getCommand()->getAction();
        return $closure(
            $this->getCommand()->getRequest(),
            new Response()
        );
    }
70675
public function run()
    {
        // Load in the /application/bootstrap/app.php file
        $this->loadBootstrap();

        $response = null;

        // Check if we're installed
        if ($this->app->isInstalled()) {
            // Call each step in the line
            // @todo Move these to individual middleware, this is basically a duplicated middleware pipeline
            $response = $this->trySteps([
                // Set the active language for the site, based either on the site locale, or the
                // current user record. This can be changed later as well, during runtime.
                // Start localization library.
                'setSystemLocale',

                // Set the system time zone (what should be the same as the database one)
                'initializeSystemTimezone',

                // Handle updating automatically
                'handleUpdates',

                // Set up packages first.
                // We do this because we don't want the entity manager to be loaded and we
                // want to give packages an opportunity to replace classes and load new classes
                'setupPackages',

                // Load site specific timezones. Has to come after packages because it
                // instantiates the site service, which sometimes packages need to override.
                'initializeSiteTimezone',

                // Define legacy urls, this may be the first thing that loads the entity manager
                'initializeLegacyUrlDefinitions',

                // Register legacy tools routes
                'registerLegacyRoutes',

                // Register legacy config values
                'registerLegacyConfigValues',

                // Handle loading permission keys
                'handlePermissionKeys',

                // Handle eventing
                'handleEventing',
            ]);
        } else {
            $this->initializeSystemTimezone();
        }

        // Create the request to use
        $request = $this->createRequest();

        if (!$response) {
            $response = $this->server->handleRequest($request);
        }

        // Prepare and return the response
        return $response->prepare($request);
    }
551299
public function run()
    {
        $this->getLastActionDates();
        $this->getInfoUsers();

        return Response::data([
            'count' => $this->info_users_count,
            'items' => $this->info_users_items,
        ]);
    }
196321
public function run()
    {
        $request = $this->container->get(self::REQUEST);

        $response = $this->handle($request);

        return $this->emit($response)->stream();
    }
1223633
public function run(): SendableResponse
    {
        $request  = WebRequest::fromRawSource();
        $response = new WebResponse($request);
        if ($response->isFixed()) {
            return $response; // http version of request not supported
        }

        try {
            $requestUri = $request->uri();
        } catch (MalformedUri $mue) {
            $response->status()->badRequest();
            return $response;
        }

        $this->configureRouting($this->routing);
        $uriResource = $this->routing->findResource($requestUri, $request->method());
        if ($this->switchToHttps($request, $uriResource)) {
            $response->redirect($uriResource->httpsUri());
            return $response;
        }

        try {
            if (!$uriResource->negotiateMimeType($request, $response)) {
                return $response;
            }

            $this->sessionHandshake($request, $response);
            if ($uriResource->applyPreInterceptors($request, $response)) {
                $response->write($uriResource->resolve($request, $response));
                $uriResource->applyPostInterceptors($request, $response);
            }
        } catch (\Exception $e) {
            $this->injector->getInstance(ExceptionLogger::class)->log($e);
            $response->write($response->internalServerError($e->getMessage()));
        }

        return $response;
    }
758550
public function run(): Response
    {
        try {
            $response = $this->dispatch();
            $this->send($response);
        } catch (\Error $e) {
            $response = $this->exceptionHandler->handleError($e);
            $this->send($response);
        } catch (\Exception $e) {
            $response = $this->exceptionHandler->handleException($e);
            $this->send($response);
        }

        return $response;
    }
355581
protected function run()
    {
        if (PHP_SAPI === 'cli') {
            return;
        }
        
        if ($this->ctrlRouterInfos->target === null) {
            return;
        }
        
        $this->module
            ->monolog
            ->getLogger()
            ->debug(
                'Execute current route.',
                ['target' => $this->ctrlRouterInfos->target]
            );
        
        $useClass = $this->config->getValue('useClass');
        
        if ($useClass === true) {
            $this->runObject();
        } else {
            $this->runProcedural();
        }
    }
167358
public function run() {

		if( isset( $this->model ) ) {

			$avatar = File::loadFile( $this->model->avatar, $this->fileName );

			if( $this->modelService->updateAvatar( $this->model, $avatar ) ) {

				$response = [ 'fileUrl' => $avatar->getFileUrl(), 'mediumUrl' => $avatar->getMediumUrl(), 'thumbUrl' => $avatar->getThumbUrl() ];

				// Trigger Ajax Success
				return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ), $response );
			}

			// Trigger Ajax Failure
			return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_REQUEST ) );
		}

		// Trigger Ajax Failure
		return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
	}
911094
public function run()
    {
        if ($this->layout !== null) {
            $this->controller->layout = $this->layout;
        }

        $this->app->getResponse()->setStatusCodeByException($this->getException());

        if ($this->app->getRequest()->getIsAjax()) {
            return $this->renderAjaxResponse();
        }

        return $this->renderHtmlResponse();
    }
1206674
public function run()
    {
        
        if (!empty($this->request)) {
            foreach ($this->request as $key => $value) {
                $this->_iterate($key, $value);
            }
        }
         
        return $this->getReport();
    }
1010014
protected function runRoute()
  {
    # Get Method and URI
    $httpMethod = $this->getRequest()->getMethod();
    $path = $this->getRequest()->getUri()->getPath();
    $routeInfo = null;
    $response = null;

    # Find route match in groups
    foreach ($this->getRouteGroups() as $routeGroup)
    {
      # Match the METHOD and URI to the routes in this group
      $routeInfo = $routeGroup->matchRoute($httpMethod,$path);

      if ( \count($routeInfo)>0 ) {
        # Debug log
        $this->getLogger()->debug('Route matched ',['path'=>$path,'handler'=>$routeInfo['handler']]);

        # Run Before Hooks
        // $ok = $this->runHooks('OnBeforeRequest');

        $beforeResult = true; // assume all before handlers succeed
        $routeResult = false;
        $afterResult = true; // assume all after handlers succeed

        #
        # Run the Common AND Groups Before Middlewares (ServerRequestInterface)
        #
        $beforeMiddleware = \array_merge($this->beforeMiddleware, $routeGroup->getBeforeMiddleware());

        foreach ($beforeMiddleware as $middleware)
        {
          if (\class_exists($middleware) ) {
            $beforeHandler = new $middleware($routeInfo['args']);

            # Debug log
            $this->getLogger()->debug('Initialize Before middleware',['rid'=>container('requestId'),'middleware'=>$middleware]);

            # Initialize
            $beforeHandler->initialize($routeInfo['args']);

            # Debug log
            $this->getLogger()->debug('Running Before middleware',['rid'=>container('requestId'),'middleware'=>$middleware]);

            if (!$beforeHandler->handle($routeInfo['args'])) {
              # Record outcome
              $beforeResult = false;

              # Stop processing more middleware
              break;
            }
          } else {
            # Log
            $this->getLogger()->warning('Before Middleware not found',['rid'=>container('requestId'),'middleware'=>$middleware]);
          }
        }

        #
        # Create & Run the Controller Class - If the Before Middlewares where ok!
        #
        if ($beforeResult) {
          # Extract class & method
          $arr = \explode('@',$routeInfo['handler']);
          $handlerClass = $arr[0];
          $handlerMethod = ($arr[1] ?? 'handle');

          # Check existance of handler class
          if (\class_exists($handlerClass))
          {
            # Create the class
            $routeHandler = new $handlerClass( $routeInfo['args'] );

            # Check method existance
            if ($routeHandler && \method_exists($routeHandler,'initialize') && \method_exists($routeHandler,$handlerMethod))
            {
              # Debug log
              $this->getLogger()->debug('Running controller->initialize()',[
                'rid' => \container('requestId'),
                'controller'=>$handlerClass
              ]);

              # Initialize
              $routeHandler->initialize($routeInfo['args']);

              # Debug log
              $this->getLogger()->debug('Running controller->handle()',[
                'rid' => \container('requestId'),
                'method'=>$handlerMethod
              ]);

              # Run Controller's method
              $response = $routeHandler->$handlerMethod($routeInfo['args']);

              # Set it
              if ($response)
                $this->setResponse($response);

            } else {
              # Log
              $this->getLogger()->error('Method not found in controller ',[
                'rid' => \container('requestId'),
                'controller'=>$handlerClass,
                'method'=>$handlerMethod
              ]);
            }

          } else {
            # Debug log
            $this->getLogger()->error('Controller not found ',[
              'rid' => \container('requestId'),
              'controller'=>$handlerClass
            ]);

            # Attempt to run the 404 error controller (if set by user in config)
            $this->runErrorController('',404);
          }
        }

        #
        # Run the After Middlewares (ServerRequestInterface)
        #
        $afterMiddleware = \array_merge($this->afterMiddleware,$routeGroup->getAfterMiddleware());
        foreach ($afterMiddleware as $middleware)
        {
          if (\class_exists($middleware) ) {
            $afterHandler = new $middleware($routeInfo['args']);

            # Debug log
            $this->getLogger()->debug('Initialize After middleware',[
              'rid' => \container('requestId'),
              'middleware'=>$middleware
            ]);

            # Initialize
            $afterHandler->initialize($routeInfo['args']);

            # Debug log
            $this->getLogger()->debug('Running After middleware',[
              'rid' => \container('requestId'),
              'middleware'=>$middleware
            ]);

            if (!$afterHandler->handle($routeInfo['args'])) {

              return false;
            }

          } else {
            # Log
            $this->getLogger()->warning('After Middleware not found',[
              'rid' => \container('requestId'),
              'middleware'=>$middleware
            ]);
          }
        }

        # Run After Hooks
        // $ok = $this->runHooks('OnAfterRequest');

        # Return the generated response
        return $this->getResponse();

      } // if count() ...

    } // foreach routeGroup

    ##
    ## No route matched the request ?!
    ##
    $this->getLogger()->notice('No route matched the request',[
      'method' => $this->getRequest()->getMethod(),
      'path' => $path,
      'ip' => \getClientIp(),
    ]);

    ##
    ## Try to load the "errors" controllers in the routes-{env}.json file
    ## and run the appropriate HTTP Code controller. If not found
    #W we will try to load the 4xx or 5xx generic controller (if defined)
    ##

    return $this->runErrorController('', 404);
  }
71387
public function execute()
    {
        Base::getLog()->debug(__METHOD__ . ' controller execute - start');

        if ( ! $this->break)
        {
            $this->executeBefore();
        }
        if ( ! $this->break)
        {
            $this->executeAction();
        }
        if ( ! $this->break)
        {
            $this->executeAfter();
        }

        Base::getLog()->debug(__METHOD__ . ' controller execute - end');
        return $this->response;
    }
838557
public function run()
    {
        $this->setMode();
        $this->checkBox();
        $this->checkCookie();
        $this->checkContent();
        $this->setDefaults();
        $this->initCookie();

        return $this->render(
                $this->mode == 'custom' 
                    ? $this->cookieView 
                    : 'box', 
                $this->prepareViewParams()
            );
    }
1150542
public function run()
    {
        $request = $this->getService('requestStack')->getMasterRequest();
        $this->getPreProcesses()->execute($request);
        $response = $this->getFrontController()->call($request);
        $this->getPostProcesses()->execute($response);
        $response->send();
    }
15217
public function run()
    {
        if ($this->driver === null || (is_array($this->driver) && !isset($this->driver['__class']))) {
            $this->driver['__class'] = GdDriver::class;
        }

        $this->driver = $this->app->ensureObject($this->driver, DriverInterface::class);

        if ($this->app->request->getQueryParam(self::REFRESH_GET_VAR) !== null) {
            // AJAX request for regenerating code
            $code = $this->getVerifyCode(true);
            $this->app->response->format = Response::FORMAT_JSON;
            return [
                'hash1' => $this->generateValidationHash($code),
                'hash2' => $this->generateValidationHash(strtolower($code)),
                // we add a random 'v' parameter so that FireFox can refresh the image
                // when src attribute of image tag is changed
                'url' => Url::to([$this->id, 'v' => uniqid()]),
            ];
        }

        $this->setHttpHeaders();
        $this->app->response->format = Response::FORMAT_RAW;

        return $this->driver->renderImage($this->getVerifyCode());
    }
687710
function run()
    {
        $request  = $this->getServerRequest();
        $response = $this->getResponse();
        $uri      = $request->getUri();
        $basepath = $uri->getBasePath();
        $args     = explode('/', htmlspecialchars($basepath));

        $response = $this->process($request, $response, $args);

        $this->finalize($request, $response, $args);
    }
1256489
public function run ()
	{
		$name = $this->controller_name;

		$this->controller = new $name($this->session, $this->log, $this->authcookie);

		$options = A([
			'action'      => $this->router->action,
			'type'        => $this->router->type,
			'base_uri'    => $this->config->base_uri,
			'params'      => $this->router->params,
			'environment' => $this->environment
			]);

		$result = $this->controller->call($options);

		$this->render($result);
	}