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


PHP Request::isXhr方法代码示例

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


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

示例1: 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

示例2: index

 public function index(Request $request, Response $response, array $args)
 {
     /** @var Careers $career */
     $career = $this->data(Careers::class);
     /** @var \PDOStatement $portfolio */
     $portfolio = $this->data(MemberPortfolios::class)->find(['member_portfolio_id' => (int) $args['id'], 'user_id' => $this->session->get('user_id'), 'deleted' => 'N']);
     if ($request->isXhr()) {
         return $response->withJson($portfolio->fetch());
     }
     $this->view->addData(['career_levels' => array_pairs($career->getLevels(), 'career_level_id'), 'industries' => array_pairs($career->getIndustries(), 'industry_id', 'industry_name')], 'sections::portfolio-form');
     $this->setPageTitle('Membership', 'Update portfolio item');
     return $this->view->render('portfolio-edit', ['portfolio' => $portfolio->fetch()]);
 }
开发者ID:aswitahidayat,项目名称:phpindonesia.or.id-membership2,代码行数:13,代码来源:PortfoliosController.php

示例3: authorizeSkillRoute

 public function authorizeSkillRoute(Request $request, Response $response, callable $next)
 {
     // Authorize portfolio middleware
     $args = $request->getAttribute('routeInfo')[2];
     if (!$args || $request->isXhr() && $request->isGet()) {
         return $next($request, $response);
     }
     $count = $this->data(Models\MemberSkills::class)->count(['member_skill_id' => (int) $args['id'], 'user_id' => $this->session->get('user_id')]);
     if ($count < 1) {
         $this->flash->addMessage('warning', 'Permission denied.');
         return $response->withRedirect($this->router->pathFor('membership-account'));
     }
     return $next($request, $response);
 }
开发者ID:phpindonesia,项目名称:phpindonesia.or.id-membership2,代码行数:14,代码来源:Middleware.php

示例4: profile

 public function profile(Request $request, Response $response, array $args)
 {
     $this->setPageTitle('Membership', 'Detail Anggota');
     /** @var Users $users */
     $users = $this->data(Users::class);
     $user = $users->getProfileUsername($args['username']);
     if (!$user) {
         throw new NotFoundException($request, $response);
     }
     if ($request->isXhr()) {
         $outputJson = ['username' => $user['username'], 'fullname' => $user['fullname'], 'email' => $user['email'], 'gender' => $user['gender'], 'city' => $user['city'], 'province' => $user['province']];
         return $response->withJson($outputJson);
     }
     return $this->view->render('profile-index', ['member' => $user, 'member_portfolios' => $users->getPortfolios($user['user_id']), 'member_skills' => $users->getSkills($user['user_id']), 'member_socmeds' => $users->getSocmends($user['user_id']), 'socmedias' => $this->settings->get('socmedias')]);
 }
开发者ID:aswitahidayat,项目名称:phpindonesia.or.id-membership2,代码行数:15,代码来源:AccountController.php

示例5: profile

 public function profile(Request $request, Response $response, array $args)
 {
     $this->setPageTitle('Membership', 'Detail Anggota');
     /** @var Users $users */
     $users = $this->data(Users::class);
     $user = $users->get(['u.user_id', 'u.username', 'u.email', 'u.created', 'm.*', 'reg_prv.regional_name province', 'reg_cit.regional_name city'], function ($query) use($args) {
         $query->from('users u')->leftJoin('members_profiles m', 'u.user_id', '=', 'm.user_id')->leftJoin('regionals reg_prv', 'reg_prv.id', '=', 'm.province_id')->leftJoin('regionals reg_cit', 'reg_cit.id', '=', 'm.city_id')->where('u.username', '=', $args['username']);
     })->fetch();
     if (!$user) {
         throw new NotFoundException($request, $response);
     }
     if ($request->isXhr()) {
         return $response->withJson(['username' => $user['username'], 'fullname' => $user['fullname'], 'email' => $user['email'], 'gender' => $user['gender'], 'city' => $user['city'], 'province' => $user['province']]);
     }
     return $this->view->render('profile-index', ['member' => $user, 'member_portfolios' => $users->getPortfolios($user['user_id']), 'member_skills' => $users->getSkills($user['user_id']), 'member_socmeds' => $users->getSocmends($user['user_id']), 'socmedias' => $this->settings->get('socmedias')]);
 }
开发者ID:phpindonesia,项目名称:phpindonesia.or.id-membership2,代码行数:16,代码来源:AccountController.php

示例6: actionUpdate

 public function actionUpdate(Request $request)
 {
     if (!Oauth::isLogged()) {
         return $this->goBack();
     }
     /* @var $model Unit */
     $model = Unit::find($request->getAttribute('id'));
     if ($request->isXhr()) {
         return $this->renderAjax('unit/ajax/modal', ['model' => $model]);
     }
     $model->addTagsToUnit($request->getParam('tags'));
     $model->fill($request->getParams());
     if ($model->validate() && $model->save()) {
         Alert::add("Successful update {$model->name}");
     }
     return $this->goBack();
 }
开发者ID:xandros15,项目名称:aigisu,代码行数:17,代码来源:UnitController.php

示例7: isAcceptable

 /**
  * @param \Slim\Http\Request $request
  * @return bool
  */
 private function isAcceptable(Request $request)
 {
     $args = $request->getAttribute('routeInfo')[2];
     return !$args || $request->isXhr() && $request->isGet();
 }
开发者ID:aswitahidayat,项目名称:phpindonesia.or.id-membership2,代码行数:9,代码来源:Middleware.php

示例8: testIsXhr

 public function testIsXhr()
 {
     $uri = Uri::createFromString('https://example.com:443/foo/bar?abc=123');
     $headers = new Headers(['Content-Type' => 'application/x-www-form-urlencoded', 'X-Requested-With' => 'XMLHttpRequest']);
     $cookies = [];
     $serverParams = [];
     $body = new RequestBody();
     $request = new Request('GET', $uri, $headers, $cookies, $serverParams, $body);
     $this->assertTrue($request->isXhr());
 }
开发者ID:kschaefers,项目名称:RaumsucheRestBackend,代码行数:10,代码来源:RequestTest.php

示例9: assertHTMLRequest

 /**
  * Assert is HTML request
  *
  * @param \Slim\Http\Request  $request
  * @param \Slim\Http\Response $response
  * @throws \Slim\Exception\NotFoundException
  */
 protected function assertHTMLRequest(Request $request, Response $response)
 {
     if ($request->isXhr()) {
         throw new NotFoundException($request, $response);
     }
 }
开发者ID:aswitahidayat,项目名称:phpindonesia.or.id-membership2,代码行数:13,代码来源:Controllers.php

示例10: assertXhrRequest

 /**
  * Assert is XHR request
  *
  * @param \Slim\Http\Request  $request
  * @param \Slim\Http\Response $response
  * @throws \Slim\Exception\NotFoundException
  */
 protected function assertXhrRequest($request, $response)
 {
     if (!$request->isXhr()) {
         throw new NotFoundException($request, $response);
     }
 }
开发者ID:tirta-keniten,项目名称:phpindonesia.or.id-membership2,代码行数:13,代码来源:Controllers.php

示例11: getSlimView

 public function getSlimView(\Slim\Http\Request $request)
 {
     if ($request->isAjax() || $request->isXhr() || $request->get('format', '') == 'json' || $request->post('format', '') == 'json') {
         return $this->slimViewFactory->getJsonSlimView();
     }
     return $this->slimViewFactory->getHtmlSlimView();
 }
开发者ID:anneks,项目名称:rightaboutnow,代码行数:7,代码来源:SlimViewPicker.class.php


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