public function __construct(Session $session, Router $router, $environement, $merchant_pos_id, $pos_auth_key, $client_id, $client_secret, $signature_key) { $this->session = $session; $this->session->start(); $this->environment = $environement; $this->merchantPosId = $merchant_pos_id; $this->posAuthKey = $pos_auth_key; $this->clientId = $client_id; $this->clientSecret = $client_secret; $this->signatureKey = $signature_key; $this->currencyCode = 'PLN'; // TODO: from configuration $this->orderType = self::ORDER_TYPE_VIRTUAL; \OpenPayU_Configuration::setEnvironment($this->environment); \OpenPayU_Configuration::setMerchantPosId($this->merchantPosId); \OpenPayU_Configuration::setPosAuthKey($this->posAuthKey); \OpenPayU_Configuration::setClientId($this->clientId); \OpenPayU_Configuration::setClientSecret($this->clientSecret); \OpenPayU_Configuration::setSignatureKey($this->signatureKey); $this->authUrl = \OpenPayU_Configuration::$authUrl; $this->summaryUrl = \OpenPayU_Configuration::$summaryUrl; $this->notifyUrl = $router->generate('webultdPayuPaymentBundle_status', array(), true); $this->cancelUrl = $router->generate('webultdPayuPaymentBundle_cancel', array(), true); $this->completeUrl = $router->generate('webultdPayuPaymentBundle_success', array(), true); }
/** * @param $type * @param Router $router * @param ArrayCollection|Subject[] $subjects * @param int|null $parentId * @return string */ public static function createSubjectTreeView($type, $router, $subjects, $parentId = null) { $tree = '<ul>%s</ul>'; $item = '<li>%s</li>'; $link = '<a href="%s">%s</a>'; $items = ""; /** * @var Subject $subject * @var ArrayCollection $children */ foreach ($subjects as $subject) { if ($subject->getParent() === null || $subject->getParent()->getId() === $parentId) { if ($type == TreeHelper::SUBJECT_ADMIN) { $path = $router->generate('ojs_admin_subject_show', ['id' => $subject->getId()]); } else { $path = $router->generate('ojs_search_index', ['subject_filters' => $subject->getSubject()]); } $content = sprintf($link, $path, $subject->getSubject()); $children = $subject->getChildren(); if ($children->count() > 0) { $content = $content . TreeHelper::createSubjectTreeView($type, $router, $children, $subject->getId()); } $items = $items . sprintf($item, $content); } } return sprintf($tree, $items); }
private function matchRoute($routePath) { $locator = new FileLocator(array($this->container->getParameter('configDir'))); $router = new Router(new YamlFileLoader($locator), 'routes.yml', array('cache_dir' => null), $this->requestContext); $parameters = $router->match($routePath); return $parameters; }
public function postGif(Gif $gif) { $gifUrl = $this->router->generate('gif', ['permalink' => $gif->getPermalink()], true); $gifUrl = Util::fixSymfonyGeneratedURLs($gifUrl); $tweetContent = $gif->generateTweet($gifUrl); return $this->postTweet($tweetContent); }
public function route($url) { try { $context = new RequestContext(); $context->fromRequest($this->_request); $closure = function () { return $this->_container->get('routes'); }; $arrpar = array(); if (!DEVELOPMENT_ENVIRONMENT) { $arrpar['cache_dir'] = ROUTECACHE; } else { \Debug::addRoutes($closure); } $router = new SymfonyRouter(new ClosureLoader(), $closure, $arrpar, $context); $parameters = $router->match($url); $this->_controller = $parameters["controller"]; $this->_method = $parameters["action"]; $this->_route = $parameters["_route"]; unset($parameters["controller"]); unset($parameters["action"]); unset($parameters["_route"]); $this->_args = $parameters; } catch (ResourceNotFoundException $e) { $this->_route = ""; } catch (\Symfony\Component\Routing\Exception\MethodNotAllowedException $ema) { $this->_route = ""; throw new \GL\Core\Exception\MethodNotAllowedException(); } return $this->_route != ""; }
public function process($data) { $mergedData = array_merge($this->defaults, $data); // generating urls if (isset($mergedData['url']) && $mergedData['url'] && strpos($mergedData['url'], '/') === false) { $url = $this->router->generate($mergedData['url'], array(), true); $mergedData['url'] = $url; } if (isset($mergedData['urlc']) && $mergedData['urlc'] && strpos($mergedData['urlc'], '/') === false) { $urlc = $this->router->generate($mergedData['urlc'], array(), true); $mergedData['urlc'] = $urlc; } $form = $this->form; $form->bind($mergedData); if (!$form->isValid()) { $errors = array(); foreach ($form->getErrors() as $error) { /* @var \Symfony\Component\Form\FormError $error */ $errors[] = $error->getMessageTemplate(); } $logger = $this->logger; $logger->err('Params: ' . json_encode($mergedData)); $logger->err('Errors: ' . json_encode($errors)); throw new \InvalidArgumentException('Invalid action parameters. Check profiler log information for more details'); } return $form; }
public function __construct(Request $request, Router $router) { parent::__construct(); $this->setCurrentUri($request->getRequestUri()); $this->addChild('Song Library', $router->generate('song')); $this->addChild('Add Song to Library', $router->generate('song_create')); }
/** * Get url for entity * * @param object $entity * @param $item \Oro\Bundle\SearchBundle\Query\Result\Item * @return string */ protected function getEntityUrl($entity, $item) { $name = $item->getEntityName(); $entityMeta = $this->em->getClassMetadata($name); $identifierField = $entityMeta->getSingleIdentifierFieldName($entityMeta); if ($this->mapper->getEntityMapParameter($name, 'route')) { $routeParameters = $this->mapper->getEntityMapParameter($name, 'route'); $routeData = array(); if ($this->isParametersDefined($routeParameters)) { /** * NOTE: possible to generate url without entity object if only identifier field needed */ $idKey = array_search($identifierField, $routeParameters['parameters']); $needToHaveEntity = $idKey === false || count($routeParameters['parameters']) > 1; if (!$entity && $needToHaveEntity) { $entity = $this->em->getRepository($name)->find($item->getRecordId()); } foreach ($routeParameters['parameters'] as $parameter => $field) { if ($entity) { $routeData[$parameter] = $this->mapper->getFieldValue($entity, $field); } else { $routeData[$parameter] = $item->getRecordId(); } } } return $this->router->generate($routeParameters['name'], $routeData, true); } return ''; }
/** * @see : 3.1.1 PAYLINE-GUIDE-Descriptif des appels webservices. * @param Order $order * @return RedirectResponse * @throws \Exception */ public function doWebPayment(Order $order) { /** @var Customer $subscriber */ $customer = $order->getCustomer(); $array['version'] = self::VERSION; $array['returnURL'] = $this->frontRouter->generate('order.placed', ['order_id' => $order->getId()], true); $array['cancelURL'] = $this->frontRouter->generate('order.failed', ['order_id' => $order->getId(), 'message' => 'payline'], true); $array['notificationURL'] = $this->paylineRouter->generate('payline_notify', ['orderId' => $order->getId()], true); $amount = (double) $order->getTotalAmount() * 100; $currency = CurrencyNumericCodeQuery::create()->findPk($order->getCurrency()->getCode())->getNumericCode(); $array['payment']['amount'] = $amount; $array['payment']['currency'] = $currency; $array['payment']['action'] = '100'; $array['payment']['mode'] = 'CPT'; $array['payment']['contractNumber'] = $this->config->getContractNumber(); $array['order']['ref'] = $order->getRef(); $array['order']['amount'] = $amount; $array['order']['currency'] = $currency; $array['order']['date'] = $order->getUpdatedAt()->format('d/m/Y H:m'); $array['buyer']['lastName'] = $customer->getLastName(); $array['buyer']['firstName'] = $customer->getFirstName(); $array['buyer']['email'] = $customer->getEmail(); $array['securityMode'] = 'SSL'; $response = $this->payline->doWebPayment($array); $code = $response['result']['code']; if ($code !== '00000') { $message = isset($response['result']['longMessage']) ? $response['result']['longMessage'] : 'Error undefined'; $this->logger->error($message); throw new \Exception($message); } return new RedirectResponse($response['redirectURL']); }
/** * {@inheritdoc} */ public function register(Container $app) { /** * Holds information about the current request * * @return RequestContext */ $app['request_context'] = function () use($app) { $context = new RequestContext(); // set default http & https ports if not set $context->setHttpPort(isset($app['request.http_port']) ? $app['request.http_port'] : 80); $context->setHttpsPort(isset($app['request.https_port']) ? $app['request.https_port'] : 443); return $context; }; /** * Matches URL based on a set of routes. * * @return UrlMatcher */ $app['matcher'] = function () use($app) { return new UrlMatcher($app['router'], $app['request_context']); }; /** * Router */ $options = array('cache_dir' => true === $app['use_cache'] ? __DIR__ . '/' . self::CACHE_DIRECTORY : null, 'debug' => true); $app['router'] = function () use($app, $options) { $router = new Router($app['config.loader'], sprintf(self::CONFIG_ROUTES_FILE, $app['env']), $options); return $router->getRouteCollection(); }; }
public function onKernelRequest(GetResponseEvent $event) { if ($event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) { return; } $request = $event->getRequest(); $fc_form = $this->form_service->guessFcForm($request); if (!$fc_form instanceof FcForm) { return; } if ($fc_form->getAction()) { return; } /** @var FormInterface $form */ $form = $this->form_service->create($fc_form); $form->handleRequest($request); if ($form->isValid()) { $data = $form->getData(); $this->form_service->clear($fc_form, array('template' => $data['_template'], 'data' => $this->form_service->initData($data))); if ($fc_form->getIsAjax()) { return; } if ($fc_form->getMessage()) { $message = $fc_form->getMessage(); } else { $message = $this->translator->trans('fc.message.form.is_valid', array(), 'FenrizbesFormConstructorBundle'); } // TODO: Связывать сообщение с конкретной формой и подчищать старые $this->session->getFlashBag()->add('fc_form.success', $message); $response = new RedirectResponse($this->router->generate($request->get('_route'), $request->get('_route_params'))); $event->setResponse($response); } }
/** * @param GetResponseEvent $event */ public function onKernelRequest(GetResponseEvent $event) { // don't redirect in dev if ($this->isDebug) { return; } $request = $event->getRequest(); $locale = $request->attributes->get('_locale'); // nothing to do here, not a URL that has to do with _locale route param if (null === $locale) { return; } // locale exists and is enabled, nothing to do here - return; if ($this->manager->isLocaleEnabled($locale)) { return; } $route = $request->attributes->get('_route'); // no route found, nothing to do here - return; and let the 404 handler do its job if (null === $route) { return; } $params = array_replace_recursive($request->attributes->get('_route_params', []), ['_locale' => $this->usePreferredLocale ? $this->manager->getPreferredLocale() : $this->manager->getDefaultLocale()]); // generate a url for the same route with the same params, but with the default locale $url = $this->router->generate($route, $params, UrlGeneratorInterface::ABSOLUTE_URL); // append query string if any $qs = $request->getQueryString(); if ($qs) { $url = $url . '?' . $qs; } $response = new RedirectResponse($url, Response::HTTP_FOUND); $event->setResponse($response); }
public function handle(GetResponseEvent $event) { $request = $event->getRequest(); $wsseHeader = $request->headers->get(self::WSSE_HEADER, false); if (!$wsseHeader || 1 !== preg_match(self::WSSE_REGEX, $wsseHeader, $matches)) { $event->setResponse(new Response('', Response::HTTP_FORBIDDEN, array('WWW-Authenticate' => 'WSSE realm="webservice", profile="ApplicationToken"'))); return; } $token = new TelenorUserToken($this->providerKey, $matches[2], $matches[3], $matches[4]); $token->setUser($matches[1]); try { $authenticatedToken = $this->authenticationManager->authenticate($token); $this->securityContext->setToken($authenticatedToken); return; } catch (NonceExpiredException $failed) { $this->logger->debug("Nonce expired: " . $wsseHeader); } catch (AuthenticationException $failed) { $this->logger->debug("Authentication failed: " . $failed->getMessage()); } $token = $this->securityContext->getToken(); if ($token instanceof TelenorUserToken) { $this->securityContext->setToken(null); } $response = new Response("", Response::HTTP_UNAUTHORIZED, array(Headers::LOCATION => $this->router->generate('telenor.authentication.login'))); $event->setResponse($response); }
public function __construct(Router $router, ContainerInterface $container) { $this->routeCollection = $router->getRouteCollection(); $this->translator = $container->get('translator'); $this->translationDomain = $container->getParameter('symfonian_id.admin.translation_domain'); $this->authorizationChecker = $container->get('security.authorization_checker'); }
function it_should_create_translations_tools_menu(MenuEvent $menuEvent, Router $router) { $menuItem = new Item(); $menuEvent->getMenu()->willReturn($menuItem); $router->generate('some_admin_route', array('locale' => 'en', 'element' => 'element'), UrlGeneratorInterface::ABSOLUTE_PATH)->willReturn('/admin/en/list/element'); $router->generate('some_admin_route', array('locale' => 'pl', 'element' => 'element'), UrlGeneratorInterface::ABSOLUTE_PATH)->willReturn('/admin/pl/list/element'); $router->generate('some_admin_route', array('locale' => 'de', 'element' => 'element'), UrlGeneratorInterface::ABSOLUTE_PATH)->willReturn('/admin/de/list/element'); $this->createTranslationLocaleMenu($menuEvent); $rootItem = $menuItem->getChildren(); $translationLocale = $rootItem['translation-locale']; expect($translationLocale->getLabel())->toBe('Menu label'); expect($translationLocale->getOption('attr'))->toHaveOption('id', 'translatable-switcher'); /** @var \FSi\Bundle\AdminBundle\Menu\Item\RoutableItem[] $subItems */ $subItems = $translationLocale->getChildren(); $localePl = $subItems['translation-locale.pl']; $localeEn = $subItems['translation-locale.en']; $localeDe = $subItems['translation-locale.de']; expect($localePl->getLabel())->toBe('Polish'); expect($localePl->getRoute())->toBe('admin_translatable_list'); expect($localePl->getRouteParameters())->toBe(array('element' => 'event', 'locale' => 'pl', 'param1' => 'val1', 'redirect_uri' => '/admin/pl/list/element?param=value')); expect($translationLocale->getOption('attr'))->toNotHaveOption('class', 'active'); expect($localeEn->getLabel())->toBe('English'); expect($localeEn->getRoute())->toBe('admin_translatable_list'); expect($localeEn->getRouteParameters())->toBe(array('element' => 'event', 'locale' => 'en', 'param1' => 'val1', 'redirect_uri' => '/admin/en/list/element?param=value')); expect($translationLocale->getOption('attr'))->toNotHaveOption('class', 'active'); expect($localeDe->getLabel())->toBe('German'); expect($localeDe->getRoute())->toBe('admin_translatable_list'); expect($localeDe->getRouteParameters())->toBe(array('element' => 'event', 'locale' => 'de', 'param1' => 'val1', 'redirect_uri' => '/admin/de/list/element?param=value')); expect($translationLocale->getOption('attr'))->toNotHaveOption('class', 'active'); }
/** * @param GetResponseEvent $event */ public function onKernelRequest(GetResponseEvent $event) { $request = $event->getRequest(); $host = $request->getHost(); $baseHost = $this->baseHost; $subdomain = str_replace('.' . $baseHost, '', $host); //Check subDomain $this->checkOldDomains($subdomain); //Fix logout bug $str = $baseHost . "/login"; if ($host != $baseHost && strstr($request->getUri(), $str, true)) { $event->setResponse(new RedirectResponse($this->router->generate('buddy_system_user_homepage_index'))); } //Fix dashboard error if ($this->security_context->getToken() && $this->security_context->isGranted('IS_AUTHENTICATED_REMEMBERED') && $request->get('_route') == 'buddy_system_user_homepage_index') { $this->checkSectionAccess(); $this->activityManager->setUser($this->security_context); $this->activityManager->login(); if ($this->security_context->isGranted('ROLE_ADMIN') || $this->security_context->isGranted('ROLE_SUPER_ADMIN')) { $event->setResponse(new RedirectResponse($this->router->generate('buddy_system_sadmin_homepage'))); } else { if ($this->security_context->isGranted('ROLE_BUDDYCOORDINATOR')) { $event->setResponse(new RedirectResponse($this->router->generate('buddy_system_admin_homepage'))); } else { $event->setResponse(new RedirectResponse($this->router->generate('buddy_system_members_homepage'))); } } } if ($host == $baseHost) { if ($request->get('_route') != null && $request->get('_route') != "buddy_system_choose" && $request->get('_route') != "buddy_system_front_change_language_ajax") { $event->setResponse(new RedirectResponse($this->router->generate('buddy_system_choose'))); } } else { //Redirection when /en or /fr at the end $url = $request->getUri(); if (substr($url, -3) == "/fr" || substr($url, -3) == "/en") { $event->setResponse(new RedirectResponse(substr($url, 0, strlen($url) - 3))); } //Add Section to local if (!$this->sectionManager->getCurrentSection()) { /** @var Section $section */ $section = $this->em->getRepository('BuddySystemMainBundle:Section')->findOneBy(array('subdomain' => $subdomain)); //Fix error on www if (!$section && $subdomain == "www") { header('Location: http://buddysystem.eu'); } if (!$section) { throw new NotFoundHttpException(sprintf('Cannot find section for host "%s", subdomain "%s"', $host, $subdomain)); } if (!array_key_exists('section', $this->twig->getGlobals())) { $this->twig->addGlobal('section', $section); } $this->sectionManager->setCurrentSection($section); } } if ($this->security_context->getToken() && $this->security_context->getToken()->getUser() && $this->sectionManager->getCurrentSection()) { $this->checkSectionAccess(); } }
public function sendWelcomeEmail(User $user) { $token = $this->tokenGenerator->generateToken(); $link = $this->router->generate('fos_user_registration_register', array('token' => $token), true); $this->mailer->sendMail($this->translator->trans('jwkh.publishers.email.welcome.subject', array(), null, $user->getPublisher()->getCongregation()->getDefaultLocale()), '*****@*****.**', $user->getEmail(), $this->translator->trans('jwkh.publishers.email.welcome.body', array('%link%' => $link), null, $user->getPublisher()->getCongregation()->getDefaultLocale())); $user->setConfirmationToken($token); $this->userManager->updateUser($user); }
public function testIndexAction() { $this->adminAuth(); $uri = $this->router->generate('rx_admin_pas_interfaces_file_index'); $crawler = $this->client->request('GET', $uri); $response = $this->client->getResponse(); $this->assertEquals(200, $response->getStatusCode(), 'Status code of "admin-pas-interfaces" must be 200.'); }
public function create($clave, $name, $code, $terminal, $transactiontype, $provider, $paymethod) { $signature = new Signature($clave, $name, $code, $terminal, $transactiontype, $provider, $paymethod); $signature->setUrl($this->router->generate('rc_servired_done', array(), true)); $signature->setUrlOK($this->router->generate('rc_servired_success', array(), true)); $signature->setUrlKO($this->router->generate('rc_servired_failed', array(), true)); return $signature; }
/** * @param RouterInterface $router */ public function __construct(Router $router) { /** * @var UrlGenerator $urlGenerator */ $urlGenerator = $router->getGenerator(); $this->urlGenerator = $urlGenerator; }
/** * SiteMapService constructor. * * @param EntityManager $em * @param Router $router */ public function __construct(EntityManager $em, $router) { $this->em = $em; $this->router = $router; $this->routes = $this->router->getRouteCollection()->all(); $this->siteMapOptionService = new SiteMapOptionService(); $this->siteMapControllerService = new SiteMapControllerService($em, $router); }
public function __construct(Request $request, Router $router) { parent::__construct(); $this->setCurrentUri($request->getRequestUri()); $this->addChild('Overview', $router->generate('dashboard')); $this->addChild('Calendar', $router->generate('dashboard_calendar')); $this->addChild('Other', 'http://www.stormid.com'); }
/** * @inheritdoc */ public function getBreadcrumb(Router $router, ContainerInterface $container, $tab, $locale) { $breadcrumb = [Translator::getInstance()->trans('Home') => $router->generate('admin.home.view', [], Router::ABSOLUTE_URL), Translator::getInstance()->trans('Brand') => $router->generate('admin.brand.default', [], Router::ABSOLUTE_URL)]; if (null !== ($brand = BrandQuery::create()->findPk($this->getBrandId()))) { $breadcrumb[$brand->setLocale($locale)->getTitle()] = sprintf("%s?current_tab=%s", $router->generate('admin.brand.update', ['brand_id' => $brand->getId()], Router::ABSOLUTE_URL), $tab); } return $breadcrumb; }
public function renderDeviceRoom(DeviceInterface $device) { $rooms = explode(',', $device->getAttribute('room')->getValue()); foreach ($rooms as &$room) { $room = '<a href="' . $this->router->generate('frontend.default.room', array('name' => $room)) . '">' . $room . '</a>'; } return implode(', ', $rooms); }
/** * @param null $data * @param array $options * @return \Symfony\Component\Form\Form */ public function getLoginForm($data = null, array $options = []) { $options['last_username'] = $this->authenticationUtils->getLastUsername(); if (!array_key_exists('action', $options)) { $options['action'] = $this->router->generate('security_login_check'); } return $this->formFactory->create(LoginType::class, $data, $options); }
/** * @return string */ public function renderTagRss() { $rss = array(); foreach ($this->tagManager->findBy(array('enabled' => true)) as $tag) { $rss[] = sprintf('<link href="%s" title="%s : %s" type="application/rss+xml" rel="alternate" />', $this->router->generate('sonata_news_tag', array('tag' => $tag->getSlug(), '_format' => 'rss'), true), $this->blog->getTitle(), $tag->getName()); } return implode("\n", $rss); }
public function __construct(Request $request, Router $router) { parent::__construct(); $this->setCurrentUri($request->getRequestUri()); $this->addChild('Admin', $router->generate('admin')); $this->addChild('Sign out', $router->generate('_security_logout')); $this->setAttributes(array('id' => 'tools-menu', 'class' => 'menu')); }
/** * Generating entity route controllers by actual route and repository name. * * @param mixed $route actual route. * @param mixed $sitemapInfo sitemap information: repository name, lastmod, priority, changefreq * @return mixed generated route controllers for entity repository. */ private function generateEntityRouteControllers($route, $sitemapInfo) { $result = array(); $limit = $this->countEntities($sitemapInfo['repository']); for ($i = 1; $i <= $limit; $i++) { $result[] = array('url' => $this->router->generate($route) . $i, 'lastmod' => $sitemapInfo['lastmod'], 'changefreq' => $sitemapInfo['changefreq'], 'priority' => $sitemapInfo['priority']); } return $result; }
/** * The event listener, which handles all the logic of the service. * * @param GetResponseEvent $getResponseEvent */ public function onRequest(GetResponseEvent $getResponseEvent) { $route = $getResponseEvent->getRequest()->get('_route'); if (in_array($route, array('php_sanitizer_user_login', 'php_sanitizer_user_register')) && $this->authorizationChecker->isGranted('IS_AUTHENTICATED_FULLY')) { // If the current request takes place on the login or on the register pages, redirect the user // to the configured route. $getResponseEvent->setResponse(new RedirectResponse($this->router->generate($this->redirectRoute))); } }
/** * This is called when an interactive authentication attempt succeeds. This * is called by authentication listeners inheriting from * AbstractAuthenticationListener. * * @param Request $request * @param TokenInterface $token * * @return Response never null */ public function onAuthenticationSuccess(Request $request, TokenInterface $token) { $referer = $request->headers->get('referer'); if (empty($referer)) { return new RedirectResponse($this->router->generate('claro_desktop_open_tool', array('toolName' => 'home'))); } else { return new RedirectResponse($referer); } }