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


PHP PhpEnvironment\Request类代码示例

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


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

示例1: getRequest

 protected function getRequest()
 {
     $request = new Request();
     $request->setUri('http://localhost/base-path/asset-path');
     $request->setBasePath('/base-path');
     return $request;
 }
开发者ID:jguittard,项目名称:AssetManager,代码行数:7,代码来源:AssetManagerTest.php

示例2: authenticate

 /**
  * Attempt to authenticate the current user.  Throws exception if login fails.
  *
  * @param \Zend\Http\PhpEnvironment\Request $request Request object containing
  * account credentials.
  *
  * @throws AuthException
  * @return \VuFind\Db\Row\User Object representing logged-in user.
  */
 public function authenticate($request)
 {
     $target = trim($request->getPost()->get('target'));
     $username = trim($request->getPost()->get('username'));
     $password = trim($request->getPost()->get('password'));
     if ($username == '' || $password == '') {
         throw new AuthException('authentication_error_blank');
     }
     // We should have target either separately or already embedded into username
     if ($target) {
         $username = "{$target}.{$username}";
     }
     // Connect to catalog:
     try {
         $patron = $this->getCatalog()->patronLogin($username, $password);
     } catch (AuthException $e) {
         // Pass Auth exceptions through
         throw $e;
     } catch (\Exception $e) {
         throw new AuthException('authentication_error_technical');
     }
     // Did the patron successfully log in?
     if ($patron) {
         return $this->processILSUser($patron);
     }
     // If we got this far, we have a problem:
     throw new AuthException('authentication_error_invalid');
 }
开发者ID:steenlibrary,项目名称:vufind,代码行数:37,代码来源:MultiILS.php

示例3: helpAction

 /**
  * @param Request $request
  * @return array|\Zend\Http\Response
  * @throws \Exception
  */
 public function helpAction($request)
 {
     $this->layout('layout/single-column');
     $this->getNavService()->setActive('setting');
     $helpForm = $this->autoFilledForm(HelpForm::class);
     $helpForm->populateValues($this->user()->getArrayCopy());
     if ($request->isPost()) {
         if ($formValid = $helpForm->isValid()) {
             $config = $this->service('Config');
             if (is_array($config) && isset($config['slack']['webhook']['help-support'])) {
                 $formData = $helpForm->getData();
                 $data = ['fields' => [['name' => 'Name', 'value' => $formData['name'], 'short' => true], ['name' => 'Email', 'value' => $formData['email'], 'short' => true], ['name' => 'Contact No.', 'value' => $formData['contact_no'], 'short' => true], ['name' => 'Type', 'value' => $formData['type'], 'short' => true], ['name' => 'Severity', 'value' => $formData['severity'], 'short' => true], ['name' => 'Need Reply?', 'value' => $formData['need_reply'], 'short' => true], ['name' => 'Message', 'value' => $formData['message'], 'short' => false]]];
                 $json = sprintf('payload=%s', json_encode($data));
                 $ch = curl_init($config['slack']['webhook']['help-support']['url']);
                 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
                 curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                 curl_exec($ch);
                 curl_close($ch);
                 $this->flashMessenger()->addSuccessMessage('Terimakasih, pesan Anda telah terkirim.');
                 return $this->redirect()->toRoute(...$this->routeSpec('web.index.help'));
             }
             $this->flashMessenger()->addErrorMessage('Maaf, tidak dapat mengirim pesan Anda saat ini, mohon hubungi admin.');
             return $this->redirect()->toRoute(...$this->routeSpec('web.index.help'));
         }
     }
     return compact('helpForm', 'formValid');
 }
开发者ID:hanif,项目名称:stokq,代码行数:33,代码来源:IndexController.php

示例4: authenticate

 /**
  * Attempt to authenticate the current user.  Throws exception if login fails.
  *
  * @param \Zend\Http\PhpEnvironment\Request $request Request object containing
  * account credentials.
  *
  * @throws AuthException
  * @return \VuFind\Db\Row\User Object representing logged-in user.
  */
 public function authenticate($request)
 {
     // Check if username is set.
     $shib = $this->getConfig()->Shibboleth;
     $username = $request->getServer()->get($shib->username);
     if (empty($username)) {
         throw new AuthException('authentication_error_admin');
     }
     // Check if required attributes match up:
     foreach ($this->getRequiredAttributes() as $key => $value) {
         if (!preg_match('/' . $value . '/', $request->getServer()->get($key))) {
             throw new AuthException('authentication_error_denied');
         }
     }
     // If we made it this far, we should log in the user!
     $user = $this->getUserTable()->getByUsername($username);
     // Has the user configured attributes to use for populating the user table?
     $attribsToCheck = array("cat_username", "email", "lastname", "firstname", "college", "major", "home_library");
     foreach ($attribsToCheck as $attribute) {
         if (isset($shib->{$attribute})) {
             $user->{$attribute} = $request->getServer()->get($shib->{$attribute});
         }
     }
     // Save and return the user object:
     $user->save();
     return $user;
 }
开发者ID:no-reply,项目名称:cbpl-vufind,代码行数:36,代码来源:Shibboleth.php

示例5: setRequest

 /**
  * @param Request $request
  */
 public function setRequest(Request $request)
 {
     $header = $request->getHeader($this->headerName);
     if ($header) {
         $this->requestHeaderValue = $header->getFieldValue();
     }
 }
开发者ID:middleout,项目名称:mdo-bundle-zf2-locale,代码行数:10,代码来源:Header.php

示例6: testBasePathDetection

 /**
  * @dataProvider baseUrlandPathProvider
  * @param array  $server
  * @param string $baseUrl
  * @param string $basePath
  */
 public function testBasePathDetection(array $server, $baseUrl, $basePath)
 {
     $_SERVER = $server;
     $request = new Request();
     $this->assertEquals($baseUrl, $request->getBaseUrl());
     $this->assertEquals($basePath, $request->getBasePath());
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:13,代码来源:RequestTest.php

示例7: uploadImageAction

 public function uploadImageAction()
 {
     $this->checkAuth();
     $request = $this->getRequest();
     if ($request->isPost()) {
         // File upload input
         $file = new FileInput('avatar');
         // Special File Input type
         $file->getValidatorChain()->attach(new Validator\File\UploadFile());
         $file->getFilterChain()->attach(new Filter\File\RenameUpload(array('target' => './public/files/users/avatar/origin/', 'use_upload_name' => true, 'randomize' => true)));
         // Merge $_POST and $_FILES data together
         $request = new Request();
         $postData = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
         $inputFilter = new InputFilter();
         $inputFilter->add($file)->setData($postData);
         if ($inputFilter->isValid()) {
             // FileInput validators are run, but not the filters...
             $data = $inputFilter->getValues();
             // This is when the FileInput filters are run.
             $avatar = basename($data['avatar']['tmp_name']);
             $this->databaseService->updateAvatar($this->user->id, $avatar);
             $this->user->avatar = $avatar;
         } else {
             // error
         }
     }
     return $this->redirect()->toRoute('profile');
 }
开发者ID:kienbk1910,项目名称:RDCAdmin,代码行数:28,代码来源:ProfileController.php

示例8: clearCookie

 /**
  * Clear authorization Cookie
  *
  * @param string $authDomain
  */
 private function clearCookie(Request $request, Response $response, $authDomain)
 {
     if ($request->getCookie()->offsetExists($authDomain)) {
         $cookie = new SetCookie($authDomain, '', strtotime('-1 Year', time()), '/');
         $response->getHeaders()->addHeader($cookie);
         $response->send();
     }
 }
开发者ID:waydelyle,项目名称:mobicms,代码行数:13,代码来源:Logout.php

示例9: __construct

 /**
  * @param Request $request
  * @param Di $di
  */
 public function __construct(Request $request, Di $di)
 {
     $inputFilter = $this->getFactory()->createInputFilter(['width' => ['name' => 'width', 'required' => false, 'validators' => [['name' => 'digits'], ['name' => 'between', 'options' => ['min' => 150, 'max' => 19200]]]], 'height' => ['name' => 'height', 'required' => false, 'validators' => [['name' => 'digits'], ['name' => 'between', 'options' => ['min' => 150, 'max' => 19200]]]], 'username' => ['name' => 'username', 'required' => false, 'validators' => [['name' => 'not_empty'], ['name' => 'regex', 'options' => ['pattern' => '/^[a-zA-Z0-9._]+$/']]]], 'limit' => ['name' => 'limit', 'required' => false, 'validators' => [['name' => 'digits'], ['name' => 'between', 'options' => ['min' => 5, 'max' => 100]]]], 'hex' => ['name' => 'hex', 'required' => false, 'validators' => [['name' => 'hex']], 'filters' => [['name' => 'callback', 'options' => ['callback' => function ($value) {
         return ltrim($value, '#');
     }]]]], 'source' => ['name' => 'source', 'required' => true, 'validators' => [['name' => 'inarray', 'options' => ['haystack' => [SourceNameInterface::SOURCE_USER, SourceNameInterface::SOURCE_FEED]]]]], 'quality' => ['name' => 'quality', 'required' => false, 'validators' => [['name' => 'inarray', 'options' => ['haystack' => [QualityInterface::QUALITY_THUMBNAIL, QualityInterface::QUALITY_LOW_RES, QualityInterface::QUALITY_STANDARD_RES]]]]]]);
     $this->merge($inputFilter);
     $this->setData($this->initDefaults($request->getQuery()));
 }
开发者ID:spalax,项目名称:ua-webchalange-instagram-collage,代码行数:12,代码来源:ConfigurationData.php

示例10: testHeadersWithMinus

 /**
  * @dataProvider serverHeaderProvider
  * @param array  $server
  * @param string $name
  * @param string $value
  */
 public function testHeadersWithMinus(array $server, $name, $value)
 {
     $_SERVER = $server;
     $request = new Request();
     $header = $request->headers()->get($name);
     $this->assertNotEquals($header, false);
     $this->assertEquals($name, $header->getFieldName($value));
     $this->assertEquals($value, $header->getFieldValue($value));
 }
开发者ID:navtis,项目名称:xerxes-pazpar2,代码行数:15,代码来源:RequestTest.php

示例11: getRequest

 public static function getRequest()
 {
     if (!isset(self::$serverParams)) {
         self::$serverParams = ['HTTP_X_FORWARDED_FOR' => '192.168.1.1', 'HTTP_CLIENT_IP' => '192.168.1.1', 'REMOTE_ADDR' => '192.168.1.1'];
     }
     $httpRequest = new HttpRequest();
     $httpRequest->setServer(new Parameters(self::$serverParams));
     return $httpRequest;
 }
开发者ID:dollyaswin,项目名称:pyro,代码行数:9,代码来源:Request.php

示例12: getRemoteAddress

 public function getRemoteAddress()
 {
     $request = new Request();
     $serverParams = $request->getServer();
     $remoteAddress = $serverParams->get('REMOTE_ADDR');
     if ($remoteAddress == '') {
         $remoteAddress = '127.0.0.1';
     }
     return $remoteAddress;
 }
开发者ID:netsensia,项目名称:zf2-foundation,代码行数:10,代码来源:MaxmindLocationService.php

示例13: getSessionIdFromRequest

 /**
  * @param \Zend\Http\PhpEnvironment\Request $request
  * @return string|null
  */
 protected function getSessionIdFromRequest($request)
 {
     $ssid = $request->getPost(static::SESSION_ID_ALIAS);
     if (!$ssid) {
         $ssid = $request->getQuery(static::SESSION_ID_ALIAS);
     }
     if (!$ssid) {
         return null;
     }
     return $ssid;
 }
开发者ID:qshurick,项目名称:auth,代码行数:15,代码来源:Authentication.php

示例14: getList

 /**
  * @param array $search
  * @param array $orderBy
  * @param array $parameters
  *
  * @return \Zend\Paginator\Paginator
  */
 public function getList($search = [], $orderBy = [], $parameters = [])
 {
     $query = $this->mainRepository->getAdminPage($search, $orderBy, $parameters);
     $paginator = $this->paginatorFactory->getQueryPaginator($query);
     $paginator->setCurrentPageNumber($this->request->getQuery(self::PAGE, 0));
     $paginator->setItemCountPerPage(5);
     return $paginator;
 }
开发者ID:peteraba,项目名称:dm-mailer,代码行数:15,代码来源:Base.php

示例15: getPermissions

 /**
  * Return an array of roles which may be granted the permission based on
  * the options.
  *
  * @param mixed $options Options provided from configuration.
  *
  * @return array
  */
 public function getPermissions($options)
 {
     if ($this->request->getServer()->get('Shib-Identity-Provider') === false) {
         $this->logWarning('getPermissions: Shibboleth server params missing');
         return [];
     }
     return parent::getPermissions($options);
 }
开发者ID:htw-pk15,项目名称:vufind,代码行数:16,代码来源:Shibboleth.php


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