当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::getAttribute方法代码示例

本文整理汇总了PHP中Slim\Http\Request::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getAttribute方法的具体用法?PHP Request::getAttribute怎么用?PHP Request::getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Slim\Http\Request的用法示例。


在下文中一共展示了Request::getAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __invoke

 public function __invoke(Request $req, Response $res)
 {
     $school = $req->getAttribute('school');
     $appForm = $this->appFormService->findSchoolApplicationForm($school->id);
     if (null === $appForm) {
         return $res->withStatus(404);
     }
     $html = $this->view->fetch('application_form/pdf.twig', ['school' => $school, 'appForm' => $appForm, 'logo' => base64_encode(file_get_contents(__DIR__ . '/../../public/img/application_form/minedu_logo.jpg')), 'style' => file_get_contents(__DIR__ . '/../../public/css/application_form/pdf.css')]);
     $pdf = new \Dompdf\Dompdf(['default_paper_size' => 'A4', 'default_font' => 'DejaVu Sans', 'isHtml5ParserEnabled' => true, 'is_remote_enabled' => false]);
     $pdf->loadHtml($html);
     $pdf->render();
     $filename = 'edulabs_app_form_' . $appForm['id'] . '.pdf';
     $str = $pdf->output();
     $length = mb_strlen($str, '8bit');
     return $res->withHeader('Cache-Control', 'private')->withHeader('Content-type', 'application/pdf')->withHeader('Content-Length', $length)->withHeader('Content-Disposition', 'attachment;  filename=' . $filename)->withHeader('Accept-Ranges', $length)->write($str);
 }
开发者ID:eellak,项目名称:gredu_labs,代码行数:16,代码来源:ApplicationFormPdf.php

示例2: actionCreate

 public function actionCreate(Request $request)
 {
     if ($request->isXhr()) {
         $model = Unit::find($request->getAttribute('id'));
         return $this->renderAjax('image/ajax/modal', ['model' => $model]);
     }
     $this->uploadFiles($request->getUploadedFiles(), $request->getParams(), $request->getAttribute('id'));
     return $this->goBack();
 }
开发者ID:xandros15,项目名称:aigisu,代码行数:9,代码来源:ImageFileController.php

示例3: __invoke

 public function __invoke(Request $req, Response $res)
 {
     $school = $req->getAttribute('school');
     if ($req->isPost()) {
         $this->appFormInputFilter->setData(array_merge($req->getParams(), ['school_id' => $school->id, 'submitted_by' => $this->authService->getIdentity()->mail]));
         $isValid = $this->appFormInputFilter->isValid();
         if ($isValid) {
             $data = $this->appFormInputFilter->getValues();
             $appForm = $this->appFormService->submit($data);
             $_SESSION['applicationForm']['appForm'] = $appForm;
             $res = $res->withRedirect($this->successUrl);
             return $res;
         }
         $this->view['form'] = ['is_valid' => $isValid, 'values' => $this->appFormInputFilter->getValues(), 'raw_values' => $this->appFormInputFilter->getRawValues(), 'messages' => $this->appFormInputFilter->getMessages()];
     }
     $loadForm = (bool) $req->getParam('load', false);
     $this->view['choose'] = !$loadForm && !$req->isPost();
     if (!$req->isPost() && $loadForm) {
         if (null !== ($appForm = $this->appFormService->findSchoolApplicationForm($school->id))) {
             $this->view['form'] = ['values' => $appForm];
         }
     }
     $labs = $this->labService->getLabsBySchoolId($school->id);
     $res = $this->view->render($res, 'application_form/form.twig', ['lab_choices' => array_map(function ($lab) {
         return ['value' => $lab['id'], 'label' => $lab['name']];
     }, $labs), 'type_choices' => array_map(function ($category) {
         return ['value' => $category['id'], 'label' => $category['name']];
     }, $this->assetsService->getAllItemCategories())]);
     return $res;
 }
开发者ID:kanellov,项目名称:gredu_labs,代码行数:30,代码来源:ApplicationForm.php

示例4: __invoke

 public function __invoke(Request $req, Response $res, array $args = [])
 {
     $school = $req->getAttribute('school', false);
     if (!$school) {
         return $res->withStatus(403, 'No school');
     }
     $params = $req->getParams();
     $id = $params['id'];
     $params['school_id'] = $school->id;
     if (isset($params['lessons']) && !is_array($params['lessons'])) {
         $params['lessons'] = explode(',', $params['lessons']);
     }
     unset($params['id']);
     try {
         if ($id) {
             $lab = $this->labservice->updateLab($params, $id);
             $res = $res->withStatus(200);
         } else {
             $lab = $this->labservice->createLab($params);
             $res = $res->withStatus(201);
         }
         $res = $res->withJson($lab);
     } catch (Exception $ex) {
         $res = $res->withStatus(500, $ex->getMessage());
     }
     return $res;
 }
开发者ID:eellak,项目名称:gredu_labs,代码行数:27,代码来源:PersistLab.php

示例5: __invoke

 public function __invoke(Request $req, Response $res)
 {
     $school = $req->getAttribute('school', false);
     if (!$school) {
         return $res->withStatus(403, 'No school');
     }
     $teacherId = $req->getParam('teacher_id');
     $teacher = $this->staffService->getTeacherById($teacherId);
     if ($teacher['school_id'] !== $school->id) {
         return $res->withStatus(403, 'No school');
     }
     if ($req->isPost()) {
         $inputFilter = $this->inputFilter;
         $result = $inputFilter($req->getParams());
         if (!$result['is_valid']) {
             $res = $res->withStatus(422);
             $res = $res->withJson($result);
             return $res;
         }
         $this->service->saveAnswers($teacherId, $result['values']);
     }
     $data = $this->service->getAnswers($teacherId);
     $res = $res->withJson($data);
     return $res;
 }
开发者ID:eellak,项目名称:gredu_labs,代码行数:25,代码来源:SurveyForm.php

示例6: getMunicipioDepartamento

 function getMunicipioDepartamento(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $id = $request->getAttribute("id");
     $data = Municipio::select("municipio.*", "departamento.nombre as departamento")->join('departamento', 'departamento.id', '=', 'municipio.idDepartamento')->where("municipio.id", "=", $id)->first();
     $response->getBody()->write($data);
     return $response;
 }
开发者ID:giocni93,项目名称:Apiturno,代码行数:8,代码来源:MunicipioControl.php

示例7: borrartipoturnosucursal

 function borrartipoturnosucursal(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $data = json_decode($request->getBody(), true);
     $id = $request->getAttribute("id");
     $tipo = Tipoturnosucursal::select("*")->where("idsucursal", "=", $id)->delete();
     $response->getBody()->write($tipo);
     return $response;
 }
开发者ID:giocni93,项目名称:Apiturno,代码行数:9,代码来源:TipoturnosucursalControl.php

示例8: __invoke

 public function __invoke(Request $req, Response $res)
 {
     $school = $req->getAttribute('school', false);
     if (!$school) {
         return $res->withStatus(403, 'No school');
     }
     $this->service->setTotalTeachers($school->id, (int) $req->getParam('total_teachers', 0));
     return $res->withStatus(204);
 }
开发者ID:eellak,项目名称:gredu_labs,代码行数:9,代码来源:SubmitTeachersCount.php

示例9: promedio

 public function promedio(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $idCliente = $request->getAttribute("idCliente");
     $query = "SELECT COALESCE(AVG(calificacion),0) as promedio FROM calificacioncliente WHERE idCliente = " . $idCliente;
     $data = DB::select(DB::raw($query));
     $response->getBody()->write(json_encode($data));
     return $response;
 }
开发者ID:giocni93,项目名称:Apiturno,代码行数:9,代码来源:CalificacionClienteControl.php

示例10: display

 /**
  * display a static page
  *
  * @param Request $request
  * @param Response $response
  * @return Response
  */
 public function display(Request $request, Response $response)
 {
     try {
         $res = $this->render($response, sprintf('pages/%s.html', $request->getAttribute('page', 'home')));
     } catch (\Exception $e) {
         $res = $this->render($response, 'errors/404.html');
     }
     return $res;
 }
开发者ID:oanhnn,项目名称:mypage,代码行数:16,代码来源:Pages.php

示例11: eliminarservicios

 function eliminarservicios(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $data = json_decode($request->getBody(), true);
     $id = $request->getAttribute("idempleado");
     $tipo = ServiciosEmpleado::select("*")->where("idEmpleado", "=", $id)->delete();
     $response->getBody()->write($tipo);
     return $response;
 }
开发者ID:giocni93,项目名称:Apiturno,代码行数:9,代码来源:ServiciosEmpleadoControl.php

示例12: normalizeProfile

 public function normalizeProfile(Request $request, Response $response, callable $next)
 {
     $routeInfo = $request->getAttribute('routeInfo');
     $args = $routeInfo[2];
     if (substr($args['username'], -5) == '.json') {
         $routeInfo[2]['username'] = substr($args['username'], 0, -5);
         $request = $request->withAttribute('routeInfo', $routeInfo)->withHeader('X-Requested-With', 'XMLHttpRequest');
     }
     return $next($request, $response);
 }
开发者ID:phpindonesia,项目名称:phpindonesia.or.id-membership2,代码行数:10,代码来源:Middleware.php

示例13: __invoke

 public function __invoke(Request $req, Response $res, array $args = [])
 {
     $school = $req->getAttribute('school', false);
     if (!$school) {
         return $res->withStatus(403, 'No school');
     }
     $staff = $this->staffService->getTeachersBySchoolId($school->id);
     return $this->view->render($res, 'schools/staff.twig', ['school' => $school, 'staff' => $staff, 'branches' => array_map(function ($branch) {
         return ['value' => $branch['id'], 'label' => $branch['name']];
     }, $this->staffService->getBranches())]);
 }
开发者ID:eellak,项目名称:gredu_labs,代码行数:11,代码来源:ListAll.php

示例14: get

 /**
  * display a static page
  *
  * @param Request $request
  * @param Response $response
  */
 public function get(Request $request, Response $response)
 {
     $pdate = str_replace('/', '-', $request->getAttribute('pdate'));
     $pslug = $request->getAttribute('pslug');
     $pfile = sprintf('%s/blog/%s-%s.md', ROOT_PATH, $pdate, strtolower($pslug));
     if (!is_file($pfile) || !is_readable($pfile)) {
         return $this->render($response, 'errors/404.html');
     }
     $f = file_get_contents($pfile);
     $t = \Michelf\MarkdownExtra::defaultTransform($f);
     return $response->getBody()->write($t);
     $pdata = json_decode(file_get_contents($pfile), true);
     if (empty($pdata)) {
         return $this->render($response, 'errors/500.html');
     }
     $pdata['published_at'] = $pdate;
     $pdata['slug'] = $pslug;
     $pdata['url'] = (string) $request->getUri();
     return $this->render($response, 'post.html', compact('pdata'));
 }
开发者ID:oanhnn,项目名称:mypage,代码行数:26,代码来源:Posts.php

示例15: promocionesByUsuario

 function promocionesByUsuario(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $id = $request->getAttribute('id');
     $data = Promocion::where("idUsuario", "=", $id)->get();
     if (count($data) == 0) {
         $response = $response->withStatus(404);
     }
     $response->getBody()->write($data);
     return $response;
 }
开发者ID:giocni93,项目名称:BuscaloApi,代码行数:11,代码来源:PromocionControl.php


注:本文中的Slim\Http\Request::getAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。