Пример #1
0
 private function handleNestedValidationException()
 {
     /** @var NestedValidationException $e */
     $e = $this->e;
     $messages = $this->formatMessages($e);
     return $this->response->withJson($e->getFullMessage(), 400);
 }
Пример #2
0
 public function __invoke(Request $req, Response $res, $args = [])
 {
     $vaultName = $args['vaultName'];
     if (!($v = Vault::get($vaultName))) {
         return $res->withStatus(404);
     }
     return $res->withJson($v->serializeArray(), 200, JSON_PRETTY_PRINT);
 }
Пример #3
0
 public function __invoke(Request $req, Response $res, $args = [])
 {
     $ret = [];
     foreach (Vault::all() as $vault) {
         $ret[] = $vault->serializeArray();
     }
     $jsonResponse = ['Marker' => null, 'VaultList' => $ret];
     return $res->withJson($jsonResponse, 200, JSON_PRETTY_PRINT);
 }
Пример #4
0
 public function active(Request $request, Response $response, $args)
 {
     $query_builder = $this->getIndicadorService()->getEntityManager()->createQueryBuilder();
     $query_builder->update('App\\Entity\\Kpi', 'kpi')->set('kpi.active', '0')->getQuery()->execute();
     $em = $this->getIndicadorService()->getEntityManager();
     $kpi = $em->getRepository('App\\Entity\\Kpi')->findOneById($args['id']);
     $kpi->setActive(1);
     $em->persist($kpi);
     $em->flush();
     return $response->withJson((new ClassMethods())->extract($kpi));
 }
 public function __invoke(Request $req, Response $res, $args = [])
 {
     $vaultName = $args['vaultName'];
     if (!($vault = Vault::get($vaultName))) {
         return $res->withStatus(404);
     }
     $jsonResponse = ['UploadsList' => []];
     foreach ($vault->getMultiparts() as $m) {
         $jsonResponse['UploadsList'][] = $m->serializeArray();
     }
     return $res->withJson($jsonResponse, 200, JSON_PRETTY_PRINT);
 }
 public function __invoke(Request $req, Response $res, $args = [])
 {
     $vaultName = $args['vaultName'];
     $multipartID = $args['multipartID'];
     if (!($vault = Vault::get($vaultName))) {
         return $res->withStatus(404);
     }
     if (!($m = $vault->getMultipart($multipartID))) {
         return $res->withStatus(404);
     }
     return $res->withJson($m->serializeArray(true), 200, JSON_PRETTY_PRINT);
 }
Пример #7
0
 public function __invoke(Request $req, Response $res, $args = [])
 {
     $vaultName = $args['vaultName'];
     $jobID = $args['jobID'];
     if (!($vault = Vault::get($vaultName))) {
         return $res->resourceNotFoundException();
     }
     if (!($job = $vault->getJob($jobID))) {
         return $res->resourceNotFoundException();
     }
     return $res->withJson($job->serializeArray(true), 200, JSON_PRETTY_PRINT);
 }
Пример #8
0
 public function __invoke(Request $req, Response $res, $args = [])
 {
     $vaultName = $args['vaultName'];
     if (!($vault = Vault::get($vaultName))) {
         return $res->withStatus(404);
     }
     $jsonResponse = ['Marker' => null, 'JobList' => []];
     foreach ($vault->getJobs() as $job) {
         $jsonResponse['JobList'][] = $job->serializeArray();
     }
     return $res->withJson($jsonResponse, 200, JSON_PRETTY_PRINT);
 }
Пример #9
0
 public function searchTabsApi(Request $request, Response $response, array $args)
 {
     return $response->withJson($this->container->tabRepository->searchSuggestions($args['term']));
 }
 /**
  * JSON render response.
  *
  * @param  Response $response
  * @param  array $data Associative array of data to be returned
  * @param  int $status HTTP status code
  * @return Response
  */
 public function render(Response $response, $data = [], $status = 200)
 {
     // Return JSON response
     return $response->withJson($data, $status);
 }
Пример #11
0
 /**
  * Presentation slide as json
  *
  * @param  Request  $request
  * @param  Response $response
  * @param  Array    $args
  * @return Response
  */
 public function json(Request $request, Response $response, array $args)
 {
     $path = $this->settings['presentation']['presentation'];
     $fileName = substr_replace($args['file'], '.', -3, 1);
     $filePath = $path . $fileName;
     $slideNumber = (int) preg_replace('/\\D/', '', $args['slide']);
     $file = new File($filePath);
     $data = [];
     if ($file->load() === true) {
         $slide = new Slide($filePath);
         $data['error'] = false;
         $data['slide'] = $slide->renderForAjax($slideNumber);
     } else {
         $data['error'] = true;
         $data['message'] = 'Could not load presentation file.';
     }
     return $response->withJson($data);
 }
 public function getVersion(Request $request, Response $response, $args)
 {
     $this->logger->info("Action: Get Application Version");
     $appVersion = ['version' => APP_VERSION, 'build' => APP_BUILD, 'fullVersion' => 'V' . APP_VERSION . '(' . APP_BUILD . ')'];
     return $response->withJson($appVersion);
 }
 public function __invoke(Request $req, Response $res, $args = [])
 {
     $policy = new DataRetrievalPolicy();
     $ruleset = $policy->get();
     return $res->withJson($policy->get(), 200, JSON_PRETTY_PRINT);
 }