本文整理汇总了PHP中Symfony\Component\HttpFoundation\ParameterBag::all方法的典型用法代码示例。如果您正苦于以下问题:PHP ParameterBag::all方法的具体用法?PHP ParameterBag::all怎么用?PHP ParameterBag::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\ParameterBag
的用法示例。
在下文中一共展示了ParameterBag::all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: overrideGlobals
/**
* Overrides the PHP global variables according to this request instance.
*
* It overrides $_GET, $_POST, $_REQUEST, $_SERVER, $_COOKIE.
* $_FILES is never override, see rfc1867
*
* @api
*/
public function overrideGlobals()
{
$_GET = $this->query->all();
$_POST = $this->request->all();
$_SERVER = $this->server->all();
$_COOKIE = $this->cookies->all();
foreach ($this->headers->all() as $key => $value) {
$key = strtoupper(str_replace('-', '_', $key));
if (in_array($key, array('CONTENT_TYPE', 'CONTENT_LENGTH'))) {
$_SERVER[$key] = implode(', ', $value);
} else {
$_SERVER['HTTP_'.$key] = implode(', ', $value);
}
}
$request = array('g' => $_GET, 'p' => $_POST, 'c' => $_COOKIE);
$requestOrder = ini_get('request_order') ?: ini_get('variable_order');
$requestOrder = preg_replace('#[^cgp]#', '', strtolower($requestOrder)) ?: 'gp';
$_REQUEST = array();
foreach (str_split($requestOrder) as $order) {
$_REQUEST = array_merge($_REQUEST, $request[$order]);
}
}
示例2: testReplace
public function testReplace()
{
$bag = new ParameterBag(array('foo' => 'bar'));
$bag->replace(array('FOO' => 'BAR'));
$this->assertEquals(array('FOO' => 'BAR'), $bag->all(), '->replace() replaces the input with the argument');
$this->assertFalse($bag->has('foo'), '->replace() overrides previously set the input');
}
示例3: getValues
/**
* Get Values by the Query String with the option of
* Remove some of them
*
* @param array $valuesToRemove
* @return array Values to Get
*/
private function getValues(array $valuesToRemove = array())
{
$values = array();
foreach (array_diff_key($this->query->all(), $valuesToRemove) as $property => $value) {
$values[$this->resource->getProperties()->get($property)->getInternalName()] = $value;
}
return $values;
}
示例4: updatesAfterUnset
/**
* Update every helpers and every registered renderer adapters with the right AbstractRenderer;
* this method is called everytime we unset a renderer
*/
protected function updatesAfterUnset()
{
$this->updateHelpers();
foreach ($this->rendererAdapters->all() as $ra) {
$ra->onRestorePreviousRenderer($this);
}
return $this;
}
示例5: it_throws_an_exception_for_an_invalid_request
public function it_throws_an_exception_for_an_invalid_request(Request $request, ParameterBag $post, ParameterBag $get)
{
$request->request = $post;
$request->query = $get;
$post->all()->willReturn([]);
$get->all()->willReturn(['text' => 'Hello!']);
$this->shouldThrow()->during('convert', [$request]);
}
示例6: transform
public function transform(ParameterBag $item)
{
foreach ($item->all() as $key => $value) {
// if value is an array with a hash, that's a serialized node's text value
if (is_array($value) && array_key_exists('#', $value)) {
$item->set($key, $value['#']);
}
}
}
示例7: getResponseCookie
/**
* Get the response header.
*
* @param string $key
*
* @return mixed
*/
public function getResponseCookie($key = null, $default = null)
{
if (!isset($this->cookie)) {
$this->cookie = new ParameterBag();
}
if (is_null($key)) {
return $this->cookie->all();
}
return $this->cookie->get($key, $default);
}
示例8: initializeHeaders
protected function initializeHeaders()
{
$headers = array();
foreach ($this->server->all() as $key => $value) {
if ('http_' === strtolower(substr($key, 0, 5))) {
$headers[substr($key, 5)] = $value;
}
}
return $headers;
}
示例9: _pageUrl
/**
* @param string $url
* @param \Symfony\Component\HttpFoundation\ParameterBag $params
*
* @return string
*/
private function _pageUrl($url, ParameterBag $params)
{
if (!$url) {
return '';
}
$allParams = $params->all();
unset($allParams['page']);
$strParams = http_build_query($allParams);
return $url . '&' . $strParams;
}
示例10: it_handles_authorization_refusal
public function it_handles_authorization_refusal(AuthorizeControllerInterface $oauth2AuthorizeController, ParameterBag $requestBag, Application $app, Request $request, TokenStorageInterface $tokenStorage)
{
$app->offsetGet('security.token_storage')->willReturn($tokenStorage);
$requestBag->all()->willReturn(['authorize' => '0']);
$responseArgument = Argument::type('OAuth2\\HttpFoundationBridge\\Response');
$requestArgument = Argument::type('OAuth2\\HttpFoundationBridge\\Request');
$oauth2AuthorizeController->handleAuthorizeRequest($requestArgument, $responseArgument, false, null)->shouldBeCalled();
$response = $this->__invoke($app, $request);
$response->shouldHaveType('OAuth2\\HttpFoundationBridge\\Response');
$response->getStatusCode()->shouldReturn(200);
}
示例11: verifySignature
protected function verifySignature()
{
$signer = new Signer($this->params->all());
$signer->setSort($this->sort);
$signer->setEncodePolicy($this->encodePolicy);
$content = $signer->getContentToSign();
$sign = $this->params->get('sign');
$match = (new Signer())->verifyWithRSA($content, $sign, $this->getAlipayPublicKey());
if (!$match) {
throw new InvalidRequestException('The signature is not match');
}
}
示例12: it_renders_authenticated_authorize_view
public function it_renders_authenticated_authorize_view(UrlGeneratorInterface $urlGenerator, AuthorizeControllerInterface $oauth2AuthorizeController, AuthorizeRenderer $authorizeRenderer, Application $app, Request $request, ParameterBag $queryBag, BridgeResponse $response, TokenStorageInterface $tokenStorage, TokenInterface $token)
{
$responseArgument = Argument::type('OAuth2\\HttpFoundationBridge\\Response');
$requestArgument = Argument::type('OAuth2\\HttpFoundationBridge\\Request');
$oauth2AuthorizeController->validateAuthorizeRequest($requestArgument, $responseArgument)->willReturn(true);
$urlGenerator->generate('oauth2_authorize_handler', Argument::any())->willReturn('/url');
$queryBag->all()->willReturn(['client_id' => 'clientId', 'response_type' => 'responseType']);
$app->offsetGet('security.token_storage')->willReturn($tokenStorage);
$tokenStorage->getToken()->willReturn($token);
$token->getUser()->willReturn('user');
$authorizeRenderer->render('/url', 'clientId', 'responseType', 'user')->willReturn($response);
$this->__invoke($app, $request)->shouldReturn($response);
}
示例13: overrideGlobals
/**
* Overrides the PHP global variables according to this request instance.
*
* It overrides $_GET, $_POST, $_REQUEST, $_SERVER, $_COOKIE, and $_FILES.
*/
public function overrideGlobals()
{
$_GET = $this->query->all();
$_POST = $this->request->all();
$_SERVER = $this->server->all();
$_COOKIE = $this->cookies->all();
// FIXME: populate $_FILES
foreach ($this->headers->all() as $key => $value) {
$_SERVER['HTTP_' . strtoupper(str_replace('-', '_', $key))] = implode(', ', $value);
}
// FIXME: should read variables_order and request_order
// to know which globals to merge and in which order
$_REQUEST = array_merge($_GET, $_POST);
}
示例14:
function it_returns_grid_data_for_non_html_requests(RequestConfiguration $requestConfiguration, RepositoryInterface $repository, Grid $gridDefinition, GridProviderInterface $gridProvider, ResourceGridViewFactoryInterface $gridViewFactory, ResourceGridView $gridView, Pagerfanta $paginator, MetadataInterface $metadata, Request $request, ParameterBag $queryParameters)
{
$requestConfiguration->hasGrid()->willReturn(true);
$requestConfiguration->getGrid()->willReturn('sylius_admin_tax_category');
$requestConfiguration->getMetadata()->willReturn($metadata);
$requestConfiguration->isHtmlRequest()->willReturn(false);
$requestConfiguration->getRequest()->willReturn($request);
$request->query = $queryParameters;
$queryParameters->all()->willReturn(['foo' => 'bar']);
$gridProvider->get('sylius_admin_tax_category')->willReturn($gridDefinition);
$gridViewFactory->create($gridDefinition, Argument::type(Parameters::class), $metadata, $requestConfiguration)->willReturn($gridView);
$gridView->getData()->willReturn($paginator);
$this->getResources($requestConfiguration, $repository)->shouldReturn($paginator);
}
示例15: transform
/**
* @inheritdoc
*/
public function transform(ParameterBag $item)
{
if (!$this->field) {
// expand root-level attributes
$item->replace($this->expand($item->all()));
return;
}
// proceed only when the field exists and is an array
$value = $item->get($this->field);
if (!is_array($value)) {
return;
}
$item->set($this->field, $this->expand($value));
}