本文整理匯總了PHP中Symfony\Component\HttpFoundation\ParameterBag::get方法的典型用法代碼示例。如果您正苦於以下問題:PHP ParameterBag::get方法的具體用法?PHP ParameterBag::get怎麽用?PHP ParameterBag::get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\HttpFoundation\ParameterBag
的用法示例。
在下文中一共展示了ParameterBag::get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: it_should_change_controller_attribute_to_use_service
/**
* @test
*/
public function it_should_change_controller_attribute_to_use_service()
{
$this->attributes->set('_controller', 'stdClass::method');
$this->given_controller_is_annotated_by_injectable_annotation();
$this->listener->onKernelController($this->getEvent());
$this->assertEquals('stdClass:method', $this->attributes->get('_controller'));
}
示例2: update
private function update(Note $note, ParameterBag $parameters)
{
$note->setTitle($parameters->get('title'));
$note->setColor($parameters->get('color'));
$note->setContent($parameters->get('content'));
return $note;
}
示例3: update
/**
* @param ParameterBag $params
*
* @return boolean
*/
public function update($params)
{
$entity = $this->rGet($params->get('id'));
$entity->setName($params->get('name'));
$entity->setGeneral($params->get('general'));
$this->merge($entity);
}
示例4: checkCopyAddress
/**
* Copies billing address to shipping address
*
* @param ParameterBag $parameters
*/
protected function checkCopyAddress(ParameterBag $parameters)
{
if (1 === (int) $parameters->get('copyAddress')) {
$billingAddress = $parameters->get('billingAddress');
$parameters->set('shippingAddress', ['shippingAddress.firstName' => $billingAddress['billingAddress.firstName'], 'shippingAddress.lastName' => $billingAddress['billingAddress.lastName'], 'shippingAddress.street' => $billingAddress['billingAddress.street'], 'shippingAddress.streetNo' => $billingAddress['billingAddress.streetNo'], 'shippingAddress.flatNo' => $billingAddress['billingAddress.flatNo'], 'shippingAddress.city' => $billingAddress['billingAddress.city'], 'shippingAddress.postCode' => $billingAddress['billingAddress.postCode'], 'shippingAddress.country' => $billingAddress['billingAddress.country']]);
}
}
示例5: handle
/**
* @param Request $request
* @param int $type
* @param bool $catch
*
* @return Response
* @throws \Exception
*/
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
{
if ($type === HttpKernelInterface::SUB_REQUEST) {
return $this->app->handle($request, $type, $catch);
}
$parameters = $this->config->get('cookie_parameters');
if (!isset($parameters[$this->config->get('current_locale')])) {
throw new \Exception(sprintf('Domain %s not available', $this->config->get('current_locale')));
}
$cookieParams = $parameters[$this->config->get('current_locale')];
$this->config->set('current_cookie_domain', $cookieParams['domain']);
if (HttpKernelInterface::MASTER_REQUEST !== $type) {
return $this->app->handle($request, $type, $catch);
}
$session = new Session();
$request->setSession($session);
$cookies = $request->cookies;
if ($cookies->has($session->getName())) {
$session->setId($cookies->get($session->getName()));
} else {
//starts the session if no session exists
$session->start();
$session->migrate(false);
}
$session->start();
$response = $this->app->handle($request, $type, $catch);
if ($session && $session->isStarted()) {
$session->save();
$params = array_merge(session_get_cookie_params(), $cookieParams);
$cookie = new Cookie($session->getName(), $session->getId(), 0 === $params['lifetime'] ? 0 : $request->server->get('REQUEST_TIME') + $params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly']);
$response->headers->setCookie($cookie);
}
return $response;
}
示例6: testUpdateResponsePage
public function testUpdateResponsePage()
{
$this->page->getCacheLifeTime()->willReturn('300');
$this->page->getUuid()->willReturn('1234');
$this->handler->updateResponse($this->response->reveal(), $this->page->reveal());
$this->assertEquals('300', $this->parameterBag->get(DebugHandler::HEADER_STRUCTURE_TTL));
}
示例7: update
/**
* @param ParameterBag $params
*
* @return boolean
*/
public function update($params)
{
/** @var ClientDirection $entity */
$entity = $this->rGet($params->get('id'));
$entity->setName($params->get('name'));
$this->merge($entity);
}
示例8: buildTopNavMenu
private final function buildTopNavMenu(ParameterBag $parameterBag)
{
static $tabDataContent = null;
if (null === $tabDataContent) {
$yamlParser = new Parser();
$yamlNavigationPath = __DIR__ . '/../Resources/config/admin/navigation.yml';
$tabConfiguration = $yamlParser->parse(file_get_contents($yamlNavigationPath));
$explodedControllerInfo = explode('::', $parameterBag->get('_controller'));
$explodedControllerName = explode('\\', $explodedControllerInfo[0]);
$controllerNameIndex = count($explodedControllerName) - 1;
$controllerName = $explodedControllerName[$controllerNameIndex];
if (isset($tabConfiguration[$controllerName])) {
// Construct tabs and inject into twig tpl
$tabDataContent = array();
// Get current route name to know when to put "current" class on HTML dom
$currentRouteName = $parameterBag->get('_route');
foreach ($tabConfiguration[$controllerName] as $tabName => $tabData) {
$tabData['isCurrent'] = false;
if ($currentRouteName === $tabData['route']) {
$tabData['isCurrent'] = true;
}
$tabDataContent[] = $this->environment->render('PrestaShopBundle:Admin/Common/_partials:_header_tab.html.twig', array('tabData' => $tabData));
}
// Inject them to templating system as global to be able to pass it to the legacy afterwards and once
// controller has given a response
}
}
return $tabDataContent;
}
示例9: update
/**
* @param ParameterBag $params
*
* @return boolean
*/
public function update($params)
{
/** @var Office $entity */
$entity = $this->rGet($params->get('id'));
$entity->setCity($params->get('city'));
$entity->setName($params->get('name'));
$this->merge($entity);
}
示例10: createColumnMapping
protected function createColumnMapping(ParameterBag $query)
{
$mapping = [];
for ($i = 0; $i < $query->get('iColumns'); $i++) {
$mapping[$i] = $query->get("mDataProp_{$i}");
}
return $mapping;
}
示例11: testSet
/**
* @covers Symfony\Component\HttpFoundation\ParameterBag::set
*/
public function testSet()
{
$bag = new ParameterBag(array());
$bag->set('foo', 'bar');
$this->assertEquals('bar', $bag->get('foo'), '->set() sets the value of parameter');
$bag->set('foo', 'baz');
$this->assertEquals('baz', $bag->get('foo'), '->set() overrides previously set parameter');
}
示例12: update
/**
* @param ParameterBag $params
*
* @return boolean
*/
public function update($params)
{
/** @var Diagnosis $entity */
$entity = $this->rGet($params->get('id'));
$entity->setDescription($params->get('description'));
$entity->setPerson($params->get('person'));
$this->merge($entity);
}
示例13: MyService
function it_calls_the_service_with_configured_arguments(ContainerInterface $container, Request $request, ParameterBag $attributes)
{
$container->get('my_service')->willReturn(new MyService());
$configuration = new ParamConverter(['name' => 'foo', 'class' => MyArgument::class, 'options' => ['service' => 'my_service', 'method' => 'myMethod', 'arguments' => ['id', 'name']]]);
$attributes->get('id')->willReturn(42);
$attributes->get('name')->willReturn('Bob');
$attributes->set('foo', new MyArgument(42, 'Bob'))->shouldBeCalled();
$this->apply($request, $configuration);
}
示例14:
function it_throws_an_exception_if_no_repository_can_be_found($doctrine, Request $request, ParameterBag $query, \stdClass $repository)
{
$request->query = $query;
$query->get('search')->willReturn('hello');
$query->get('referenceDataName')->willReturn(null);
$query->get('class')->willReturn('Foo\\Bar');
$doctrine->getRepository('Foo\\Bar')->willReturn($repository);
$this->shouldThrow(new \LogicException('The repository of the class "Foo\\Bar" can not retrieve options via Ajax.'))->during('listAction', [$request]);
}
示例15: update
/**
* @param ParameterBag $params
*
* @return boolean
*/
public function update($params)
{
$application = $this->rGet($params->get('applicationId'));
$client = $this->rGet($params->get('clientId'));
$entity = $this->rGet($params->get('id'));
$entity->setApplication($application);
$entity->setClient($client);
$this->merge($entity);
}