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


PHP Request::getParam方法代码示例

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


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

示例1: 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

示例2: __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

示例3: 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

示例4: function

 * Grid of Media
 *
 * @author   Anton Shevchuk
 */
/**
 * @namespace
 */
namespace Application;

use Bluz\Proxy\Layout;
use Bluz\Proxy\Request;
use Bluz\Proxy\Response;
return function () use($view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::setTemplate('dashboard.phtml');
    Layout::breadCrumbs([$view->ahref('Dashboard', ['dashboard', 'index']), __('Media')]);
    $grid = new Media\Grid();
    $countCol = Request::getParam('countCol');
    if ($countCol != null) {
        Response::setCookie("countCol", $countCol, time() + 3600, '/');
    } else {
        $countCol = Request::getCookie('countCol', 4);
    }
    $lnCol = (int) (12 / $countCol);
    $view->countCol = $countCol;
    $view->col = $lnCol;
    $view->grid = $grid;
};
开发者ID:bobrofor,项目名称:menuProject,代码行数:31,代码来源:grid.php

示例5: 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

示例6: function

 * @accept HTML
 * @accept JSON
 * @privilege Management
 *
 * @param int $id
 * @return bool
 * @throws Exception
 */
return function ($id) {
    /**
     * @var Controller $this
     */
    $user = Users\Table::findRow($id);
    if (!$user) {
        throw new Exception('User ID is incorrect');
    }
    if (Request::isPost()) {
        $roles = Request::getParam('roles');
        // update roles
        Db::delete('acl_users_roles')->where('userId = ?', $user->id)->execute();
        foreach ($roles as $role) {
            Db::insert('acl_users_roles')->set('userId', $user->id)->set('roleId', $role)->execute();
        }
        // clean cache
        Cache::delete('user:' . $user->id);
        Messages::addSuccess('User roles was updated');
        return false;
    }
    $this->assign('user', $user);
    $this->assign('roles', Roles\Table::getInstance()->getRoles());
};
开发者ID:bluzphp,项目名称:skeleton,代码行数:31,代码来源:user.php

示例7: function

 * @accept JSON
 * @method GET
 *
 * @param  \Bluz\Crud\Table $crud
 * @param  mixed $primary
 * @return array
 */
return function ($crud, $primary) {
    if (!empty($primary)) {
        // @throws NotFoundException
        return [$crud->readOne($primary)];
    } else {
        $params = Request::getParams();
        // setup default offset and limit - safe way
        $offset = Request::getParam('offset', 0);
        $limit = Request::getParam('limit', 10);
        if ($range = Request::getHeader('Range')) {
            list(, $offset, $last) = preg_split('/[-=]/', $range);
            // for better compatibility
            $limit = $last - $offset;
        }
        Response::setStatusCode(206);
        $total = 0;
        $result = $crud->readSet($offset, $limit, $params, $total);
        if (sizeof($result) < $total) {
            Response::setStatusCode(206);
            Response::setHeader('Content-Range', 'items ' . $offset . '-' . ($offset + sizeof($result)) . '/' . $total);
        }
        return $result;
    }
};
开发者ID:bluzphp,项目名称:skeleton,代码行数:31,代码来源:get.php

示例8: testGet

 /**
  * Complex test for magic getter
  *
  * @covers \Bluz\Http\Request::getParam()
  */
 public function testGet()
 {
     $this->assertEquals('get', Request::getParam('get'));
     $this->assertEquals('post', Request::getParam('post'));
     $this->assertEquals('cookie', Request::getParam('cookie'));
     $this->assertEquals('server', Request::getParam('server'));
     $this->assertEquals('env', Request::getParam('env'));
     $this->assertNull(Request::getParam('some'));
 }
开发者ID:dezvell,项目名称:mm.local,代码行数:14,代码来源:RequestTest.php

示例9: function

 * @param string $id
 *
 * @route /api/{$resource}
 * @param string $resource
 *
 * @return mixed
 */
return function ($resource, $id, $relation, $relationId) {
    /**
     * @var Controller $this
     */
    $this->useJson();
    Auth::clearIdentity();
    try {
        // authentication by api token
        if ($token = Request::getParam('token')) {
            Table::getInstance()->authenticateToken($token);
        }
        $params = [];
        foreach ([$id, $relation, $relationId] as $param) {
            if (!is_null($param)) {
                $params[] = $param;
            }
        }
        return $this->dispatch('api', 'resources/' . $resource, $params);
    } catch (\Exception $e) {
        // process exceptions here
        Response::setStatusCode($e->getCode());
        return ['error' => $e->getMessage()];
    }
};
开发者ID:bluzphp,项目名称:skeleton,代码行数:31,代码来源:index.php

示例10: function

<?php

/**
 * Created by PhpStorm.
 * User: gunko
 * Date: 9/29/15
 * Time: 10:22 AM
 */
/**
 * @namespace
 */
namespace Application;

use Bluz\Controller;
use Bluz\Proxy\Request;
return function () {
    $str = Request::getParam('query');
    if ($str != NULL) {
        return $search = \Application\MusicTypes\Table::getInstance()->search($str);
    } else {
        return [];
    }
};
开发者ID:Kit-kat1,项目名称:bluz,代码行数:23,代码来源:search.php


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