handle the request

@return Response
@throws HttpForbiddenException
500975
public function handler(): Response
    {
        $mailer = new Mailer([
            'driver' => 'smtp',
            'host' => 'host',
            'port' => 0,
            'encryption' => '',
            'username' => 'username',
            'password' => 'password',
            'sender' => 'sender',
            'remark' => ''
        ]);
        if (Mailer::count() === 0) {
            $mailer->default(true);
        }
        $mailer->save();
        $this->log('info', 'Create a mailer [' . $mailer->getSender() . ']');
        return response([
            'id' => $mailer->getId()
        ]);
    }
54318
public function handle()
    {
        $response = '';

        try {
            // Set running mode
            $this->app->instance('mode', 'web');

            // App boot
            $this->app->boot();

            // Prepare request
            $request = $this->prepareRequest();

            // Preparar rotas
            $response = $this->runRoute($request);

        } catch (\Exception $e) {
            $this->reportException($e);

            $response = Router::toResponse($request, $this->renderException($request, $e));
        }

        // Call terminate
        $this->terminate($request, $response);

        return $response;
    }
653743
public function handler(): Response
    {
        $bulletin = Bulletin::find($this->getParameter('id'));
        if (!$bulletin) {
            throw new HttpNotFoundException();
        }
        if (!$bulletin->isDraft()) {
            throw new HttpForbiddenException();
        }
        $data = $this->validate([
            'title' => [
                new NotBlank()
            ],
            'content' => [
                new NotBlank()
            ],
            'receivers' => []
        ]);
        $bulletin->update($data);
        $this->log('info', 'Update bulletin [' . $bulletin->getId() . ']');
        return response();
    }
766775
public function handler(): Response
    {
        $extension = Extension::findBy([
            'vendor' => $this->getParameter('vendor'),
            'package' => $this->getParameter('package')
        ]);
        if (!$extension) {
            throw new HttpForbiddenException();
        }
        if ($this->request->get('activation') === true) {
            $extension->activate();
            $this->log('info', 'Activate extension [' . $extension->getPackage() . ']');
        } else {
            $extension->deactivate();
            $this->log('info', 'Deactivate extension [' . $extension->getPackage() . ']');
        }
        return response();
    }
251762
public function handler(): Response
    {
        $data = $this->validate([
            'name' => [
                new NotBlank()
            ],
            'slug' => [
                new NotBlank()
            ],
            'icon' => [],
            'color' => []
        ]);
        $role = new Role($data);
        $role->save();
        $this->log('info', 'Create a role [' . $role->getSlug() . ']');
        return response([
            'id' => $role->getId()
        ]);
    }
14885
public function handler(): Response
    {
        $mailer = Mailer::find($this->getParameter('id'));
        if (!$mailer) {
            throw new HttpForbiddenException();
        }
        foreach (Mailer::all() as $m) {
            $m->default(false)->save();
        }
        $mailer->default(true)->save();
        $this->log('info', 'Set mailer [' . $mailer->getSender() . '] as default');
        return response();
    }
556083
public function execute()
    {
        $this->setOptions();

        $response = $this->parseResponse($this->curlExecute());

        $this->close();

        return $response;
    }
246236
protected function _handle()
    {
        $request = $this->_request();
        $this->_configIndex($this->_table(), $request);
        $query = $this->_table()->find();
        $repository = $query->repository();

        $query->searchOptions(['ignore_unavailable' => true]);

        if ($request->query('type')) {
            $repository->name($request->query('type'));
        }

        if ($request->query('primary_key')) {
            $query->where(['primary_key' => $request->query('primary_key')]);
        }

        if ($request->query('transaction')) {
            $query->where(['transaction' => $request->query('transaction')]);
        }

        if ($request->query('user')) {
            $query->where(['meta.user' => $request->query('user')]);
        }

        if ($request->query('changed_fields')) {
            $query->where(function ($builder) use ($request) {
                $fields = explode(',', $request->query('changed_fields'));
                $fields = array_map(function ($f) { return 'changed.' . $f; }, array_map('trim', $fields));
                $fields = array_map([$builder, 'exists'], $fields);
                return $builder->and_($fields);
            });
        }

        if ($request->query('query')) {
            $query->where(function ($builder) use ($request) {
                return $builder->query(new \Elastica\Query\QueryString($request->query('query')));
            });
        }

        try {
            $this->addTimeConstraints($request, $query);
        } catch (\Exception $e) {
        }

        $subject = $this->_subject(['success' => true, 'query' => $query]);
        $this->_trigger('beforePaginate', $subject);

        $items = $this->_controller()->paginate($subject->query);
        $subject->set(['entities' => $items]);

        $this->_trigger('afterPaginate', $subject);
        $this->_trigger('beforeRender', $subject);
    }
555118
public function handleOptionsRequest()
    {
        // Generate the "Allow" header
        $allow = '';
        foreach ($this->router->getMethodsByRoute($this->uri) as $method) {
            $allow .= strtoupper($method) . ',';
        }
        $allow = substr($allow, 0, strlen($allow) - 1);
        header('Allow: ' . $allow);
        $this->setResponse('');
    }
289936
public function handler(): Response
    {
        $response = [];
        foreach (Permission::all() as $permission) {
            $response[] = [
                'id' => $permission->getId(),
                'permission' => $permission->getPermission(),
                'role' => [
                    'id' => $permission->getRole()->getId(),
                    'name' => $permission->getRole()->getName(),
                    'slug' => $permission->getRole()->getSlug()
                ]
            ];
        }
        return response($response);
    }
875893
public function handle()
    {
        $scaffoldApi = $this->option('api');
        $webExecution = $this->option('webExecution');

        try
        {
            // Get all the models
            $modelFiles = File::allFiles(base_path('scaffolder-config/models/'));

            // Get app config
            $scaffolderConfig = Json::decodeFile(base_path('scaffolder-config/app.json'));

            $apiDirectory = strtolower(str_replace(' ', '-', $scaffolderConfig->name . '-api'));

            // Compilers
            $modelCompiler = new ModelCompiler();
            $apiModelCompiler = new ApiModelCompiler();
            $migrationCompiler = new MigrationCompiler();
            $controllerCompiler = new ControllerCompiler();
            $apiControllerCompiler = new ApiControllerCompiler();
            $indexViewCompiler = new IndexViewCompiler();
            $createViewCompiler = new CreateViewCompiler();
            $editViewCompiler = new EditViewCompiler();
            $dashboardViewCompiler = new DashboardViewCompiler();
            $welcomeViewCompiler = new WelcomeViewCompiler();
            $loginViewCompiler = new LoginViewCompiler();
            $pageLayoutViewCompiler = new PageLayoutCompiler();
            $createLayoutCompiler = new CreateLayoutCompiler();
            $editLayoutCompiler = new EditLayoutCompiler();
            $routeCompiler = new RouteCompiler();
            $apiRouteCompiler = new ApiRouteCompiler();

            // Compiler output
            $modelCompilerOutput = [];
            $apiModelCompilerOutput = [];
            $controllerCompilerOutput = [];
            $apiControllerCompilerOutput = [];
            $viewCompilerOutput = [];
            $migrationCompilerOutput = [];

            // Sidenav links
            $sidenavLinks = [];

            // Compiled routes
            $compiledRoutes = '';
            $compiledApiRoutes = '';

            // Get stubs
            $modelStub = File::get($this->stubsDirectory . 'Model.php');
            $apiModelStub = File::get($this->stubsDirectory . 'api/Model.php');
            $migrationStub = File::get($this->stubsDirectory . 'Migration.php');
            $controllerStub = File::get($this->stubsDirectory . 'Controller.php');
            $apiControllerStub = File::get($this->stubsDirectory . 'api/Controller.php');
            $indexViewStub = File::get($this->themeViews->getIndexPath());
            $createViewStub = File::get($this->themeViews->getCreatePath());
            $editViewStub = File::get($this->themeViews->getEditPath());
            $routeStub = File::get($this->stubsDirectory . 'ResourceRoute.php');
            $apiRouteStub = File::get($this->stubsDirectory . 'api/ResourceRoute.php');

            // Create models directory
            Directory::createIfNotExists(app_path('Models'));

            // Initialize API
            if ($scaffoldApi)
            {
                if (!(new \FilesystemIterator(base_path('../' . $apiDirectory)))->valid())
                {
                    $this->writeStatus('Initializing API ...', $webExecution);

                    $this->call('scaffolder:api-initialize', [
                        'name' => $scaffolderConfig->name,
                        'domain' => $scaffolderConfig->api->domain,
                        '--webExecution' => $webExecution
                    ]);

                    $this->output->newLine();
                }
                else
                {
                    $this->writeStatus('API already initialized', $webExecution);
                }

                // Create models directory
                Directory::createIfNotExists(base_path('../' . $apiDirectory . '/app/Models'));
            }

            $this->writeStatus('Compiling ...', $webExecution);
            $this->output->newLine();

            // Start progress bar
            $this->output->progressStart(count($modelFiles));

            // Iterate over model files
            foreach ($modelFiles as $modelFile)
            {
                // Get model name
                $modelName = ucwords($modelFile->getBasename('.' . $modelFile->getExtension()));

                // Get model data
                $modelData = Json::decodeFile($modelFile->getRealPath());

                // Create views directory
                Directory::createIfNotExists(base_path('resources/views/' . strtolower($modelName)));

                $modelHash = md5_file($modelFile->getRealPath());

                // Compile stubs
                array_push($modelCompilerOutput, $modelCompiler->compile($modelStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->extensions));
                if ($scaffoldApi) array_push($apiModelCompilerOutput, $apiModelCompiler->compile($apiModelStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->extensions));
                array_push($controllerCompilerOutput, $controllerCompiler->compile($controllerStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->extensions));
                if ($scaffoldApi) array_push($apiControllerCompilerOutput, $apiControllerCompiler->compile($apiControllerStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->extensions));
                array_push($migrationCompilerOutput, $migrationCompiler->compile($migrationStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->extensions));
                array_push($viewCompilerOutput, $indexViewCompiler->compile($indexViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->themeExtension, $this->extensions));
                array_push($viewCompilerOutput, $createViewCompiler->compile($createViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->themeExtension, $this->extensions));
                array_push($viewCompilerOutput, $editViewCompiler->compile($editViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->themeExtension, $this->extensions));
                $compiledRoutes .= $routeCompiler->compile($routeStub, $modelName, $modelData, $scaffolderConfig, null, $this->extensions);
                if ($scaffoldApi) $compiledApiRoutes .= $apiRouteCompiler->compile($apiRouteStub, $modelName, $modelData, $scaffolderConfig, null, $this->extensions);

                // Add entity link
                array_push($sidenavLinks, ['modelName' => $modelName, 'modelLabel' => $modelData->modelLabel]);

                // Advance progress
                $this->output->progressAdvance();
            }

            // Finish progress
            $this->output->progressFinish();

            // Store compiled routes
            $routeCompiler->compileGroup(File::get($this->stubsDirectory . 'Routes.php'), $compiledRoutes, $scaffolderConfig);
            if ($scaffoldApi) $apiRouteCompiler->compileGroup(File::get($this->stubsDirectory . 'api/Routes.php'), $compiledApiRoutes, $scaffolderConfig);

            // Create layouts directory
            Directory::createIfNotExists(base_path('resources/views/layouts'));

            // Compile page layout
            array_push($viewCompilerOutput, $pageLayoutViewCompiler->compile(File::get($this->themeLayouts->getPagePath()), null, null, $scaffolderConfig, null, $this->themeExtension, $this->extensions, ['links' => $sidenavLinks]));

            // Compile create layout
            array_push($viewCompilerOutput, $createLayoutCompiler->compile(File::get($this->themeLayouts->getCreatePath()), null, null, $scaffolderConfig, null, $this->themeExtension, $this->extensions));

            // Compile edit layout
            array_push($viewCompilerOutput, $editLayoutCompiler->compile(File::get($this->themeLayouts->getEditPath()), null, null, $scaffolderConfig, null, $this->themeExtension, $this->extensions));

            // Compile dashboard view
            array_push($viewCompilerOutput, $dashboardViewCompiler->compile(File::get($this->themeViews->getDashboardPath()), null, null, $scaffolderConfig, null, $this->themeExtension, $this->extensions));

            // Compile welcome view
            array_push($viewCompilerOutput, $welcomeViewCompiler->compile(File::get($this->themeViews->getWelcomePath()), null, null, $scaffolderConfig, null, $this->themeExtension, $this->extensions));

            // Compile login view
            array_push($viewCompilerOutput, $loginViewCompiler->compile(File::get($this->themeViews->getLoginPath()), null, null, $scaffolderConfig, null, $this->themeExtension, $this->extensions));

            // Summary
            $this->comment('- Files created');

            $this->comment('- - Views');
            foreach ($viewCompilerOutput as $viewFile)
            {
                $this->info('- - - ' . $viewFile);
            }

            $this->comment('- - Controllers');
            foreach ($controllerCompilerOutput as $controllerFile)
            {
                $this->info('- - - ' . $controllerFile);
            }

            $this->comment('- - Migrations');
            foreach ($migrationCompilerOutput as $migrationFile)
            {
                $this->info('- - - ' . $migrationFile);
            }

            $this->comment('- - Models');
            foreach ($modelCompilerOutput as $modelFile)
            {
                $this->info('- - - ' . $modelFile);
            }

            if ($scaffoldApi)
            {
                $this->comment('- - API Controllers');
                foreach ($apiControllerCompilerOutput as $apiControllerFile)
                {
                    $this->info('- - - ' . $apiControllerFile);
                }

                $this->comment('- - API Models');
                foreach ($apiModelCompilerOutput as $apiModelFile)
                {
                    $this->info('- - - ' . $apiModelFile);
                }
            }

            $this->writeStatus('Done', $webExecution);
        }
        catch (\Exception $exception)
        {
            $this->writeStatus('Error', $webExecution);
            Log::error($exception->getMessage());
        }
    }
1111036
protected function handleHead() : HttpResponse
    {
        $key = $this->request->key();

        if ( ! $fileMeta = $this->cache->get($key)) {
            return $this->response->send(null, HttpResponse::HTTP_NOT_FOUND);
        }

        $offset = $fileMeta['offset'] ?? false;

        if (false === $offset) {
            return $this->response->send(null, HttpResponse::HTTP_GONE);
        }

        return $this->response->send(null, HttpResponse::HTTP_OK, $this->getHeadersForHeadRequest($fileMeta));
    }
915664
public function run()
	{
		if ( $this->description )
			touch( $this->mutexPath() );

		try
		{
			UniversalBuilder::call( $this->callback, $this->parameters )
		}
		finally
		{
			$this->removeMutex();
		}

		parent::callAfterCallbacks();

		return $response;
	}
806492
public function handleRequest()
    {
        // Create the request very early so the Resource Management has a chance to grab it:
        $this->request = Request::createFromEnvironment();
        $this->response = new Response();

        $this->checkBasicRequirementsAndDisplayLoadingScreen();

        $this->boot();
        $this->resolveDependencies();
        if (isset($this->settings['http']['baseUri'])) {
            $this->request->setBaseUri(new Uri($this->settings['http']['baseUri']));
        }

        $componentContext = new ComponentContext($this->request, $this->response);
        $this->baseComponentChain->handle($componentContext);

        $this->baseComponentChain->getResponse()->send();

        $this->bootstrap->shutdown('Runtime');
        $this->exit->__invoke();
    }
229371
public function handleRequest()
    {
        try {
            $rtn = parent::handleRequest();

            if (extension_loaded('newrelic')) {
                $site = $this->toPhpName($this->config->get('site.name'));
                $controller = $this->toPhpName($this->route['controller']);
                $action = $this->toPhpName($this->route['action']);

                newrelic_name_transaction($site . '.' . $controller . '.' . $action);
            }
        } catch (HttpException\NotFoundException $ex) {
            $rtn = $this->handleHttpError($ex->getErrorCode());
        } catch (HttpException $ex) {
            if ((defined('CMS_ENV') && CMS_ENV == 'development') || array_key_exists('ex', $_GET)) {
                throw $ex;
            }

            $rtn = $this->handleHttpError($ex->getErrorCode());
        } catch (Exception $ex) {
            if ((defined('CMS_ENV') && CMS_ENV == 'development') || array_key_exists('ex', $_GET)) {
                throw $ex;
            }

            $rtn = $this->handleHttpError(500);
        }

        return $rtn;
    }
1176734
public function handle()
    {
        URL::forceRootUrl(config('app.url'));
        $usingDingoRouter = strtolower(config('apidoc.router')) == 'dingo';
        if ($usingDingoRouter) {
            $routes = $this->routeMatcher->getDingoRoutesToBeDocumented(config('apidoc.routes'));
        } else {
            $routes = $this->routeMatcher->getLaravelRoutesToBeDocumented(config('apidoc.routes'));
        }

        $generator = new Generator(config('apidoc.faker_seed'));
        $parsedRoutes = $this->processRoutes($generator, $routes);
        $parsedRoutes = collect($parsedRoutes)->groupBy('group')
            ->sortBy(static function ($group) {
                /* @var $group Collection */
                return $group->first()['group'];
            }, SORT_NATURAL);

        $this->writeMarkdown($parsedRoutes);
    }
275979
public function handle()
    {
        // get information about the REST-request
        $this->get();

        if ($this->requestMethod === 'GET' && $this->typo3Cache->hasCacheEntry($this->url, $_GET)) {
            return $this->handleRequestByTypo3Cache();
        }

        // if no cache exist: restler should handle the request
        if (Defaults::$useVendorMIMEVersioning) {
            $this->responseFormat = $this->negotiateResponseFormat();
        }
        $this->route();
        $this->negotiate();
        $this->preAuthFilter();
        $this->authenticate();
        $this->postAuthFilter();
        $this->validate();
        $this->preCall();
        $this->call();
        $this->compose();
        $this->postCall();

        if ($this->responseFormat instanceof JsonFormat) {
            // return stdClass-object (instead of an array)
            return $this->getRestApiJsonFormat()->decode($this->responseData);
        }
        return $this->responseFormat->decode($this->responseData);
    }