當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。