本文整理汇总了PHP中Symfony\Component\HttpFoundation\ParameterBag类的典型用法代码示例。如果您正苦于以下问题:PHP ParameterBag类的具体用法?PHP ParameterBag怎么用?PHP ParameterBag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ParameterBag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: let
public function let(ParameterBag $attributes, Request $request, GetResponseEvent $event, ParameterStack $stack)
{
$event->getRequest()->willReturn($request);
$request->attributes = $attributes;
$attributes->get('_route_params', Argument::any())->willReturn(['foo' => 'bar', 'baz' => 2]);
$this->beConstructedWith($stack);
}
示例2: Response
/**
* @param \FSi\Bundle\AdminBundle\Admin\Context\Request\HandlerInterface $handler
* @param \Symfony\Component\HttpFoundation\Request $request
* @param \Symfony\Component\HttpFoundation\ParameterBag $requestParameterBag
*/
function it_return_response_from_handler($handler, $request, $requestParameterBag)
{
$handler->handleRequest(Argument::type('FSi\\Bundle\\AdminBundle\\Event\\FormEvent'), $request)->willReturn(new Response());
$request->request = $requestParameterBag;
$requestParameterBag->get('indexes', array())->willReturn(array());
$this->handleRequest($request)->shouldReturnAnInstanceOf('Symfony\\Component\\HttpFoundation\\Response');
}
示例3: configureActionsVars
public function configureActionsVars(ParameterBag $actionsVars)
{
if ($this->container->isScopeActive('request')) {
$adminSession = new AdminSession($this->container->get('request'), $this->container->get('session'), $this->getOption('sessionParameter'));
$actionsVars->set('admin_session', $adminSession);
}
}
示例4: 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);
}
示例5: let
public function let(ActionFactory $actionFactory, ActionEventManager $eventManager, ManagerRegistry $managerRegistry, ManagerInterface $manager, RouterInterface $router, TranslatorInterface $translator, MassActionDispatcher $massActionDispatcher, JobInstanceRepository $jobInstanceRepository, JobLauncherInterface $jobLauncher, TokenStorageInterface $tokenStorage, Request $request, ParameterBag $attributes, ConfigurationInterface $configuration, Session $session, FlashBag $flashBag)
{
$this->beConstructedWith($actionFactory, $eventManager, $managerRegistry, $router, $translator, $massActionDispatcher, $jobInstanceRepository, $jobLauncher, $tokenStorage);
// initialize configuration
$configuration->getEntityClass()->willReturn('entity_class');
$configuration->getName()->willReturn('entity');
// initialize manager
$managerRegistry->getFromConfiguration($configuration)->willReturn($manager);
// initialize router
$router->generate(Argument::type('string'), Argument::type('array'), Argument::any())->will(function ($arguments) {
$path = $arguments[0] . '?';
foreach ($arguments[1] as $key => $value) {
$path .= '&' . $key . '=' . $value;
}
return $path;
});
// initialize request
$request->attributes = $attributes;
$attributes->get('id')->willReturn('id');
// initialize flashbag
$request->getSession()->willReturn($session);
$session->getFlashBag()->willReturn($flashBag);
// initialize translator
$translator->trans(Argument::type('string'), Argument::any())->will(function ($arguments) {
if (!isset($arguments[1])) {
$arguments[1] = array();
}
$translated = sprintf('<%s>', $arguments[0]);
foreach ($arguments[1] as $key => $value) {
$translated .= sprintf('%s=%s;', $key, $value);
}
return $translated;
});
}
示例6: let
public function let(ActionFactory $actionFactory, ActionEventManager $eventManager, ManagerRegistry $managerRegistry, ManagerInterface $manager, RouterInterface $router, TranslatorInterface $translator, ConfigurationInterface $configuration, Request $request, ParameterBag $attributes, EngineInterface $templating, FormFactoryInterface $formFactory, FormInterface $form, FormView $formView, Entity $object, ActionInterface $indexAction)
{
$this->beConstructedWith($actionFactory, $eventManager, $managerRegistry, $router, $translator, $templating, $formFactory);
// initialize configuration
$configuration->getEntityClass()->willReturn('entity_class');
$configuration->getName()->willReturn('entity');
// initialize manager
$managerRegistry->getFromConfiguration($configuration)->willReturn($manager);
// initialize router
$router->generate(Argument::type('string'), Argument::type('array'), Argument::any())->will(function ($arguments) {
$path = $arguments[0] . '?';
foreach ($arguments[1] as $key => $value) {
$path .= '&' . $key . '=' . $value;
}
return $path;
});
// initialize form
$formFactory->create('form_type', $object, ['data_class' => 'entity_class'])->willReturn($form);
$form->createView()->willReturn($formView);
$form->getData()->willReturn($object);
// initialize request
$request->attributes = $attributes;
$attributes->get('id')->willReturn('id');
// initialize configuration for form
$actionFactory->getAction('entity', 'index')->willReturn($indexAction);
$configuration->hasAction('index')->willReturn(true);
$indexAction->getRoute()->willReturn('index');
$indexAction->getRouteParameters(null)->willReturn(['ir_param1' => 'value1']);
}
示例7: 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;
}
示例8: 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;
}
示例9: 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);
}
示例10: 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']]);
}
}
示例11: generateDiscountCode
public function generateDiscountCode(ParameterBag $options)
{
$length = $options->get('length');
if (0 > $length || self::MAX_LENGTH < $length) {
throw new InvalidArgumentException("Wrong number of codes");
}
return $this->engine->getCode($length);
}
示例12:
function it_returns_null_channel_code_if_no_fake_channel_code_was_found(Request $request, ParameterBag $queryBag, ParameterBag $cookiesBag)
{
$queryBag->get('_channel_code')->willReturn(null);
$request->query = $queryBag;
$cookiesBag->get('_channel_code')->willReturn(null);
$request->cookies = $cookiesBag;
$this->getCode($request)->shouldReturn(null);
}
示例13: it_do_not_authenticate_channel_when_cookie_name_is_missing
public function it_do_not_authenticate_channel_when_cookie_name_is_missing(Session $session, ParameterBag $cookies)
{
$session->getName()->shouldBeCalled()->willReturn('session');
$cookies->get('session')->shouldBeCalled()->willReturn('invalid_channel');
$session->set('socketId', 1)->shouldNotBeCalled();
$session->set('channelName', 'new_channel')->shouldNotBeCalled();
$this->authenticate(1, 'new_channel')->shouldReturn(false);
}
示例14:
function it_sets_request($localeSettings, Request $request, ParameterBag $parameterBag)
{
$parameterBag->get('_locale')->willReturn(true);
$request->attributes = $parameterBag;
$localeSettings->getLanguage()->shouldNotBeCalled();
$localeSettings->getLocale()->willReturn('fr_FR');
$this->setRequest($request);
}
示例15:
function it_checks_if_an_item_is_in_the_includes(Request $request, ParameterBag $parameterBag)
{
$includes = 'product,image';
$entity = 'image';
$request->query = $parameterBag;
$parameterBag->get('include')->shouldBeCalledTimes(1)->willReturn($includes);
$this->inIncludes($entity)->shouldReturn(true);
}