Inheritance: extends PhalconApi\Api
 public function beforeExecuteRoute(Event $event, Api $api)
 {
     $collection = $api->getMatchedCollection();
     $endpoint = $api->getMatchedEndpoint();
     if (!$collection || !$endpoint) {
         return;
     }
     $allowed = $this->acl->isAllowed($this->userService->getRole(), $collection->getIdentifier(), $endpoint->getIdentifier());
     if (!$allowed) {
         throw new Exception(ErrorCodes::ACCESS_DENIED);
     }
 }
 public function run(Api $api, DiInterface $di, Config $config)
 {
     /** @var \PhalconApi\Acl\MountingEnabledAdapterInterface $acl */
     $acl = $di->get(Services::ACL);
     $unauthorizedRole = new Acl\Role(AclRoles::UNAUTHORIZED);
     $authorizedRole = new Acl\Role(AclRoles::AUTHORIZED);
     $acl->addRole($unauthorizedRole);
     $acl->addRole($authorizedRole);
     $acl->addRole(new Acl\Role(AclRoles::ADMINISTRATOR), $authorizedRole);
     $acl->addRole(new Acl\Role(AclRoles::MANAGER), $authorizedRole);
     $acl->addRole(new Acl\Role(AclRoles::USER), $authorizedRole);
     $acl->mountMany($api->getCollections());
 }
 public function run(Api $api, DiInterface $di, Config $config)
 {
     $api->get('/', function () use($api) {
         /** @var \Phalcon\Mvc\View\Simple $view */
         $view = $api->di->get(Services::VIEW);
         return $view->render('general/index');
     });
     $api->get('/proxy.html', function () use($api, $config) {
         /** @var \Phalcon\Mvc\View\Simple $view */
         $view = $api->di->get(Services::VIEW);
         $view->setVar('client', $config->clientHostName);
         return $view->render('general/proxy');
     });
     $api->get('/documentation.html', function () use($api, $config) {
         /** @var \Phalcon\Mvc\View\Simple $view */
         $view = $api->di->get(Services::VIEW);
         $view->setVar('title', $config->application->title);
         $view->setVar('description', $config->application->description);
         $view->setVar('documentationPath', $config->hostName . '/export/documentation.json');
         return $view->render('general/documentation');
     });
 }
 public function run(Api $api, DiInterface $di, Config $config)
 {
     $api->collection(new ExportCollection('/export'))->resource(new UserResource('/users'))->resource(new AlbumResource('/albums'))->resource(new PhotoResource('/photos'));
 }
 public function run(Api $api, DiInterface $di, Config $config)
 {
     $api->attach(new CorsMiddleware($config->cors->allowedOrigins->toArray()))->attach(new OptionsResponseMiddleware())->attach(new NotFoundMiddleware())->attach(new AuthenticationMiddleware())->attach(new AuthorizationMiddleware())->attach(new FractalMiddleware())->attach(new UrlQueryMiddleware());
 }