本文整理匯總了PHP中Bluz\Proxy\Request::setParam方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::setParam方法的具體用法?PHP Request::setParam怎麽用?PHP Request::setParam使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Bluz\Proxy\Request
的用法示例。
在下文中一共展示了Request::setParam方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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());
}
示例2: processRoute
/**
* Process router by default rules
*
* Default routers examples
* /
* /:module/
* /:module/:controller/
* /:module/:controller/:key1/:value1/:key2/:value2...
*
* @return bool
*/
protected function processRoute()
{
$uri = Request::getCleanUri();
$uri = trim($uri, '/');
$params = explode('/', $uri);
if (sizeof($params)) {
Request::setModule(array_shift($params));
}
if (sizeof($params)) {
Request::setController(array_shift($params));
}
if ($size = sizeof($params)) {
// save raw params
Request::setRawParams($params);
// remove tail
if ($size % 2 == 1) {
array_pop($params);
$size = sizeof($params);
}
// or use array_chunk and run another loop?
for ($i = 0; $i < $size; $i = $i + 2) {
Request::setParam($params[$i], $params[$i + 1]);
}
}
return true;
}
示例3: testReadRecordError
/**
* GET with invalid PRIMARY should return ERROR
* @expectedException \Bluz\Application\Exception\NotFoundException
*/
public function testReadRecordError()
{
Request::setMethod(Request::METHOD_GET);
Request::setParam('id', 100042);
$this->processCrud();
}