function let(ParametersParser $parametersParser, Parameters $parameters, Request $request, ParameterBag $parameterBag, HeaderBag $headerBag, FilterControllerEvent $event, ResourceController $resourceController, Configuration $configuration) { $resourceController->getConfiguration()->willReturn($configuration); $event->getController()->willReturn(array($resourceController)); $event->getRequest()->willReturn($request); $request->attributes = $parameterBag; $request->headers = $headerBag; $this->beConstructedWith($parametersParser, $parameters, array('paginate' => false, 'limit' => false, 'sortable' => false, 'sorting' => null, 'filterable' => false, 'criteria' => null)); }
/** * @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); } }
public function setContainer(ContainerInterface $container = null) { parent::setContainer($container); if ($container !== null) { $this->flashHelper = new FlashHelper($this->config, $container->get('translator'), $container->get('session')); } }
public function __construct(MetadataInterface $metadata, SyliusRequestConfigurationFactoryInterface $requestConfigurationFactory, ViewHandlerInterface $viewHandler, RepositoryInterface $repository, FactoryInterface $factory, NewResourceFactoryInterface $newResourceFactory, ObjectManager $manager, SingleResourceProviderInterface $singleResourceProvider, ResourcesCollectionProviderInterface $resourcesFinder, ResourceFormFactoryInterface $resourceFormFactory, RedirectHandlerInterface $redirectHandler, FlashHelperInterface $flashHelper, AuthorizationCheckerInterface $authorizationChecker, EventDispatcherInterface $eventDispatcher, ViewerFactory $viewerFactory, SortingManager $sortingManager, BatchManager $batchManager) { parent::__construct($metadata, $requestConfigurationFactory, $viewHandler, $repository, $factory, $newResourceFactory, $manager, $singleResourceProvider, $resourcesFinder, $resourceFormFactory, $redirectHandler, $flashHelper, $authorizationChecker, $eventDispatcher); $this->viewerFactory = $viewerFactory; $this->sortingManger = $sortingManager; $this->batchManager = $batchManager; }
/** * {@inheritdoc} */ public function createNew() { if (null === ($productId = $this->getRequest()->get('productId'))) { throw new NotFoundHttpException('No parent product given.'); } $product = $this->findProductOr404($productId); $variant = parent::createNew(); $variant->setProduct($product); return $variant; }
/** * {@inheritdoc} */ public function createNew() { $request = $this->config->getRequest(); if (null === ($countryId = $request->get('countryId'))) { throw new NotFoundHttpException('No country given'); } $country = $this->getCountryController()->findOr404($request, ['id' => $countryId]); $province = parent::createNew(); $province->setCountry($country); return $province; }
/** * {@inheritdoc} */ public function createNew() { $request = $this->getRequest(); if (null === ($promotionId = $request->get('promotionId'))) { throw new NotFoundHttpException('No promotion id given'); } $promotion = $this->getPromotionController()->findOr404($request, array('id' => $promotionId)); $coupon = parent::createNew(); $coupon->setPromotion($promotion); return $coupon; }
/** * {@inheritdoc} */ public function createNew() { if (null === ($orderId = $this->getRequest()->get('orderId'))) { return new JsonResponse(array('error' => 'Missing order id.'), 400); } if (!($order = $this->getOrderRepository()->find($orderId))) { $this->createNotFoundException('Requested order does not exist.'); } $adjustment = parent::createNew(); $adjustment->setAdjustable($order); return $adjustment; }
/** * {@inheritdoc} */ public function createNew() { if (null === ($orderId = $this->getRequest()->get('orderId'))) { throw new NotFoundHttpException('No order id given.'); } if (!($order = $this->getOrderRepository()->find($orderId))) { throw new NotFoundHttpException('Requested order does not exist.'); } $orderItem = parent::createNew(); $orderItem->setOrder($order); return $orderItem; }
/** * {@inheritdoc} */ public function createNew() { if (null === ($taxonomyId = $this->getRequest()->get('taxonomyId'))) { throw new NotFoundHttpException('No taxonomy id given.'); } if (!($taxonomy = $this->getTaxonomyRepository()->find($taxonomyId))) { throw new NotFoundHttpException('Requested taxonomy does not exist.'); } $taxon = parent::createNew(); $taxon->setTaxonomy($taxonomy); return $taxon; }
/** * {@inheritdoc} */ public function createNew() { $product = parent::createNew(); $code = $this->getRequest()->query->get('archetype'); if (null === $code) { return $product; } $archetype = $this->getArchetypeRepository()->findOneBy(array('code' => $code)); if (!$archetype) { throw new NotFoundHttpException(sprintf('Requested archetype does not exist!')); } $product->setArchetype($archetype); $this->getBuilder()->build($product); return $product; }
public function findOr404(Request $request, array $criteria = array()) { if ($request->attributes->has('_sylius_entity')) { return $request->attributes->get('_sylius_entity'); } return parent::findOr404($request, $criteria); }
/** * @param RequestConfiguration $configuration * * @return ProductInterface|null */ public function findOr404(RequestConfiguration $configuration) { $request = $configuration->getRequest(); if ($request->attributes->has('_sylius_entity')) { return $request->attributes->get('_sylius_entity'); } return parent::findOr404($configuration); }
/** * {@inheritdoc} * * Here for AOP */ public function showAction(Request $request) { return parent::showAction($request); }