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


PHP Proxy\Request类代码示例

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


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

示例1: initRequest

 /**
  * get CLI Request
  *
  * @return Cli\Request
  */
 public function initRequest()
 {
     $request = new Cli\Request();
     if ($config = Config::getData('request')) {
         $request->setOptions($config);
     }
     Request::setInstance($request);
 }
开发者ID:dezvell,项目名称:skeleton,代码行数:13,代码来源:CliBootstrap.php

示例2: testProcessRequest

 /**
  * Process Request
  */
 public function testProcessRequest()
 {
     $request = Request::getInstance();
     $request = $request->withQueryParams(['arr-page' => 2, 'arr-limit' => 2, 'arr-order-id' => 'desc', 'arr-filter-name' => 'ne-Smith', 'arr-filter-status' => 'disable']);
     Request::setInstance($request);
     $grid = new ArrayGrid();
     $this->assertEquals(8, $grid->total());
     $this->assertEquals(4, $grid->pages());
 }
开发者ID:bluzphp,项目名称:framework,代码行数:12,代码来源:GridTest.php

示例3: initRequest

 /**
  * get CLI Request
  * @return void
  * @throws ApplicationException
  */
 public function initRequest()
 {
     $arguments = getopt("u:", ["uri:"]);
     if (!array_key_exists('u', $arguments) && !array_key_exists('uri', $arguments)) {
         throw new ApplicationException('Attribute `--uri` is required');
     }
     $uri = $arguments['u'] ?? $arguments['uri'];
     $request = RequestFactory::fromGlobals(['REQUEST_URI' => $uri, 'REQUEST_METHOD' => 'CLI']);
     Request::setInstance($request);
 }
开发者ID:bluzphp,项目名称:skeleton,代码行数:15,代码来源:CliBootstrap.php

示例4: testParamManipulation

 /**
  * Test of params
  */
 public function testParamManipulation()
 {
     Request::setParam('foo', 'bar');
     Request::setParam('baz', 'qux');
     $this->assertEquals('bar', Request::getParam('foo'));
     $this->assertEquals('qux', Request::getParam('baz'));
     $this->assertEquals('moo', Request::getParam('qux', 'moo'));
     $this->assertEqualsArray(['foo' => 'bar', 'baz' => 'qux'], Request::getParams());
     $this->assertEqualsArray(['foo' => 'bar', 'baz' => 'qux'], Request::getAllParams());
 }
开发者ID:dezvell,项目名称:mm.local,代码行数:13,代码来源:RequestTest.php

示例5: testErrorController

 /**
  * Test run Error Controller
  */
 public function testErrorController()
 {
     // setup Request
     $request = new ServerRequest([], [], uniqid('module') . '/' . uniqid('controller'), Request::METHOD_GET);
     Request::setInstance($request);
     // run Application
     $this->getApp()->process();
     $this->assertEquals(Router::getErrorModule(), $this->getApp()->getModule());
     $this->assertEquals(Router::getErrorController(), $this->getApp()->getController());
 }
开发者ID:bluzphp,项目名称:framework,代码行数:13,代码来源:ApplicationTest.php

示例6: testErrorController

 /**
  * Test run Error Controller
  */
 public function testErrorController()
 {
     // setup Request
     Request::setRequestUri(uniqid('module') . '/' . uniqid('controller'));
     Request::setMethod(Request::METHOD_GET);
     // run Application
     $this->getApp()->process();
     $this->assertEquals(Router::getErrorModule(), $this->getApp()->getModule());
     $this->assertEquals(Router::getErrorController(), $this->getApp()->getController());
 }
开发者ID:dezvell,项目名称:mm.local,代码行数:13,代码来源:ApplicationTest.php

示例7: resetApp

 /**
  * Reset layout and Request
  */
 protected static function resetApp()
 {
     if (self::$app) {
         self::$app->useLayout(true);
     }
     Proxy\Auth::clearIdentity();
     Proxy\Messages::popAll();
     Proxy\Request::setInstance(new Http\Request());
     Proxy\Response::setInstance(new Http\Response());
     Proxy\Response::setPresentation(null);
 }
开发者ID:9618211,项目名称:framework,代码行数:14,代码来源:TestCase.php

示例8: getIdentity

 /**
  * Return identity if user agent is correct
  * @api
  * @return EntityInterface|null
  */
 public function getIdentity()
 {
     if (!$this->identity) {
         // check user agent
         if (Session::get('auth:agent') == Request::getServer('HTTP_USER_AGENT')) {
             $this->identity = Session::get('auth:identity');
         } else {
             $this->clearIdentity();
         }
     }
     return $this->identity;
 }
开发者ID:9618211,项目名称:framework,代码行数:17,代码来源:Auth.php

示例9: __construct

 /**
  * Prepare request for processing
  */
 public function __construct()
 {
     // rewrite REST with "_method" param
     // this is workaround
     $this->method = strtoupper(Request::getParam('_method', Request::getMethod()));
     // get all params
     $query = Request::getQuery();
     if (is_array($query) && !empty($query)) {
         unset($query['_method']);
         $this->params = $query;
     }
     $this->data = Request::getParams();
 }
开发者ID:9618211,项目名称:framework,代码行数:16,代码来源:AbstractController.php

示例10: testUploadFile

 /**
  * Test upload file
  */
 public function testUploadFile()
 {
     // get path from config
     $path = 'uploads/musician';
     if (empty($path)) {
         throw new Exception('Temporary path is not configured');
     }
     $_FILES = array('file' => array('name' => 'test.jpg', 'size' => filesize($path), 'type' => 'image/jpeg', 'tmp_name' => $path, 'error' => 0));
     Request::setFileUpload(new TestFileUpload());
     $this->dispatchUri('media/crud', ['title' => 'test', 'file' => $_FILES['file']], 'POST');
     $this->assertQueryCount('input[name="title"]', 1);
     $this->assertOk();
 }
开发者ID:Kit-kat1,项目名称:bluz,代码行数:16,代码来源:CrudTest.php

示例11: __invoke

 /**
  * {@inheritdoc}
  *
  * @throws NotImplementedException
  * @throws NotFoundException
  * @throws BadRequestException
  * @return mixed
  */
 public function __invoke()
 {
     $primary = $this->getPrimaryKey();
     // switch by method
     switch ($this->method) {
         case Request::METHOD_GET:
             $row = $this->readOne($primary);
             $result = ['row' => $row];
             if (!empty($primary)) {
                 // update form
                 $result['method'] = Request::METHOD_PUT;
             } else {
                 // create form
                 $result['method'] = Request::METHOD_POST;
             }
             break;
         case Request::METHOD_POST:
             try {
                 $result = $this->createOne($this->data);
                 if (!Request::isXmlHttpRequest()) {
                     $row = $this->readOne($result);
                     $result = ['row' => $row, 'method' => Request::METHOD_PUT];
                 }
             } catch (ValidatorException $e) {
                 $row = $this->readOne(null);
                 $row->setFromArray($this->data);
                 $result = ['row' => $row, 'errors' => $e->getErrors(), 'method' => $this->getMethod()];
             }
             break;
         case Request::METHOD_PATCH:
         case Request::METHOD_PUT:
             try {
                 $result = $this->updateOne($primary, $this->data);
                 if (!Request::isXmlHttpRequest()) {
                     $row = $this->readOne($primary);
                     $result = ['row' => $row, 'method' => $this->getMethod()];
                 }
             } catch (ValidatorException $e) {
                 $row = $this->readOne($primary);
                 $row->setFromArray($this->data);
                 $result = ['row' => $row, 'errors' => $e->getErrors(), 'method' => $this->getMethod()];
             }
             break;
         case Request::METHOD_DELETE:
             $result = $this->deleteOne($primary);
             break;
         default:
             throw new NotImplementedException();
     }
     return $result;
 }
开发者ID:Kit-kat1,项目名称:custom-bluz-app,代码行数:59,代码来源:Crud.php

示例12: sendBody

 /**
  * Send body
  *
  * @return void
  */
 protected function sendBody()
 {
     // Nobody for HEAD and OPTIONS
     if (Request::METHOD_HEAD == ProxyRequest::getMethod() || Request::METHOD_OPTIONS == ProxyRequest::getMethod()) {
         return;
     }
     // Body can be Closures
     $content = $this->body;
     if ($content instanceof \Closure) {
         $content();
     } else {
         echo $content;
     }
 }
开发者ID:dezvell,项目名称:mm.local,代码行数:19,代码来源:Response.php

示例13: createOne

 /**
  * createOne
  *
  * @param array $data
  * @throws \Application\Exception
  * @throws \Bluz\Request\RequestException
  * @return integer
  */
 public function createOne($data)
 {
     /**
      * Process HTTP File
      * @var \Bluz\Http\File $file
      */
     $file = Request::getFileUpload()->getFile('file');
     if (!$file or $file->getErrorCode() != UPLOAD_ERR_OK) {
         if ($file->getErrorCode() == UPLOAD_ERR_NO_FILE) {
             throw new Exception("Please choose file for upload");
         }
         throw new Exception("Sorry, I can't receive file");
     }
     /**
      * Generate image name
      */
     $fileName = strtolower(isset($data['title']) ? $data['title'] : $file->getName());
     // Prepare filename
     $fileName = preg_replace('/[ _;:]+/i', '-', $fileName);
     $fileName = preg_replace('/[-]+/i', '-', $fileName);
     $fileName = preg_replace('/[^a-z0-9.-]+/i', '', $fileName);
     // If name is wrong
     if (empty($fileName)) {
         $fileName = date('Y-m-d-His');
     }
     // If file already exists, increment name
     $originFileName = $fileName;
     $counter = 0;
     while (file_exists($this->uploadDir . '/' . $fileName . '.' . $file->getExtension())) {
         $counter++;
         $fileName = $originFileName . '-' . $counter;
     }
     // Setup new name and move to user directory
     $file->setName($fileName);
     $file->moveTo($this->uploadDir);
     $this->uploadDir = substr($this->uploadDir, strlen(PATH_PUBLIC) + 1);
     $data['file'] = $this->uploadDir . '/' . $file->getFullName();
     $data['type'] = $file->getMimeType();
     $row = $this->getTable()->create();
     $row->setFromArray($data);
     return $row->save();
 }
开发者ID:bobrofor,项目名称:menuProject,代码行数:50,代码来源:Crud.php

示例14: process

 /**
  * Response as JSONP
  */
 public function process()
 {
     // override response code so javascript can process it
     $this->response->setHeader('Content-Type', 'application/javascript');
     // prepare body
     if ($body = $this->response->getBody()) {
         // convert to JSON
         $body = json_encode($body);
         // try to guess callback function name
         //  - check `callback` param
         //  - check `jsonp` param
         //  - use `callback` as default callback name
         $callback = Request::getParam('jsonp', Request::getParam('callback', 'callback'));
         $body = $callback . '(' . $body . ')';
         // setup content length
         $this->response->setHeader('Content-Length', strlen($body));
         // prepare to JSON output
         $this->response->setBody($body);
     }
 }
开发者ID:9618211,项目名称:framework,代码行数:23,代码来源:Jsonp.php

示例15: readSet

 /**
  * {@inheritdoc}
  *
  * @param int $offset
  * @param int $limit
  * @param array $params
  * @return array|int|mixed
  */
 public function readSet($offset = 0, $limit = 10, $params = array())
 {
     $select = Db::select('*')->from('test', 't');
     if ($limit) {
         $selectPart = $select->getQueryPart('select');
         $selectPart = 'SQL_CALC_FOUND_ROWS ' . current($selectPart);
         $select->select($selectPart);
         $select->setLimit($limit);
         $select->setOffset($offset);
     }
     $result = $select->execute('\\Application\\Test\\Row');
     if ($limit) {
         $total = Db::fetchOne('SELECT FOUND_ROWS()');
     } else {
         $total = sizeof($result);
     }
     if (sizeof($result) < $total && Request::METHOD_GET == Request::getMethod()) {
         Response::setStatusCode(206);
         Response::setHeader('Content-Range', 'items ' . $offset . '-' . ($offset + sizeof($result)) . '/' . $total);
     }
     return $result;
 }
开发者ID:Kit-kat1,项目名称:bluz,代码行数:30,代码来源:Crud.php


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