作者:mseshachala
项目:quick-u
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);
}
作者:bol
项目:bol
/**
* 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);
}
作者:symfony-cm
项目:seo-bundl
/**
* {@inheritdoc}.
*/
public function guessValues(UrlInformation $urlInformation, $object, $sitemap)
{
if ($urlInformation->getLocation()) {
return;
}
$urlInformation->setLocation($this->urlGenerator->generate($object, array(), UrlGeneratorInterface::ABSOLUTE_URL));
}
作者:rybaki
项目:RybakitNavigationBundl
/**
* {@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]);
}
}
作者:seiffer
项目:controller-helper-bundl
/**
* @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);
}
作者:knpuniversit
项目:oauth2-client-bundl
/**
* 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);
}
作者:xtrasma
项目:iinan
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');
}
作者:mayec
项目:GoogleBundl
/**
* @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);
}
作者:bendavie
项目:Hateoa
/**
* {@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);
}
作者:teqneer
项目:ext-application-bundl
/**
* {@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)]);
}
作者:pminnieu
项目:altereg
/**
* {@inheritDoc}
*/
public function getAuthorizationUrl($redirectUrl)
{
if (!preg_match('#^https://.*#', $redirectUrl)) {
$redirectUrl = $this->generator->generate($redirectUrl, array(), true);
}
return parent::getAuthorizationUrl($redirectUrl);
}
作者:nym
项目:silex-twig-breadcrumb-extensio
/**
* 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);
}
作者:pramodda
项目:bambo
/**
* 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);
}
}
作者:Zifiu
项目:PayumServe
/**
* @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')));
}
作者:php-lu
项目:lu
/**
* {@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);
}
作者:hd-dema
项目:elcod
/**
* 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);
}
作者:elcod
项目:bambo
/**
* 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);
}
}
作者:surfne
项目:stepup-bundl
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']]);
}
作者:xsbaltra
项目:RedsysBundl
/**
* 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);
}
作者:wellcommerc
项目:wellcommerc
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())];
});
}