本文整理汇总了PHP中Symfony\Component\Routing\Generator\UrlGeneratorInterface类的典型用法代码示例。如果您正苦于以下问题:PHP UrlGeneratorInterface类的具体用法?PHP UrlGeneratorInterface怎么用?PHP UrlGeneratorInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UrlGeneratorInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
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);
}
示例2: getUrl
/**
* 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);
}
示例3: guessValues
/**
* {@inheritdoc}.
*/
public function guessValues(UrlInformation $urlInformation, $object, $sitemap)
{
if ($urlInformation->getLocation()) {
return;
}
$urlInformation->setLocation($this->urlGenerator->generate($object, array(), UrlGeneratorInterface::ABSOLUTE_URL));
}
示例4: apply
/**
* {@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]);
}
}
示例5: generateUrl
/**
* @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);
}
示例6: mapPath
/**
* {@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)]);
}
示例7: getAuthorizationUrl
/**
* {@inheritDoc}
*/
public function getAuthorizationUrl($redirectUrl)
{
if (!preg_match('#^https://.*#', $redirectUrl)) {
$redirectUrl = $this->generator->generate($redirectUrl, array(), true);
}
return parent::getAuthorizationUrl($redirectUrl);
}
示例8: addItem
/**
* 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);
}
示例9: addFreePaymentPaymentMethod
/**
* 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);
}
}
示例10: createAction
/**
* @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')));
}
示例11: render
/**
* {@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);
}
示例12: generateControllerRoute
/**
* 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);
}
示例13: addPaypalPaymentMethod
/**
* 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);
}
}
示例14: buildForm
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']]);
}
示例15: failureAction
/**
* 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);
}