handle the request

@return Response
@throws HttpForbiddenException
518996
public function handler(): Response
    {
        $memberData = $this->validate([
            'email' => [
                new NotBlank(),
                new Email()
            ]
        ]);
        $data = $this->validate([
            'password' => [
                new NotBlank()
            ],
            'passwordConfirmation' => [
                new NotBlank()
            ],
            'passwordOrigin' => [
                new NotBlank()
            ]
        ]);
        if (!preg_match('/[a-zA-Z]/', $data['passwordOrigin'])
            || !preg_match('/[0-9]/', $data['passwordOrigin'])
            || !preg_match('/[^a-zA-Z0-9]/', $data['passwordOrigin'])
            || strlen($data['passwordOrigin']) < 8) {
            throw new HttpForbiddenException('密码太弱，需至少8位并且包含字母数字以及字符');
        }
        if (sha1($data['passwordOrigin']) !== $data['password']
            || $data['password'] !== $data['passwordConfirmation']) {
            throw new HttpForbiddenException('两次输入的密码不一样');
        }
        $token = PasswordResetToken::find($this->getParameter('token'));
        $member = Member::findBy($memberData);
        if (!$token || !$token->isValid() || !$member || $token->getMember()->getId() !== $member->getId()) {
            throw new HttpForbiddenException();
        }
        $token->delete();
        $member->password($data['password'])
            ->save();
        $this->auth(null);
        $this->log('info', '[' . $memberData['email'] . '] reset password');
        return response();
    }
628821
public function execute()
    {
        if (empty($this->webhookUrl)) {
            $this->phpci->logFailure('You must specify a webhook URL.');
            return false;
        }

        $http = new HttpClient();

        $response = $http->post($this->webhookUrl, array(
            'reason' => $this->phpci->interpolate($this->reason),
            'source' => 'PHPCI',
            'url' => $this->phpci->interpolate('%BUILD_URI%'),
            'branch' => $this->phpci->interpolate('%BRANCH%'),
            'commit' =>  $this->phpci->interpolate('%COMMIT%'),
            'update_only' => $this->updateOnly,
        ));

        return $response['success'];
    }
1295084
private function handle(){
        $params = [
            "start"     => null,
            "finish"    => null,
            "response"  => null,
            "error"     => null,
        ];

        try{
            $params["start"]    = microtime(true);
            $params["response"] = $this->handler->handle($this->request);
        }catch(\Throwable $e){
            $params["error"]    = $e;
            $this->error        = $e;
        }finally{
            $params["finish"]   = microtime(true);
        }

        $this->event(new Event("response.handle.after", $params));

        return $params["response"];
    }
298863
public function handler(): Response
    {
        $extension = Extension::findBy([
            'vendor' => $this->getParameter('vendor'),
            'package' => $this->getParameter('package')
        ]);
        if (!$extension) {
            throw new HttpForbiddenException();
        }
        $extension->uninstall();
        $this->log('info', 'Uninstall 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()
        ]);
    }
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);
    }
1290083
protected function _handle()
    {
        $ids = $this->_processIds();
        $subject = $this->_constructSubject($ids);

        $event = $this->_trigger('beforeBulk', $subject);
        if ($event->isStopped()) {
            return $this->_stopped($subject);
        }

        if ($this->_bulk($subject->query)) {
            $this->_success($subject);
        } else {
            $this->_error($subject);
        }

        return $this->_redirect($subject, ['action' => 'index']);
    }
1209579
public function send(): HttpResponse {
        $ch = $this->createCurl();
        $response = $this->execCurl($ch);
        curl_close($ch);

        return $response;
    }
1033775
public static function handleCurrentRequest() {
		try {
			HTTPRoute::initialize();
			static::$mainRequest = static::generateFromEnvironment();
			$response = static::$mainRequest->process();
		} catch( \Exception $e ) {
			$response = HTMLHTTPResponse::generateFromException($e);
		}
		$response->process();
		die();
	}
416082
protected function handlePatch() : HttpResponse
    {
        $uploadKey = $this->request->key();

        if ( ! $meta = $this->cache->get($uploadKey)) {
            return $this->response->send(null, HttpResponse::HTTP_GONE);
        }

        $status = $this->verifyPatchRequest($meta);

        if (HttpResponse::HTTP_OK !== $status) {
            return $this->response->send(null, $status);
        }

        $file     = $this->buildFile($meta);
        $checksum = $meta['checksum'];

        try {
            $fileSize = $file->getFileSize();
            $offset   = $file->setKey($uploadKey)->setChecksum($checksum)->upload($fileSize);

            // If upload is done, verify checksum.
            if ($offset === $fileSize) {
                if ( ! $this->verifyChecksum($checksum, $meta['file_path'])) {
                    return $this->response->send(null, self::HTTP_CHECKSUM_MISMATCH);
                }

                $this->event()->dispatch(
                    UploadComplete::NAME,
                    new UploadComplete($file, $this->getRequest(), $this->getResponse())
                );
            } else {
                $this->event()->dispatch(
                    UploadProgress::NAME,
                    new UploadProgress($file, $this->getRequest(), $this->getResponse())
                );
            }
        } catch (FileException $e) {
            return $this->response->send($e->getMessage(), HttpResponse::HTTP_UNPROCESSABLE_ENTITY);
        } catch (OutOfRangeException $e) {
            return $this->response->send(null, HttpResponse::HTTP_REQUESTED_RANGE_NOT_SATISFIABLE);
        } catch (ConnectionException $e) {
            return $this->response->send(null, HttpResponse::HTTP_CONTINUE);
        }

        return $this->response->send(null, HttpResponse::HTTP_NO_CONTENT, [
            'Content-Type' => self::HEADER_CONTENT_TYPE,
            'Upload-Expires' => $this->cache->get($uploadKey)['expires_at'],
            'Upload-Offset' => $offset,
        ]);
    }
1209042
public function handler(): Response
    {
        $data = $this->validate([
            'remark' => [],
            'driver' => [],
            'host' => [],
            'port' => [],
            'encryption' => [],
            'username' => [],
            'password' => [],
            'sender' => [
                new Email()
            ]
        ]);
        $mailer = Mailer::find($this->getParameter('id'));
        if (!$mailer) {
            throw new HttpForbiddenException();
        }
        $mailer->update($data);
        $this->log('info', 'Update mailer [' . $mailer->getSender() . ']');
        return response();
    }
49238
public function handler(): Response
    {
        $role = Role::find($this->getParameter('id'));
        if (!$role) {
            throw new HttpForbiddenException();
        }
        $this->log('info', 'Delete role [' . $role->getSlug() . ']');
        $role->delete(true);
        return response();
    }
591619
public function handle()
    {
        $input = $this->getCommandInput();

        $resources = Resource::fromFile($input->resourceFile, $input->langFile);

        $destenationFile = $this->getDestenationFile($input->controllerName, $input->controllerDirectory);

        if ($this->hasErrors($resources, $destenationFile)) {
            return false;
        }

        $requestName = 'Request';
        $requestNameSpace = 'Illuminate\Http\Request';

        if ($input->withFormRequest) {
            $requestName = $input->formRequestName;
            $requestNameSpace = $this->getRequestsNamespace($requestName, $input->formRequestDirectory);

            if (!$this->option('without-form-request')) {
                $this->makeFormRequest($input);
            }
        }

        $fields = $resources->fields;
        $viewVariablesForIndex = $this->getCompactVariablesFor($fields, $this->getPluralVariable($input->modelName), 'index');
        $viewVariablesForShow = $this->getCompactVariablesFor($fields, $this->getSingularVariable($input->modelName), 'show');
        $viewVariablesForEdit = $this->getCompactVariablesFor($fields, $this->getSingularVariable($input->modelName), 'form');
        $modelNamespace = $this->getModelNamespace($input->modelName, $input->modelDirectory);
        $affirmMethod = $this->getAffirmMethod($input->withFormRequest, $fields, $requestNameSpace, $input);
        $classToExtendFullname = $this->getFullClassToExtend($input->extends);
        $namespacesToUse = $this->getRequiredUseClasses($fields, [$modelNamespace, $requestNameSpace, $classToExtendFullname]);
        $dataMethod = $this->getDataMethod($fields, $requestNameSpace . '\\' . $requestName, $input);
        $stub = $this->getStubContent('controller');
        $languages = array_keys(Helpers::getLanguageItems($fields));
        $viewLabels = new ViewLabelsGenerator($input->modelName, $fields, $this->isCollectiveTemplate());
        $standardLabels = $viewLabels->getLabels();

        return $this->replaceViewNames($stub, $input->viewDirectory, $input->prefix)
            ->replaceGetDataMethod($stub, $dataMethod)
            ->replaceCallDataMethod($stub, $this->getCallDataMethod($input->withFormRequest))
            ->replaceModelName($stub, $input->modelName)
            ->replaceNamespace($stub, $this->getControllersNamespace($input->controllerDirectory))
            ->replaceControllerExtends($stub, $this->getControllerExtends($classToExtendFullname))
            ->replaceUseCommandPlaceholder($stub, $namespacesToUse)
            ->replaceRouteNames($stub, $this->getModelName($input->modelName), $input->prefix)
            ->replaceConstructor($stub, $this->getConstructor($input->withAuth))
            ->replaceCallAffirm($stub, $this->getCallAffirm($input->withFormRequest))
            ->replaceAffirmMethod($stub, $affirmMethod)
            ->replacePaginationNumber($stub, $input->perPage)
            ->replaceFileMethod($stub, $this->getUploadFileMethod($fields, $input->withFormRequest))
            ->replaceViewVariablesForIndex($stub, $viewVariablesForIndex)
            ->replaceViewVariablesForShow($stub, $viewVariablesForShow)
            ->replaceViewVariablesForCreate($stub, $this->getCompactVariablesFor($fields, null, 'form'))
            ->replaceViewVariablesForEdit($stub, $viewVariablesForEdit)
            ->replaceWithRelationsForIndex($stub, $this->getWithRelationFor($fields, 'index'))
            ->replaceWithRelationsForShow($stub, $this->getWithRelationFor($fields, 'show'))
            ->replaceRelationCollections($stub, $this->getRequiredRelationCollections($fields))
            ->replaceOnStoreAction($stub, $this->getOnStoreAction($fields))
            ->replaceOnUpdateAction($stub, $this->getOnUpdateAction($fields))
            ->replaceAppName($stub, Helpers::getAppName())
            ->replaceControllerName($stub, $input->controllerName)
            ->replaceDataVariable($stub, 'data')
            ->replaceRequestName($stub, $requestName)
            ->replaceRequestFullName($stub, $requestNameSpace)
            ->replaceRequestVariable($stub, $this->requestVariable)
            ->replaceTypeHintedRequestName($stub, $this->getTypeHintedRequestName($requestName))
            ->replaceStandardLabels($stub, $standardLabels)
            ->createFile($destenationFile, $stub)
            ->info('A controller was crafted successfully.');
    }
268098
public function handle()
    {
        if (file_exists($publicPath = public_path('assets'))) {
            return $this->error('The "webroot/assets" directory already exists.');
        }

        $assetsPath = $this->container['config']->get('routing.assets.path', base_path('assets'));

        $this->container->make('files')->link(
            $assetsPath, $publicPath
        );

        $this->info('The [webroot/assets] directory has been linked.');
    }
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;
    }
1264366
public static function handleRequest()
    {
        // save static class
        static::$calledClass = get_called_class();

        // handle JSON requests
        if (static::peekPath() == 'json') {
            // check access for API response modes
            static::$responseMode = static::shiftPath();
            if (in_array(static::$responseMode, ['json','jsonp'])) {
                if (!static::checkAPIAccess()) {
                    return static::throwAPIUnAuthorizedError();
                }
            }
        }

        return static::handleRecordsRequest();
    }