handle the request

@return Response
@throws HttpForbiddenException
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();
    }
1357350
public function handle()
    {
        if (parent::handle() === false) return false;

        $this->createTest();
        if (!$this->option('api')) $this->generateView();
        $this->generateTranslation();
        $this->appendRouteFile();

        return null;
    }
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'];
    }
64564
public function handle()
    {
        $id = $this->argument('id');

        try {
            $user = $this->prepareUser($id);
        } catch (Exception $e) {
            $this->warn($e->getMessage());
            return 1;
        }

        $attachList = array_merge($this->option('id'), $this->option('name'));

        if (! method_exists($user, 'attachPermission')) {
            $this->warn("User not use HasPermissionsTrait!");
            return 1;
        }

        $user->attachPermission($attachList);
        echo "Attached permissions. Done!", PHP_EOL;

        return 0;
    }
798572
public function handle()
    {
        $id = $this->getAttribute('id');
        Event::fire('antares.ready: menu.before.' . $id);
        Event::fire(new BeforeMenu($id, $this));


        if (!$this->passesAuthorization()) {
            return;
        }
        $args = func_get_args();


        if (isset($args[0]) && ($args[0] instanceof AfterMenu || $args[0] instanceof Handler)) {
            $menu = $args[0] instanceof AfterMenu ? $args[0]->menu : $args[0];

            $menu->add($this->getAttribute('id'))
                    ->link($this->getAttribute('link'))
                    ->title($this->getAttribute('title'))
                    ->icon($this->getAttribute('icon'))
                    ->type($this->getAttribute('type'))
                    ->active($this->getAttribute('active'));
        } else {
            $menu = $this->createMenu();
            if ($menu) {
                $this->attachIcon($menu);
            }
        }

        Event::fire('antares.ready: menu.after.' . $id);
        Event::fire(new AfterMenu($id, $this));
    }
1201662
public function handle()
    {
        try {
            $query = $this->di->request->getRoute();
            $parts = $this->di->request->getRouteParts();

            // Match predefined routes
            foreach ($this->routes as $route) {
                if ($route->match($query)) {
                    return $route->handle();
                }
            }

            // Default handling route as :controller/:action/:params using the dispatcher
            $dispatcher = $this->di->dispatcher;
            $dispatcher->setControllerName(isset($parts[0]) ? $parts[0] : 'index');

            if ($dispatcher->isValidController()) {
                $dispatcher->setActionName(isset($parts[1]) ? $parts[1] : 'index');

                $params = [];
                if (isset($parts[2])) {
                    $params = $parts;
                    array_shift($params);
                    array_shift($params);
                }
                $dispatcher->setParams($params);

                if ($dispatcher->isCallable()) {
                    return $dispatcher->dispatch();
                }
            }

            // Use the "catch-all" route
            if ($this->defaultRoute) {
                return $this->defaultRoute->handle();
            }

            // No route was matched
            $this->handleInternal('404');
        } catch (\Exception $e) {
            // Exception codes can match a route for a http status code
            $code = $e->getCode();
            $statusCodes = [403, 404, 500];
            if (in_array($code, $statusCodes)) {
                $this->di->flash->setMessage($e->getMessage());
                $this->handleInternal($code);
            } else {
                throw $e;
            }
        }
    }
469672
public function handler(): Response
    {
        $response = [];
        foreach (Extension::all(['createdAt' => 'ASC']) as $extension) {
            $response[] = [
                'vendor' => $extension->getVendor(),
                'package' => $extension->getPackage(),
                'version' => $extension->getVersion(),
                'description' => $extension->getDescription(),
                'isActivated' => $extension->isActivated()
            ];
        }
        return response($response);
    }
407083
public function handler(): Response
    {
        $bulletin = Bulletin::find($this->getParameter('id'));
        if (!$bulletin) {
            throw new HttpNotFoundException();
        }
        $response = [];
        foreach ($bulletin->getFeedbacks() as $feedback) {
            $response[] = [
                'id' => $feedback->getId(),
                'updatedAt' => $feedback->getUpdatedAt() ? $feedback->getUpdatedAt()->getTimestamp() : null,
                'receiver' => [
                    'id' => $feedback->getReceiver()->getId(),
                    'username' => $feedback->getReceiver()->getUsername(),
                    'name' => $feedback->getReceiver()->getName()
                ],
                'checked' => $feedback->isChecked(),
                'remark' => $feedback->getRemark()
            ];
        }
        return response($response);
    }
220515
public function handler(): Response
    {
        $member = Member::search($this->getParameter('username'));
        if (!$member) {
            throw new HttpNotFoundException();
        }
        $r = $member->getRole();
        return response([
            'id' => $member->getId(),
            'username' => $member->getUsername(),
            'email' => $member->getEmail(),
            'phone' => $member->getPhone(),
            'name' => $member->getName(),
            'gender' => $member->getGender(),
            'role' => [
                'name' => $r->getName(),
                'color' => $r->getColor(),
                'icon' => $r->getIcon(),
                'slug' => $r->getSlug()
            ]
        ]);
    }
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();
	}
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);
    }
88516
public function send()
    {
        try {
            $response = $this->guzzleClient->request($this->method, $this->uri, $this->options);
        } catch (ClientException $e) {
            $this->handleApiException($e->getResponse()->getBody()->getContents());
        }

        return $this->getBody($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();
    }
274632
public function handler(): Response
    {
        $bulletin = Bulletin::find($this->getParameter('id'));
        if (!$bulletin) {
            throw new HttpNotFoundException();
        }
        if ($bulletin->isDraft()) {
            $bulletin->publish();
            $this->log('info', 'Publish a bulletin [' . $bulletin->getId() . ']');
        } else {
            throw new HttpForbiddenException();
        }
        return response();
    }
1361348
protected function handlePost() : HttpResponse
    {
        $fileName   = $this->getRequest()->extractFileName();
        $uploadType = self::UPLOAD_TYPE_NORMAL;

        if (empty($fileName)) {
            return $this->response->send(null, HttpResponse::HTTP_BAD_REQUEST);
        }

        if ( ! $this->verifyUploadSize()) {
            return $this->response->send(null, HttpResponse::HTTP_REQUEST_ENTITY_TOO_LARGE);
        }

        $uploadKey = $this->getUploadKey();
        $filePath  = $this->uploadDir . DIRECTORY_SEPARATOR . $fileName;

        if ($this->getRequest()->isFinal()) {
            return $this->handleConcatenation($fileName, $filePath);
        }

        if ($this->getRequest()->isPartial()) {
            $filePath   = $this->getPathForPartialUpload($uploadKey) . $fileName;
            $uploadType = self::UPLOAD_TYPE_PARTIAL;
        }

        $checksum = $this->getClientChecksum();
        $location = $this->getRequest()->url() . $this->getApiPath() . '/' . $uploadKey;

        $file = $this->buildFile([
            'name' => $fileName,
            'offset' => 0,
            'size' => $this->getRequest()->header('Upload-Length'),
            'file_path' => $filePath,
            'location' => $location,
        ])->setKey($uploadKey)->setChecksum($checksum);

        $this->cache->set($uploadKey, $file->details() + ['upload_type' => $uploadType]);

        $this->event()->dispatch(
            UploadCreated::NAME,
            new UploadCreated($file, $this->getRequest(), $this->getResponse())
        );

        return $this->response->send(
            null,
            HttpResponse::HTTP_CREATED,
            [
                'Location' => $location,
                'Upload-Expires' => $this->cache->get($uploadKey)['expires_at'],
            ]
        );
    }
913786
public function handler(): Response
    {
        $data = $this->validate([
            'accept' => [
                new Choice(['choices' => [true, false, 0, 1]])
            ],
            'remark' => []
        ]);
        $feedback = BulletinFeedback::find($this->getParameter('id'));
        if (!$feedback) {
            throw new HttpNotFoundException();
        }
        if ($feedback->isChecked() !== null) {
            throw new HttpForbiddenException();
        }
        $feedback->checked(!!$data['accept']);
        $feedback->remark($data['remark']);
        $feedback->save();
        $this->log('info', '[' . $feedback->getReceiver()->getUsername() . '] has feedback for bulletin [' . $feedback->getBulletin()->getId() . ']');
        return response();
    }
1222191
public static function handleRequest() {
        $response = get_response();
        try {
            $routes = self::$routes->getRoutes();
            if (!empty($routes)) {
                $beforeRoutes = self::$beforeRoutes->getRoutes();
                if (!empty($beforeRoutes)) {
                    foreach ($beforeRoutes as $beforeRoute) {
                        self::executeAction($beforeRoute->getAction(), array_merge($_REQUEST, $beforeRoute->getParameters()));
                    }
                }

                try {
                    foreach ($routes as $route) {
                        $routeResult = self::executeAction($route->getAction(), array_merge($_REQUEST, $route->getParameters()));
                        if (isset($routeResult)) {
                            $response->content($routeResult);
                        }
                    }
                    $afterRoutes = self::$afterRoutes->getRoutes();
                    if (!empty($afterRoutes)) {
                        foreach ($afterRoutes as $afterRoute) {
                            $routeResult = self::executeAction($afterRoute->getAction(), array_merge($_REQUEST, $afterRoute->getParameters()));
                            if (isset($routeResult)) {
                                $response->content($routeResult);
                            }
                        }
                    }
                    $response->send();
                }
                catch (ActionNotFoundException $notFoundException) {
                    self::handleRequestNotFound();
                }
            }
            else {
                self::handleRequestNotFound();
            }
        }
        catch (Throwable $ex) {
            self::handleRequestException($ex);
        }
    }