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)); }
private function update(Note $note, ParameterBag $parameters) { $note->setTitle($parameters->get('title')); $note->setColor($parameters->get('color')); $note->setContent($parameters->get('content')); return $note; }
/** * @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); }
/** * @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); }
/** * @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; }
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; }
/** * @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); }
/** * @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); }
protected function createColumnMapping(ParameterBag $query) { $mapping = []; for ($i = 0; $i < $query->get('iColumns'); $i++) { $mapping[$i] = $query->get("mDataProp_{$i}"); } return $mapping; }
/** * @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'); }
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); }
/** * @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); }
/** * @param ParameterBag $params * * @return boolean */ public function update($params) { $entity = $this->rGet($params->get('id')); $entity->setName($params->get('name')); $entity->setIso2($params->get('iso2')); $entity->setPattern($params->get('pattern')); $entity->setPrefix($params->get('prefix')); $this->merge($entity); }
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]); }
private function updateGuestInfo(Guest $guest, ParameterBag $input) { $guest->setFirstName($input->get('firstName')); $guest->setLastName($input->get('lastName')); $guest->setEmailAddress($input->get('emailAddress')); $guest->setPhoneNumber((int) $input->get('phoneNumber')); $guest->setAddress($input->get('address')); $this->guest->save($guest); return $guest; }
/** * {@inheritdoc} */ public function init(Transport $transportEntity) { $this->resetAttemptCount(); $this->settings = $transportEntity->getSettingsBag(); $wsdlUrl = $this->settings->get('wsdl_url'); if (!$wsdlUrl) { throw new InvalidConfigurationException("SOAP Transport require 'wsdl_url' option to be defined."); } $this->client = $this->getSoapClient($wsdlUrl); }
/** * @param OAuth2Provider $provider * @param ParameterBag $getParams * @return OAuth2Token * @throws OAuthException */ protected function retrieveToken(OAuth2Provider $provider, ParameterBag $getParams) { if ($getParams->has('error')) { throw OAuthException::createFromError($getParams->get('error'), $getParams->get('error_description')); } if (!$getParams->has('code')) { throw new GrantCodeNotFoundException('The grant code parameter was not found'); } return $provider->retrieveToken($getParams->get('code')); }
/** * @param QueryBuilder $query * @param ParameterBag $request * @return QueryBuilder */ public function map(QueryBuilder $query, ParameterBag $request) { if ($request->has('name')) { $query->andWhere('o.name LIKE :name')->setParameter('name', '%' . $request->get('name') . '%'); } if ($request->has('login')) { $query->andWhere('o.login = :login')->setParameter('login', $request->get('login')); } return $query; }
/** * @param ParameterBag $params * * @return boolean */ public function update($params) { /** @var Person $entity */ $entity = $this->rGet($params->get('id')); $entity->setName($params->get('name')); $entity->setClient($params->get('client')); $entity->setBorn($params->get('born')); $entity->setFamilyStatus($params->get('familyStatus')); $this->merge($entity); }
/** * @param Request $request * @param int $type * @param bool $catch */ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true) { $host = $request->getHttpHost(); $sites = $this->config->get('default_site_id'); $site = str_replace('.', '_', $host); $sid = isset($sites[$site]) ? $sites[$site] : $sites['default']; $this->config->set('side_id', $sid); $this->config->set('current_site_id', $sid); return $this->app->handle($request, $type, $catch); }
/** * @param QueryBuilder $query * @param ParameterBag $request * @return QueryBuilder */ public function map(QueryBuilder $query, ParameterBag $request) { if ($request->has('firstname')) { $query->andWhere('u.firstName LIKE :firstname')->setParameter('firstname', '%' . $request->get('firstname') . '%'); } if ($request->has('login')) { $query->andWhere('u.login = :login')->setParameter('login', $request->get('login')); } if ($request->has('lastname')) { $query->andWhere('u.lastName LIKE :lastname')->setParameter('lastname', '%' . $request->get('lastname') . '%'); } if ($request->has('name')) { $term = str_replace(' ', '%', trim($request->get('name'))); $query->andWhere('u.firstName LIKE :term OR u.lastName LIKE :term OR u.fullName LIKE :term')->setParameter('term', '%' . $term . '%'); } if ($request->has('branch')) { $query->andWhere('u.branch = :branch')->setParameter('branch', $request->get('branch')); } if ($request->has('level')) { $query->andWhere('u.niveau = :level')->setParameter('level', $request->get('level')); } if ($request->has('speciality')) { $query->andWhere('u.filiere = :speciality')->setParameter('speciality', $request->get('speciality')); } if ($request->has('is_student')) { $query->andWhere('u.isStudent = :is_student')->setParameter('is_student', (bool) $request->get('is_student')); } if ($request->has('bde_member') && $request->get('bde_member') == '1') { $query->andWhere('m.end > :now')->setParameter('now', new \DateTime('now')); } return $query; }
public function bindValues($id, ParameterBag $values) { $updated = $this->find($id); if ($values->get('name')) { $updated->setName($values->get('name')); } if ($values->get('price')) { $updated->setPrice($values->get('price')); } return $updated; }
private function handleShows($path, ParameterBag $query) { if ($path == '/shows' && $query->has('showid')) { return $this->createShowResponseFromId($query->get('showid')); } elseif ($path == '/shows/view/person') { return $this->createPersonResponseFromId($query->get('person')); } else { $ref = substr($path, 7); return $this->createShowResponseFromRef($ref); } }
function it_renders_login_form(Request $request, ParameterBag $requestAttributes, AuthenticationUtils $authenticationUtils, FormFactoryInterface $formFactory, Form $form, FormView $formView, EngineInterface $templatingEngine, Response $response) { $authenticationUtils->getLastAuthenticationError()->willReturn('Bad credentials.'); $authenticationUtils->getLastUsername()->willReturn('john.doe'); $request->attributes = $requestAttributes; $requestAttributes->get('_sylius[template]', 'SyliusUiBundle:Security:login.html.twig', true)->willReturn('CustomTemplateName'); $requestAttributes->get('_sylius[form]', 'sylius_security_login', true)->willReturn('custom_form_type'); $formFactory->createNamed('', 'custom_form_type')->willReturn($form); $form->createView()->willReturn($formView); $templatingEngine->renderResponse('CustomTemplateName', ['form' => $formView, 'last_username' => 'john.doe', 'last_error' => 'Bad credentials.'])->willReturn($response); $this->loginAction($request)->shouldReturn($response); }
/** * @param ParameterBag $parameters * * @return Request */ private function buildRequestFromParameters(ParameterBag $parameters) { $uri = $parameters->get('url'); $method = $parameters->get('method', 'GET'); $parameters = $this->transformParametersStringToArray($parameters->get('parameters', '')); $cookies = []; $files = []; $server = []; $content = null; $request = Request::create($uri, $method, $parameters, $cookies, $files, $server, $content); return $request; }
/** * {@inheritDoc} */ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) { if (!$request->headers->has($this->header)) { $uuid = (string) ($uuid = Uuid::uuid4()); $request->headers->set($this->header, $uuid); $this->config->set('request_id', $uuid); } else { $this->config->set('request_id', (string) $request->headers->get($this->header)); } $response = $this->app->handle($request, $type, $catch); $response->headers->set($this->header, (string) $this->config->get('request_id')); return $response; }
/** * @param ParameterBag $query * @return Filter */ public function transform(ParameterBag $query) { $filter = new Filter(); if (null === $query->get('filter')) { return $filter; } foreach ($query->get('filter') as $name => $value) { $filterClassName = '\\FhemConnectionBundle\\Filter\\' . ucfirst($name) . 'Filter'; // TODO create factory $filterClass = new $filterClassName($value); $filter->addFilter($filterClass); } return $filter; }
public function parseCookies(ParameterBag $cookies) { $this->setUtm(new Utm()); if ($cookies->has('__utmz')) { $this->utmz($cookies->get('__utmz')); } if ($cookies->has('__utmb')) { $this->utmb($cookies->get('__utmb')); } if ($cookies->has('__utma')) { $this->utma($cookies->get('__utma')); } return $this->getUtm(); }
/** * 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']]); } }
/** * @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')); }