Ejemplo n.º 1
0
 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));
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 5
0
 /**
  * @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;
 }
Ejemplo n.º 6
0
 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);
 }
Ejemplo n.º 8
0
 /**
  * @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);
 }
Ejemplo n.º 9
0
 protected function createColumnMapping(ParameterBag $query)
 {
     $mapping = [];
     for ($i = 0; $i < $query->get('iColumns'); $i++) {
         $mapping[$i] = $query->get("mDataProp_{$i}");
     }
     return $mapping;
 }
Ejemplo n.º 10
0
 /**
  * @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);
 }
Ejemplo n.º 12
0
 /**
  * @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);
 }
Ejemplo n.º 13
0
 /**
  * @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;
 }
Ejemplo n.º 16
0
 /**
  * {@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);
 }
Ejemplo n.º 17
0
 /**
  * @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'));
 }
Ejemplo n.º 18
0
 /**
  * @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;
 }
Ejemplo n.º 19
0
 /**
  * @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);
 }
Ejemplo n.º 20
0
 /**
  * @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);
 }
Ejemplo n.º 21
0
 /**
  * @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;
 }
Ejemplo n.º 22
0
 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;
 }
Ejemplo n.º 23
0
 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);
     }
 }
Ejemplo n.º 24
0
 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);
 }
Ejemplo n.º 25
0
 /**
  * @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;
 }
Ejemplo n.º 26
0
 /**
  * {@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;
 }
Ejemplo n.º 28
0
 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();
 }
Ejemplo n.º 29
-10
 /**
  * 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'));
 }