本文整理汇总了PHP中Zend\Http\PhpEnvironment\Request::setPost方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::setPost方法的具体用法?PHP Request::setPost怎么用?PHP Request::setPost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Http\PhpEnvironment\Request
的用法示例。
在下文中一共展示了Request::setPost方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Parameters
/**
* Test if objects are being passed the service locator
*/
function testServiceLocatorAwareMustBeGivenServiceLocator()
{
$this->request->setPost(new Parameters(array('extAction' => 'KJSenchaTestAsset.Direct.ServiceAction', 'extMethod' => 'getServiceResult', 'extTID' => 0, 'extModule' => null)));
$this->controller->setDebugMode(true);
$result = $this->controller->dispatch($this->request);
$this->assertEquals('pong!', $result->result);
}
示例2: testShowErrorResponseWhenDebugModeIsOn
/**
* @covers \KJSencha\Controller\DirectController::setDebugMode
* @covers \KJSencha\Controller\DirectController::isDebugMode
*/
function testShowErrorResponseWhenDebugModeIsOn()
{
$this->request->setPost(new Parameters(array('extAction' => 'KJSenchaTestAsset.Direct.ErrorGenerator', 'extMethod' => 'throwException', 'extTID' => 0, 'extModule' => null)));
$this->controller->setDebugMode(true);
$result = $this->controller->dispatch($this->request);
$this->assertEquals('exception', $result->type);
$this->assertEquals('Exception!', $result->message);
$this->assertNotEmpty($result->where);
}
示例3: testGridData
public function testGridData()
{
$entityClassName = '\\SynergyDataGridTest\\Entity\\TestBrand';
$this->_grid->setGridIdentity($entityClassName);
$this->_grid->setCustomQueryBuilder(new QueryBuilder($this->_grid->getModel()->getEntityManager()));
$this->_grid->setDatatype('local');
$this->_grid->getOptions();
$params = array('page' => 1, 'rows' => 25, 'sord' => 'asc', 'sidx' => 'id', BaseGrid::GRID_IDENTIFIER => $this->_grid->getId(), BaseGrid::ENTITY_IDENTFIER => $this->_grid->getEntity());
$request = new Request();
$parameters = new Parameters($params);
$request->setPost($parameters);
$this->_grid->prepareGridData($request);
/** @var $viewHelper \SynergyDataGrid\View\Helper\DisplayGrid */
$viewHelper = $this->_serviceManager->get('viewhelpermanager')->get('displayGrid');
$viewHelper->setView(new PhpRenderer());
$data = $viewHelper($this->_grid, false);
$this->assertArrayHasKey('html', $data);
$this->assertArrayHasKey('js', $data);
$this->assertArrayHasKey('onLoad', $data);
}
示例4: testIndexAction_WithValidPostRequest
public function testIndexAction_WithValidPostRequest()
{
$postData = array('name' => uniqid('name'), 'email' => uniqid('email') . '@' . uniqid('host') . '.com.pl');
$request = new Request();
$request->setMethod(Request::METHOD_POST);
$request->setPost(new Parameters($postData));
$this->formMock->expects($this->once())->method('setData')->with($postData);
$this->formMock->expects($this->once())->method('isValid')->willReturn(true);
$registerInputFilter = new RegisterInputFilter();
$registerInputFilter->add(array('name' => 'captcha'));
$this->formMock->expects($this->once())->method('getInputFilter')->willReturn($registerInputFilter);
$this->serviceMock->expects($this->once())->method('proceed');
$result = $this->controller->dispatch($request);
$expected = array('form' => $this->formMock);
$this->assertResponseStatusCode(Response::STATUS_CODE_200);
$this->assertSame($expected, $result);
// TODO: reactivate
//$fm = $this->controller->flashMessenger();
//$fm->setNamespace(Notification::NAMESPACE_SUCCESS);
//$expectedMessages = array(
// 'An Email with an activation link has been sent, please try to check your email box'
//);
//$this->assertSame($expectedMessages, $fm->getCurrentMessages());
}
示例5: testRetrievingASingleValueForParameters
public function testRetrievingASingleValueForParameters()
{
$request = new Request();
$p = new \Zend\Stdlib\Parameters(array('foo' => 'bar'));
$request->setQuery($p);
$request->setPost($p);
$request->setFiles($p);
$request->setServer($p);
$request->setEnv($p);
$this->assertSame('bar', $request->getQuery('foo'));
$this->assertSame('bar', $request->getPost('foo'));
$this->assertSame('bar', $request->getFiles('foo'));
$this->assertSame('bar', $request->getServer('foo'));
$this->assertSame('bar', $request->getEnv('foo'));
$headers = new Headers();
$h = new GenericHeader('foo', 'bar');
$headers->addHeader($h);
$request->setHeaders($headers);
$this->assertSame($headers, $request->getHeaders());
$this->assertSame($h, $request->getHeaders()->get('foo'));
$this->assertSame($h, $request->getHeader('foo'));
}
示例6: login
/**
* @param $request
* @return array|mixed|User
* @throws \Exception
*/
public function login($request)
{
$adapter = $this->getAuthPlugin()->getAuthAdapter();
$pin = $request->get('pin');
$accountId = $request->get('accountId');
if (!empty($pin)) {
$user = $this->getUserByPin($pin, $accountId);
$credentials = array('username' => $user->getUsername(), 'password' => $user->getPassword());
} else {
$credentials = array('username' => $request->get('username'), 'password' => $request->get('password'));
}
$params = new Parameters();
$params->set('identity', $credentials['username']);
$params->set('credential', $credentials['password']);
$emulatedRequest = new Request();
$emulatedRequest->setPost($params);
$result = $adapter->prepareForAuthentication($emulatedRequest);
if ($result instanceof Response) {
return $result;
}
$auth = $this->getAuthPlugin()->getAuthService()->authenticate($adapter);
if (!$auth->isValid()) {
$isRegistered = $this->isRegistered($credentials);
$accountUser = $this->getAccountUsersByParams($params);
if ($accountUser != null && !$isRegistered) {
if ($this->getAgencyIsDeleted($accountUser->getAccountId())) {
throw new \Exception(self::AGENCY_DELETED_MESSAGE);
}
return $this->createUserFromAccountUsers($accountUser);
}
$account = $this->getAccountByParams($params);
if ($account != null && !$isRegistered) {
return $this->createUserFromAccount($account);
}
if ($accountUser != null && $isRegistered) {
return $this->updateUser($accountUser);
}
$result = $auth->getMessages();
$message = "Bad request.";
if (isset($result[0])) {
$message = $result[0];
}
throw new \Exception($message);
}
$accountUser = $this->getAccountUsersByParams($params);
if ($this->getAgencyIsDeleted($accountUser->getAccountId())) {
throw new \Exception(self::AGENCY_DELETED_MESSAGE);
}
if ($this->getUserIsDeleted($credentials['username'])) {
throw new \Exception(self::USER_DELETED_MESSAGE);
}
$user = $this->getAuthPlugin()->getIdentity();
return $user;
}
示例7: testIndexAction_WithPostRequest
public function testIndexAction_WithPostRequest()
{
$postData = array('identity' => uniqid('identity'));
$request = new Request();
$request->setMethod(Request::METHOD_POST);
$request->setPost(new Parameters($postData));
$this->formMock->expects($this->once())->method('setData')->with($postData);
$this->formMock->expects($this->once())->method('isValid')->willReturn(true);
$this->formMock->expects($this->once())->method('getInputFilter')->willReturn(new ForgotPasswordInputFilter());
$this->serviceMock->expects($this->once())->method('proceed');
$result = $this->controller->dispatch($request);
$expected = array('form' => $this->formMock);
$this->assertResponseStatusCode(Response::STATUS_CODE_200);
$this->assertSame($expected, $result);
//$fm = $this->controller->flashMessenger();
//$fm->setNamespace(Notification::NAMESPACE_SUCCESS);
//$expectedMessages = array(
// 'Mail with link for reset password has been sent, please try to check your email box'
//);
//$this->assertSame($expectedMessages, $fm->getCurrentMessages());
}
示例8: testIndexAction_WithPostRequest
public function testIndexAction_WithPostRequest()
{
$postData = array('valid data');
$request = new Request();
$request->setMethod(Request::METHOD_POST);
$request->setPost(new Parameters($postData));
$userEntity = UserEntityProvider::createEntityWithRandomData();
$this->authenticationServiceMock->expects($this->once())->method('getUser')->willReturn($userEntity);
$this->formMock->expects($this->once())->method('bind')->with($userEntity);
$this->formMock->expects($this->once())->method('setData')->with($postData);
$this->formMock->expects($this->once())->method('isValid')->willReturn(true);
$this->repositoriesMock->expects($this->once())->method('store')->with($userEntity);
$result = $this->controller->dispatch($request);
$expected = array('valid' => true, 'form' => $this->formMock);
$this->assertResponseStatusCode(Response::STATUS_CODE_200);
$this->assertSame($expected, $result);
}
示例9: initGrid
public function initGrid(BaseGrid $grid)
{
$html = array();
$js = array();
$onLoad = array();
$postCommand = array();
$showToolbar = false;
$jsPager = '';
$htmlPager = '';
$config = $grid->getConfig();
$gridId = $grid->getId();
$grid->setActionsColumn($config['add_action_column']);
$grid->setGridColumns()->setGridDisplayOptions()->setAllowEditForm($config['allow_form_edit']);
$onLoad[] = 'var ' . $grid->getLastSelectVariable() . '; ';
$onLoad[] = sprintf('var obj_%s = jQuery("#%s").addClass("synergy-grid").data("padding", %d);', $gridId, $gridId, $grid->getJsCode()->getPadding());
$onLoad[] = sprintf('obj_%s.parent().addClass("%s");', $gridId, $grid->getJsCode()->getContainerClass());
$onLoad[] = sprintf('obj_%s.data("lastsel", 0);', $gridId);
if (!$grid->getEditurl()) {
$grid->setEditurl($grid->getUrl());
}
//add custom toolbar buttons
list(, $toolbarPosition) = $grid->getToolbar();
if (!($showToolbar = ($config['toolbar_buttons']['global'] or isset($config['toolbar_buttons']['specific'][$grid->getEntityId()])))) {
$grid->setToolbar(false);
}
//get previous sort order from cookie if set
$grid->prepareSorting();
//get number per page if set in cookie
$grid->preparePaging();
//load first data for main grid and not subgrids
if ($config['first_data_as_local'] and !$grid->getIsDetailGrid()) {
$grid->setDatatype('local');
$gridOptions = $grid->getOptions();
$params = array('page' => 1, 'rows' => $gridOptions['rowNum'], $grid::GRID_IDENTIFIER => $grid->getId(), $grid::ENTITY_IDENTFIER => $grid->getEntity());
if ($grid->getIsTreeGrid()) {
$grid->setSortname('lft');
$params['displayTree'] = true;
if (isset($gridOptions['postData'])) {
$params = array_merge($params, $gridOptions['postData']);
}
}
$request = new Request();
$parameters = new Parameters($params);
$request->setPost($parameters);
$initialData = $grid->getFirstDataAsLocal($request, true);
$postCommand[] = sprintf('obj_%s.jqGrid("setGridParam", {datatype:"json", treedatatype : "json"});', $gridId, $grid->getEditurl());
$postCommand[] = sprintf('obj_%s[0].addJSONData(%s) ;', $gridId, Json::encode($initialData));
}
$grid->getJsCode()->prepareAfterInsertRow();
$grid->getJsCode()->prepareAfterSaveRow();
$grid->getJsCode()->prepareOnEditRow();
$grid->getJsCode()->prepareAfterRestoreRow();
if ($grid->getAllowResizeColumns()) {
$grid->prepareColumnSizes();
}
//Add subgrid as grid data. This will override any subgrid
if ($grid instanceof SubGridAwareInterface and $subGrids = $grid->getSubGridsAsGrid()) {
$l = $s = $h = array();
foreach ($subGrids as $subGrid) {
list($l[], $s[], $h[]) = $this->initGrid($subGrid);
}
$expandFunction = new Expr(sprintf("function(subgrid_id, row_id) {\n jQuery('#'+subgrid_id).html('%s');\n %s\n %s\n }", implode("<hr />", $h), implode("\n", $l), implode("\n", $s)));
/** @var $grid \SynergyDataGrid\Grid\GridType\BaseGrid */
$grid->setSubGridRowExpanded($expandFunction);
}
$onLoad[] = $grid->getJsCode()->prepareSetColumnsOrderingCookie();
$grid->reorderColumns();
$onLoad[] = sprintf('obj_%s.jqGrid(%s);', $gridId, Json::encode($grid->getOptions(), false, array('enableJsonExprFinder' => true)));
$datePicker = $grid->getDatePicker()->prepareDatepicker();
$js = array_merge($js, $datePicker);
$html[] = '<table id="' . $gridId . '"></table>';
if ($grid->getNavGridEnabled()) {
if ($grid->getIsDetailGrid()) {
$grid->getNavGrid()->setSearch(false);
}
$options = $grid->getNavGrid()->getOptions() ?: new \stdClass();
$prmEdit = $grid->getNavGrid()->getEditParameters() ?: new \stdClass();
$prmAdd = $grid->getNavGrid()->getAddParameters() ?: new \stdClass();
$prmDel = $grid->getNavGrid()->getDeleteParameters() ?: new \stdClass();
$prmSearch = $grid->getNavGrid()->getSearchParameters() ?: new \stdClass();
$prmView = $grid->getNavGrid()->getViewParameters() ?: new \stdClass();
$jsPager = sprintf('obj_%s.jqGrid("navGrid","#%s",%s,%s,%s,%s,%s,%s);', $gridId, $grid->getPager(), Json::encode($options, false, array('enableJsonExprFinder' => true)), Json::encode($prmEdit, false, array('enableJsonExprFinder' => true)), Json::encode($prmAdd, false, array('enableJsonExprFinder' => true)), Json::encode($prmDel, false, array('enableJsonExprFinder' => true)), Json::encode($prmSearch, false, array('enableJsonExprFinder' => true)), Json::encode($prmView, false, array('enableJsonExprFinder' => true)));
//display filter toolbar
if ($config['filter_toolbar']['enabled']) {
$onLoad[] = sprintf('obj_%s.jqGrid("filterToolbar",%s);', $gridId, Json::encode($config['filter_toolbar']['options'], false, array('enableJsonExprFinder' => true)));
if (!$config['filter_toolbar']['showOnLoad']) {
$onLoad[] = sprintf('obj_%s[0].toggleToolbar();', $gridId);
}
}
$navButtons = $grid->getNavButtons();
if (is_array($navButtons)) {
foreach ($navButtons as $title => $button) {
$jsPager .= sprintf('obj_%s.navButtonAdd("#%s",{
caption: "%s",
title: "%s",
buttonicon: "%s",
onClickButton: %s,
position: "%s",
cursor: "%s",
id: "%s"
//.........这里部分代码省略.........