本文整理汇总了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();
}
示例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()]);
}
示例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);
}
示例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')]);
}
示例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')]);
}
示例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();
}
示例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();
}
示例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());
}
示例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);
}
}
示例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);
}
}
示例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();
}