The constants in this interface define the different types of resource references that are declared in RFC 3986: http://tools.ietf.org/html/rfc3986 We are using the term "URL" instead of "URI" as this is more common in web applications and we do not need to distinguish them as the difference is mostly semantical and less technical. Generating URIs, i.e. representation-independent resource identifiers, is also possible.
Автор: Fabien Potencier (fabien@symfony.com)
Наследование: extends Symfony\Component\Routing\RequestContextAwareInterface
 /**
  * {@inheritdoc}
  */
 public function mapPath($path, $build, $development)
 {
     if (substr($path, 0, 1) === '/') {
         return $path;
     }
     return $this->urlGenerator->generate('tq_extjs_application_resources', ['build' => $build, 'dev' => $development ? '-dev' : '', 'path' => str_replace('..', '~', $path)]);
 }
 function its_on_registration_success(FormEvent $event, UrlGeneratorInterface $router, RandomUsernameGenerator $generator)
 {
     $router->generate('quickstart_app_account')->shouldBeCalled()->willReturn('/en/account');
     $this->beConstructedWith($router, $generator);
     $event->setResponse(Argument::type('Symfony\\Component\\HttpFoundation\\RedirectResponse'))->shouldBeCalled();
     $this->onRegistrationSuccess($event);
 }
Пример #3
0
 /**
  * {@inheritDoc}
  */
 public function getAuthorizationUrl($redirectUrl)
 {
     if (!preg_match('#^https://.*#', $redirectUrl)) {
         $redirectUrl = $this->generator->generate($redirectUrl, array(), true);
     }
     return parent::getAuthorizationUrl($redirectUrl);
 }
 /**
  * Add new breadcrumb item
  * @param string $linkName
  * @param string|array|null $target
  * @return void
  */
 public function addItem($linkName, $target = null)
 {
     if (is_array($target)) {
         $target = isset($target['params']) ? $this->urlGen->generate($target['route'], $target['params']) : $this->urlGen->generate($target['route']);
     }
     $this->items[] = array("linkName" => $linkName, "target" => $target);
 }
 /**
  * Add Free payment method
  *
  * @param PaymentCollectionEvent $event Event
  */
 public function addFreePaymentPaymentMethod(PaymentCollectionEvent $event)
 {
     if ($this->plugin->isUsable()) {
         $bankwire = new PaymentMethod($this->plugin->getHash(), 'elcodi_plugin.bankwire.name', 'elcodi_plugin.bankwire.description', $this->router->generate('paymentsuite_bankwire_execute'));
         $event->addPaymentMethod($bankwire);
     }
 }
Пример #6
0
 /**
  * @param Request $request
  *
  * @return JsonResponse
  */
 public function createAction($content, Request $request)
 {
     $this->forward400Unless('json' == $request->getContentType() || 'form' == $request->getContentType());
     $rawPayment = ArrayObject::ensureArrayObject($content);
     $form = $this->formFactory->create('create_payment');
     $form->submit((array) $rawPayment);
     if (false == $form->isValid()) {
         return new JsonResponse($this->formToJsonConverter->convertInvalid($form), 400);
     }
     /** @var Payment $payment */
     $payment = $form->getData();
     $payment->setId(Random::generateToken());
     $storage = $this->payum->getStorage($payment);
     $storage->update($payment);
     $payment->setNumber($payment->getNumber() ?: date('Ymd-' . mt_rand(10000, 99999)));
     $storage->update($payment);
     // TODO
     $payment->setValue('links', 'done', 'http://dev.payum-server.com/client/index.html');
     $payment->setValue('links', 'self', $this->urlGenerator->generate('payment_get', ['id' => $payment->getId()], true));
     $token = $this->payum->getTokenFactory()->createAuthorizeToken($payment->getGatewayName(), $payment, $payment->getValue('links', 'done'), ['payum_token' => null, 'payment' => $payment->getId()]);
     $payment->setValue('links', 'authorize', $token->getTargetUrl());
     $token = $this->payum->getTokenFactory()->createCaptureToken($payment->getGatewayName(), $payment, $payment->getValue('links', 'done'), ['payum_token' => null, 'payment' => $payment->getId()]);
     $payment->setValue('links', 'capture', $token->getTargetUrl());
     $token = $this->payum->getTokenFactory()->createNotifyToken($payment->getGatewayName(), $payment);
     $payment->setValue('links', 'notify', $token->getTargetUrl());
     $storage->update($payment);
     return new JsonResponse(array('payment' => $this->paymentToJsonConverter->convert($payment)), 201, array('Location' => $payment->getValue('links', 'self')));
 }
Пример #7
0
 /**
  * {@inheritdoc}
  */
 public function render(GridViewInterface $grid, ColumnInterface $column, $sorting)
 {
     $definition = $grid->getDefinition();
     $name = $column->getName();
     if (!$definition->hasSort($name)) {
         return;
     }
     $sort = $sorting === SorterInterface::ASC ? $name : '-' . $name;
     $routeParameters = [];
     if (($request = $this->requestStack->getMasterRequest()) !== null) {
         $routeParameters = array_merge($request->attributes->get('_route_params', []), $request->query->all());
     }
     if (!isset($routeParameters['grid']['reset']) && isset($routeParameters['grid']['sorting']) && $routeParameters['grid']['sorting'] === $sort) {
         return;
     }
     if ($definition->hasOption('persistent') && $definition->getOption('persistent')) {
         $filters = $this->filterManager->get($definition);
         if (isset($filters['sorting']) && $filters['sorting'] === $sort) {
             return;
         }
     }
     $routeParameters['grid']['sorting'] = $sort;
     unset($routeParameters['grid']['reset']);
     return $this->urlGenerator->generate($definition->getOption('grid_route'), $routeParameters);
 }
Пример #8
0
 /**
  * Returns the canonical url for the current request,
  * or null if called outside of the request cycle.
  *
  * @return string|null
  */
 public function getUrl()
 {
     if (($request = $this->requestStack->getCurrentRequest()) === null) {
         return null;
     }
     return $this->urlGenerator->generate($request->attributes->get('_route'), $request->attributes->get('_route_params'), UrlGeneratorInterface::ABSOLUTE_URL);
 }
Пример #9
0
 /**
  * {@inheritdoc}.
  */
 public function guessValues(UrlInformation $urlInformation, $object, $sitemap)
 {
     if ($urlInformation->getLocation()) {
         return;
     }
     $urlInformation->setLocation($this->urlGenerator->generate($object, array(), UrlGeneratorInterface::ABSOLUTE_URL));
 }
Пример #10
0
 /**
  * Generates referral program tracking route
  *
  * @param ReferralHashInterface $referralHash Referral hash
  *
  * @return string
  */
 public function generateControllerRoute(ReferralHashInterface $referralHash)
 {
     /**
      * Referral link generation
      */
     return $this->routeGenerator->generate($this->controllerRouteName, array('hash' => $referralHash->getHash()), true);
 }
Пример #11
0
 /**
  * Add PayPal payment method
  *
  * @param PaymentCollectionEvent $event Event
  */
 public function addPaypalPaymentMethod(PaymentCollectionEvent $event)
 {
     if ($this->plugin->isUsable(['business'])) {
         $paypal = new PaymentMethod($this->plugin->getHash(), 'elcodi_plugin.paypal_web_checkout.name', 'elcodi_plugin.paypal_web_checkout.description', $this->router->generate('paymentsuite_paypal_web_checkout_execute'));
         $event->addPaymentMethod($paypal);
     }
 }
Пример #12
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->setAction($this->urlGenerator->generate($options['route'], $options['route_parameters']));
     $builder->setMethod('POST');
     $builder->add('locale', 'choice', ['label' => false, 'required' => true, 'widget_addon_prepend' => ['icon' => 'language'], 'choices' => $this->localeChoiceList->create(), 'choices_as_values' => true]);
     $builder->add('switch', 'submit', ['label' => 'stepup_middleware_client.form.switch_locale.switch', 'attr' => ['class' => 'btn btn-default']]);
 }
Пример #13
0
 /**
  * Payment fail action.
  *
  * @param Request $request Request element
  *
  * @return Response
  */
 public function failureAction(Request $request)
 {
     $orderId = $request->query->get('order_id', false);
     $failureRoute = $this->redirectionRoutes->getRedirectionRoute('failure');
     $redirectUrl = $this->urlGenerator->generate($failureRoute->getRoute(), $failureRoute->getRouteAttributes($orderId));
     return new RedirectResponse($redirectUrl);
 }
Пример #14
0
 /**
  * {@inheritdoc}
  */
 public function apply(array &$options, ItemInterface $item)
 {
     if (!empty($options['route'])) {
         $route = (array) $options['route'] + array('', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
         $options['uri'] = $this->generator->generate($route[0], $route[1], $route[2]);
     }
 }
 private function loadCategories()
 {
     $collection = $this->repository->matching(new Criteria());
     $collection->map(function (CategoryInterface $category) {
         $this->categories[$category->getId()] = ['name' => $category->translate()->getName(), 'route' => $this->generator->generate($category->translate()->getRoute()->getId())];
     });
 }
 /**
  * @param string $route
  * @param array $parameters
  * @param string $referenceType
  * @return string
  * @throws MissingDependencyException
  */
 public function generateUrl($route, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
 {
     if (null === $this->urlGenerator) {
         throw new MissingDependencyException('No router present.');
     }
     return $this->urlGenerator->generate($route, $parameters, $referenceType);
 }
 public function testGetFailedMessage()
 {
     $message = 'test message';
     $this->router->expects($this->never())->method($this->anything());
     $this->translator->expects($this->once())->method('trans')->willReturn($message);
     $this->assertEquals($message, $this->generator->getFailedMessage());
 }
Пример #18
0
 /**
  * {@inheritdoc}.
  */
 public function guessValues(UrlInformation $urlInformation, $object, $sitemap)
 {
     if ($urlInformation->getLocation()) {
         return;
     }
     $urlInformation->setLocation($this->urlGenerator->generate($object, array(), true));
 }
Пример #19
0
 /**
  * @param SluggableInterface $sluggable
  * @param array              $parameterList
  *
  * @return string
  */
 public function generate(SluggableInterface $sluggable, array $parameterList = [])
 {
     $configuration = $this->sluggableManager->getConfiguration($sluggable);
     $parameterList[$configuration->getRouteIdParameterName()] = $sluggable->getId();
     $parameterList[$configuration->getRouteSlugParameterName()] = $this->slugger->slug($sluggable);
     return $this->urlGenerator->generate($configuration->getRouteName(), $parameterList);
 }
Пример #20
0
 /**
  * Add Free payment method
  *
  * @param PaymentCollectionEvent $event Event
  */
 public function addFreePaymentPaymentMethod(PaymentCollectionEvent $event)
 {
     if ($this->plugin->isUsable()) {
         $freePayment = new PaymentMethod($this->plugin->getHash(), 'elcodi_plugin.free_payment.name', 'elcodi_plugin.free_payment.description', $this->router->generate('freepayment_payment_routes'));
         $event->addPaymentMethod($freePayment);
     }
 }
 /**
  * Creates a provider of the given class.
  *
  * @param string $class
  * @param array $options
  * @param string $redirectUri
  * @param array $redirectParams
  * @return mixed
  */
 public function createProvider($class, array $options, $redirectUri, array $redirectParams = [])
 {
     $redirectUri = $this->generator->generate($redirectUri, $redirectParams, UrlGeneratorInterface::ABSOLUTE_URL);
     $options['redirectUri'] = $redirectUri;
     // todo - make this configuration when someone needs this
     $collaborators = [];
     return new $class($options, $collaborators);
 }
 /**
  * {@inheritdoc}
  */
 public function isStrictRequirements()
 {
     if ($this->wrapped instanceof ConfigurableRequirementsInterface) {
         return $this->wrapped->isStrictRequirements();
     }
     return null;
     // requirements check is deactivated completely
 }
Пример #23
0
 private function failRegistration($message, GetResponseUserEvent $event)
 {
     //        throw new \Exception($message);
     /** @var Session $session */
     $session = $event->getRequest()->getSession();
     $session->getFlashBag()->set('error', $message);
     $event->setResponse(new RedirectResponse($this->urlGenerator->generate('fda_dsb_homepage')));
 }
Пример #24
0
 protected function setUp()
 {
     $this->urlGenerator = $this->getMock('Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface');
     $this->security = $this->getMock('Symfony\\Component\\Security\\Core\\SecurityContextInterface');
     $this->session = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Session\\Session')->disableOriginalConstructor()->getMock();
     $this->urlGenerator->expects($this->once())->method('generate')->with('payment_page')->willReturn('/buy/new/ticket');
     $this->sut = new AccessDeniedListener($this->security, $this->urlGenerator, 'payment_page');
 }
 /**
  * @param string|null $build
  * @return string
  */
 public function getAppCachePath($build = null)
 {
     $build = $build ?: $this->application->getDefaultBuild();
     if (!$this->application->hasAppCache($build)) {
         return '';
     }
     return $this->generator->generate('tq_extjs_application_appcache', ['build' => $build, 'dev' => $this->application->isDevelopment() ? '-dev' : '']);
 }
Пример #26
0
 /**
  * @ApiDoc(
  *     section="Shift",
  *     description="Create a Shift",
  *     input="ShiftBundle\Model\ShiftCreation",
  *     statusCodes={
  *         201 = "Successfully created the shift",
  *     },
  * )
  * @Method("PUT")
  * @Route()
  * @View(statusCode=201)
  * @param ShiftCreationInterface $shiftCreation
  * @param ConstraintViolationListInterface $validationErrors
  * @ParamConverter(name="shiftCreation", converter="fos_rest.request_body", class="ShiftBundle\Model\ShiftCreation")
  * @return Response
  */
 public function createAction(ShiftCreationInterface $shiftCreation, ConstraintViolationListInterface $validationErrors)
 {
     if (count($validationErrors) > 0) {
         throw new ConstraintViolationBadRequestException($validationErrors);
     }
     $shift = $this->shiftHandler->create($shiftCreation);
     return new Response(null, Response::HTTP_CREATED, ['Location' => $this->urlGenerator->generate('shift_shift_details', ['shift' => $shift->getId()])]);
 }
Пример #27
0
 /**
  * @param int $shoppingListId
  * @param int $entitiesCount
  * @param null|string $transChoiceKey
  * @return string
  */
 public function getSuccessMessage($shoppingListId = null, $entitiesCount = 0, $transChoiceKey = null)
 {
     $message = $this->translator->transChoice($transChoiceKey ?: 'orob2b.shoppinglist.actions.add_success_message', $entitiesCount, ['%count%' => $entitiesCount]);
     if ($shoppingListId && $entitiesCount > 0) {
         $message = sprintf('%s (<a href="%s">%s</a>).', $message, $this->router->generate('orob2b_shopping_list_frontend_view', ['id' => $shoppingListId]), $linkTitle = $this->translator->trans('orob2b.shoppinglist.actions.view'));
     }
     return $message;
 }
Пример #28
0
 /**
  * @param AdWordsUser $adwordsuser
  * @param Google_Client $googleclient
  * @param Cache $cache
  * @param UrlGeneratorInterface $router
  * @param app_redirect_route
  */
 public function __construct(AdWordsUser $adwordsuser, Google_Client $googleclient, Cache $cache, UrlGeneratorInterface $router, $app_redirect_route)
 {
     $this->adwordsuser = $adwordsuser;
     $this->googleclient = $googleclient;
     $this->cache = $cache;
     $redirect_url = $router->generate($app_redirect_route, array(), UrlGeneratorInterface::ABSOLUTE_URL);
     $this->googleclient->setRedirectUri($redirect_url);
 }
Пример #29
0
 /**
  * @param PurchaseCompleteEvent $event
  */
 public function abandonCart(PurchaseCompleteEvent $event)
 {
     if (in_array($event->getSubject()->getState(), [PaymentInterface::STATE_PENDING, PaymentInterface::STATE_PROCESSING, PaymentInterface::STATE_COMPLETED])) {
         $this->cartProvider->abandonCart();
         return;
     }
     $event->setResponse(new RedirectResponse($this->router->generate($this->redirectTo)));
 }
Пример #30
0
 /**
  * {@inheritdoc}
  */
 public function generate($name, array $parameters, $absolute = false)
 {
     // If is it at least Symfony 2.8 and $absolute is passed as boolean
     if (SymfonyUrlGeneratorInterface::ABSOLUTE_PATH === 1 && is_bool($absolute)) {
         $absolute = $absolute ? SymfonyUrlGeneratorInterface::ABSOLUTE_URL : SymfonyUrlGeneratorInterface::ABSOLUTE_PATH;
     }
     return $this->urlGenerator->generate($name, $parameters, $absolute);
 }