function it_creates_configuration_without_default_settings(MetadataInterface $metadata, Request $request, ParametersParser $parametersParser, ParameterBag $headersBag, ParameterBag $attributesBag)
 {
     $request->headers = $headersBag;
     $request->attributes = $attributesBag;
     $attributesBag->get('_sylius', [])->willReturn(['template' => ':Product:list.html.twig']);
     $parametersParser->parseRequestValues(['template' => ':Product:list.html.twig'], $request)->willReturn(['template' => ':Product:list.html.twig']);
     $this->create($metadata, $request)->isSortable()->shouldReturn(false);
 }
 function it_creates_configuration_from_resource_metadata_and_request(MetadataInterface $metadata, Request $request, ParametersParser $parametersParser, ParameterBag $headersBag, ParameterBag $attributesBag)
 {
     $request->headers = $headersBag;
     $request->attributes = $attributesBag;
     $headersBag->has('Accept')->willReturn(false);
     $headersBag->has('Accept')->willReturn(false);
     $configuration = ['template' => ':Product:show.html.twig'];
     $attributesBag->get('_sylius', [])->shouldBeCalled()->willReturn($configuration);
     $parametersParser->parseRequestValues($configuration, $request)->willReturn($configuration);
     $this->create($metadata, $request)->shouldHaveType(RequestConfiguration::class);
 }
Exemplo n.º 3
0
 public function createFromRoute($route, MetadataInterface $metadata, RouterInterface $router)
 {
     $route = $router->getRouteCollection()->get($route);
     if ($route === null) {
         return null;
     }
     $parameters = $route->getDefault('_sylius');
     $request = new Request();
     $parameters = array_merge($this->defaultParameters, $parameters);
     $parameters = $this->parametersParser->parseRequestValues($parameters, $request);
     return new $this->configurationClass($metadata, $request, new Parameters($parameters));
 }
Exemplo n.º 4
0
 /**
  * @param ResourceController $controller
  * @param Request            $request
  */
 private function processRequest(ResourceController $controller, Request $request)
 {
     $parameters = array_merge($this->settings, $this->parseApiData($request));
     list($parameters, $parameterNames) = $this->parametersParser->parse($parameters, $request);
     $this->parameters->replace($parameters);
     $this->parameters->set('paramater_name', $parameterNames);
     $controller->getConfiguration()->setRequest($request);
     $controller->getConfiguration()->setParameters($this->parameters);
     $routeParams = $request->attributes->get('_route_params', array());
     if (isset($routeParams['_sylius'])) {
         unset($routeParams['_sylius']);
         $request->attributes->set('_route_params', $routeParams);
     }
 }
Exemplo n.º 5
0
 /**
  * @param object|null $resource
  *
  * @return array
  */
 public function getRedirectParameters($resource = null)
 {
     $redirect = $this->parameters->get('redirect');
     if (!is_array($redirect) || empty($redirect['parameters'])) {
         $redirect = array('parameters' => array());
     }
     $parameters = $redirect['parameters'];
     if (null !== $resource) {
         $parameters = $this->parser->process($parameters, $resource);
     }
     return $parameters;
 }
 /**
  * {@inheritdoc}
  */
 public function create(MetadataInterface $metadata, Request $request)
 {
     $parameters = array_replace_recursive($this->defaultParameters, $this->parseApiParameters($request));
     $parameters = $this->parametersParser->parseRequestValues($parameters, $request);
     return new $this->configurationClass($metadata, $request, new Parameters($parameters));
 }
Exemplo n.º 7
0
 function it_returns_array_as_redirect_parameters(Parameters $parameters, ParametersParser $parser)
 {
     $parameters->get('redirect')->willReturn(null);
     $this->getRedirectParameters()->shouldReturn(array());
     $parameters->get('redirect')->willReturn('string');
     $this->getRedirectParameters()->shouldReturn(array());
     $parameters->get('redirect')->willReturn(array('parameters' => array('myParameter')));
     $this->getRedirectParameters()->shouldReturn(array('myParameter'));
     $params = array('myParameter');
     $parameters->get('redirect')->willReturn(array('parameters' => array('myParameter')));
     $parser->process($params, 'resource')->willReturn($params);
     $this->getRedirectParameters('resource')->shouldReturn($params);
 }