• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Proxy\Request类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: createOne

 /**
  * @param array $data
  * @throws Exception
  * @throws \Bluz\Request\RequestException
  * @return integer
  */
 public function createOne($data)
 {
     /** @var \Bluz\Http\File $file */
     $file = Request::getFileUpload()->getFile('image');
     if (!$file or $file->getErrorCode() != UPLOAD_ERR_OK) {
         if (!$file || $file->getErrorCode() == UPLOAD_ERR_NO_FILE) {
             throw new Exception('Please choose file to upload');
         }
         throw new Exception('Sorry I can`t receive file');
     }
     $filename = $file->getName();
     $name = explode(".", $filename);
     $name[0] = uniqid($name[0]);
     $filename = implode(".", $name);
     $file->setName($filename);
     $file->moveTo($this->uploadDir);
     $data['file'] = $this->uploadDir . '/' . $file->getFullName();
     $data['type'] = $file->getMimeType();
     $row = $this->getTable()->create();
     $row->setFromArray($data);
     return $row->save();
 }
开发者ID:Kit-kat1,项目名称:custom-bluz-app,代码行数:28,代码来源:Crud.php


示例17: upload

 /**
  * @param array $data
  * @throws Exception
  * @throws \Bluz\Request\RequestException
  * @return integer
  */
 public function upload()
 {
     /** @var \Bluz\Http\File $file */
     $file = Request::getFileUpload()->getFile('files');
     $type = $file->getType();
     $row = new \Application\MusicianImage\Row();
     $row->getTable()->create();
     $row->setFromArray(['type' => $type]);
     $row->beforeSave();
     $row->afterSave();
     if (!$file or $file->getErrorCode() != UPLOAD_ERR_OK) {
         if (!$file || $file->getErrorCode() == UPLOAD_ERR_NO_FILE) {
             throw new Exception('Please choose file to upload');
         }
         throw new Exception('Sorry I can`t receive file');
     }
     $name = uniqid();
     $filename = $name . "." . $file->getExtension();
     $file->setName($name);
     $file->moveTo($this->uploadDir);
     Session::set('image', $filename);
     return $file;
 }
开发者ID:Kit-kat1,项目名称:bluz,代码行数:29,代码来源:Upload.php


示例18: createOne

 public function createOne()
 {
     //get saved data
     $existFilesData = Session::get('files');
     $files = unserialize($existFilesData);
     //get paths to upload directory
     $path = Config::getModuleData('menu', 'full_path');
     $relativePath = Config::getModuleData('menu', 'relative_path');
     //get new file,that saved in /tmp directory
     $newFileData = Request::getFileUpload()->getFile('files');
     $editor = new Manager($newFileData, $path);
     //validate file name
     $editor->renameFileName();
     //merge new and exist files data
     if ($existFilesData) {
         $fileObjects = $files;
         $fileObjects[uniqid()] = $editor->getFile();
     } else {
         $fileObjects = [uniqid() => $editor->getFile()];
     }
     Session::set('files', serialize($fileObjects));
     $file = $editor->getFile();
     return array('id' => array_search($editor->getFile(), $fileObjects), 'path' => $relativePath . $file->getName() . '.' . $file->getExtension());
 }
开发者ID:bobrofor,项目名称:menuProject,代码行数:24,代码来源:FileCrud.php


示例19: resetApp

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


示例20: processRequest

 /**
  * Process request
  *
  * Example of request url
  * - http://domain.com/pages/grid/
  * - http://domain.com/pages/grid/page/2/
  * - http://domain.com/pages/grid/page/2/order-alias/desc/
  * - http://domain.com/pages/grid/page/2/order-created/desc/order-alias/asc/
  *
  * with prefix for support more than one grid on page
  * - http://domain.com/users/grid/users-page/2/users-order-created/desc/
  * - http://domain.com/users/grid/users-page/2/users-filter-status/active/
  *
  * hash support
  * - http://domain.com/pages/grid/#/page/2/order-created/desc/order-alias/asc/
  *
  * @return Grid
  */
 public function processRequest()
 {
     $this->module = Request::getModule();
     $this->controller = Request::getController();
     $page = Request::getParam($this->prefix . 'page', 1);
     $this->setPage($page);
     $limit = Request::getParam($this->prefix . 'limit', $this->limit);
     $this->setLimit($limit);
     foreach ($this->allowOrders as $column) {
         $order = Request::getParam($this->prefix . 'order-' . $column);
         if ($order) {
             $this->addOrder($column, $order);
         }
     }
     foreach ($this->allowFilters as $column) {
         $filter = Request::getParam($this->prefix . 'filter-' . $column);
         if ($filter) {
             if (strpos($filter, '-')) {
                 $filter = trim($filter, ' -');
                 while ($pos = strpos($filter, '-')) {
                     $filterType = substr($filter, 0, $pos);
                     $filter = substr($filter, $pos + 1);
                     if (strpos($filter, '-')) {
                         $filterValue = substr($filter, 0, strpos($filter, '-'));
                         $filter = substr($filter, strpos($filter, '-') + 1);
                     } else {
                         $filterValue = $filter;
                     }
                     $this->addFilter($column, $filterType, $filterValue);
                 }
             } else {
                 $this->addFilter($column, self::FILTER_EQ, $filter);
             }
         }
     }
     return $this;
 }
开发者ID:bluzphp,项目名称:framework,代码行数:55,代码来源:Grid.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Bolt\Library类代码示例发布时间:2022-05-23
下一篇:
PHP models\User类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap