Inheritance: extends Symfony\Component\Routing\Router
Esempio n. 1
0
 /**
  * Constructor
  * Initialize some default items.
  *
  * @param Router $router
  */
 public function __construct(Router $router)
 {
     $this->items = array();
     $this->lastPosition = 0;
     $this->separatorCount = 0;
     $this->add('base.user.menu.admin')->setIcon('gear.png')->setUrl($router->generate('orga_admin'))->end()->add('base.user.menu.members')->setIcon('users.png')->setUrl($router->generate('orga_admin_members'))->end()->add('base.user.menu.logout')->setIcon('control-power.png')->setUrl($router->generate('user_disconnect'))->end()->addSeparator()->add('base.user.menu.help')->setIcon('question.png')->setUrl('')->end();
 }
Esempio n. 2
0
 /**
  * Check request to decide if user has access to specific route
  *
  * @param GetResponseEvent $event
  * @throws AccessDeniedException
  * @throws InvalidRouteException
  * @throws UserNotFoundException
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     $routeName = $event->getRequest()->get("_route");
     if (strpos($routeName, "app_default_") === 0) {
         throw new InvalidRouteException();
     }
     $routeCollection = $this->router->getRouteCollection();
     $route = $routeCollection->get($routeName);
     if ($route instanceof Route) {
         //Check if need to validate route
         //Sometime we want to allow access without validation: index page, login page
         $accessValidation = $route->getOption('access_validation');
         if ($accessValidation === false) {
             return;
         }
         //Validate current user access to route
         $this->authentication->setCurrentUser($this->request->get("token"));
         $user = $this->authentication->getCurrentUser();
         if (!$user instanceof User) {
             throw new UserNotFoundException();
         }
         $access = $this->accessService->checkPermissions($user, $routeName);
         if ($access === false) {
             throw new AccessDeniedException($user, $routeName);
         }
     }
 }
Esempio n. 3
0
 /**
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if (!$this->installed) {
         return;
     }
     $request = $event->getRequest();
     if ($request->attributes->has('_controller') || $event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) {
         return;
     }
     $slugUrl = $request->getPathInfo();
     if ($slugUrl !== '/') {
         $slugUrl = rtrim($slugUrl, '/');
     }
     /** @var EntityManager $em */
     $em = $this->registry->getManagerForClass('OroB2BRedirectBundle:Slug');
     $slug = $em->getRepository('OroB2BRedirectBundle:Slug')->findOneBy(['url' => $slugUrl]);
     if ($slug) {
         $routeName = $slug->getRouteName();
         $controller = $this->router->getRouteCollection()->get($routeName)->getDefault('_controller');
         $parameters = [];
         $parameters['_route'] = $routeName;
         $parameters['_controller'] = $controller;
         $redirectRouteParameters = $slug->getRouteParameters();
         $parameters = array_merge($parameters, $redirectRouteParameters);
         $parameters['_route_params'] = $redirectRouteParameters;
         $request->attributes->add($parameters);
     }
 }
Esempio n. 4
0
 private function generateTabsView($fieldTranslations, $field, $isKeywords = false)
 {
     $template = '<ul id="tabs" class="nav nav-tabs" data-tabs="tabs">';
     $i = 0;
     foreach ($fieldTranslations as $langCode => $translationValue) {
         if ($i == 0) {
             $template .= '<li class="active"><a href="#' . $field . '-' . $langCode . '" data-toggle="tab">' . $langCode . '</a></li>';
         } else {
             $template .= '<li><a href="#' . $field . '-' . $langCode . '" data-toggle="tab">' . $langCode . '</a></li>';
         }
         $i++;
     }
     $template .= '</ul><div id="my-tab-content" class="tab-content">';
     $t = 0;
     foreach ($fieldTranslations as $langCode => $translationValue) {
         $activeString = $t == 0 ? 'active' : '';
         $template .= '<div class="tab-pane ' . $activeString . '" id="' . $field . '-' . $langCode . '">';
         if ($isKeywords) {
             $explodeValue = explode(',', $translationValue);
             $i = 0;
             foreach ($explodeValue as $explodeItem) {
                 $commaSign = $i != 0 ? ',' : '';
                 $template .= $commaSign . '<a href="' . $this->router->generate('ojs_search_index', ['q' => $explodeItem]) . '" target="_blank">' . $explodeItem . '</a>';
                 $i++;
             }
         } else {
             $template .= $translationValue;
         }
         $template .= '</div>';
         $t++;
     }
     $template .= '</div>';
     return $template;
 }
 /**
  * add a rel=self Link header to the response
  *
  * @param FilterResponseEvent $event response listener event
  *
  * @return void
  */
 public function onKernelResponse(FilterResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         // don't do anything if it's not the master request
         return;
     }
     $response = $event->getResponse();
     $request = $event->getRequest();
     $linkHeader = LinkHeader::fromResponse($response);
     // extract various info from route
     $routeName = $request->get('_route');
     $routeParts = explode('.', $routeName);
     $routeType = end($routeParts);
     if ($routeType == 'post') {
         $routeName = substr($routeName, 0, -4) . 'get';
     }
     /** if the request failed in the RestController, $request will not have an record id in
         case of a POST and $router->generate() will fail. that's why we catch it and fail silently
         by not including our header in the response. i hope that's a good compromise. **/
     /** Nope, it's not a good compromise...catch and handle it where it happens.
      *  I will refactory this in another branch*/
     $addHeader = true;
     $url = '';
     try {
         $url = $this->router->generate($routeName, $this->generateParameters($routeType, $request), true);
     } catch (\Exception $e) {
         $addHeader = false;
     }
     if ($addHeader) {
         // append rel=self link to link headers
         $linkHeader->add(new LinkHeaderItem($url, array('rel' => 'self')));
         // overwrite link headers with new headers
         $response->headers->set('Link', (string) $linkHeader);
     }
 }
Esempio n. 6
0
 /**
  * @DI\Observe("badge-resource-icap_wiki-section_create-generate_validation_link")
  * @DI\Observe("badge-resource-icap_wiki-section_delete-generate_validation_link")
  * @DI\Observe("badge-resource-icap_wiki-section_move-generate_validation_link")
  * @DI\Observe("badge-resource-icap_wiki-section_remove-generate_validation_link")
  * @DI\Observe("badge-resource-icap_wiki-section_restore-generate_validation_link")
  * @DI\Observe("badge-resource-icap_wiki-section_update-generate_validation_link")
  * @DI\Observe("badge-resource-icap_wiki-contribution_create-generate_validation_link")
  */
 public function onBagdeCreateValidationLink($event)
 {
     $content = null;
     $log = $event->getLog();
     switch ($log->getAction()) {
         case LogSectionCreateEvent::ACTION:
         case LogSectionDeleteEvent::ACTION:
         case LogSectionMoveEvent::ACTION:
         case LogSectionRemoveEvent::ACTION:
         case LogSectionRestoreEvent::ACTION:
         case LogSectionUpdateEvent::ACTION:
             $logDetails = $event->getLog()->getDetails();
             $parameters = array('wikiId' => $logDetails['section']['wiki']);
             $sectionAnchor = sprintf('#section-%s', $logDetails['section']['id']);
             $url = $this->router->generate('icap_wiki_view', $parameters, UrlGeneratorInterface::ABSOLUTE_PATH);
             $title = $logDetails['section']['title'];
             $content = sprintf('<a href="%s%s" title="%s">%s</a>', $url, $sectionAnchor, $title, $title);
             break;
         case LogContributionCreateEvent::ACTION:
             $logDetails = $event->getLog()->getDetails();
             $parameters = array('wikiId' => $logDetails['contribution']['wiki']);
             $sectionAnchor = sprintf('#section-%s', $logDetails['contribution']['section']);
             $url = $this->router->generate('icap_wiki_view', $parameters, UrlGeneratorInterface::ABSOLUTE_PATH);
             $title = $logDetails['contribution']['title'];
             $content = sprintf('<a href="%s%s" title="%s">%s</a>', $url, $sectionAnchor, $title, $title);
             break;
     }
     $event->setContent($content);
     $event->stopPropagation();
 }
 /**
  * @depends testPut
  */
 public function testDeleteMultiple()
 {
     $data = [2, 3];
     $uri = self::$router->generate('post_assets') . '.json';
     self::$client->request('DELETE', $uri, ['images' => json_encode($data)]);
     $this->assertTrue(self::$client->getResponse()->isRedirect());
 }
Esempio n. 8
0
 public function testPlaceholders()
 {
     $routes = new RouteCollection();
     $routes->add('foo', new Route('/foo', array('foo' => '%foo%', 'bar' => '%bar%', 'foobar' => 'foobar', 'foo1' => '%foo', 'foo2' => 'foo%', 'foo3' => 'f%o%o'), array('foo' => '%foo%', 'bar' => '%bar%', 'foobar' => 'foobar', 'foo1' => '%foo', 'foo2' => 'foo%', 'foo3' => 'f%o%o')));
     $sc = $this->getServiceContainer($routes);
     $sc->expects($this->at(1))->method('hasParameter')->will($this->returnValue(false));
     $sc->expects($this->at(2))->method('hasParameter')->will($this->returnValue(true));
     $sc->expects($this->at(3))->method('getParameter')->will($this->returnValue('bar'));
     $sc->expects($this->at(4))->method('hasParameter')->will($this->returnValue(false));
     $sc->expects($this->at(5))->method('hasParameter')->will($this->returnValue(true));
     $sc->expects($this->at(6))->method('getParameter')->will($this->returnValue('bar'));
     $router = new Router($sc, 'foo');
     $route = $router->getRouteCollection()->get('foo');
     $this->assertEquals('%foo%', $route->getDefault('foo'));
     $this->assertEquals('bar', $route->getDefault('bar'));
     $this->assertEquals('foobar', $route->getDefault('foobar'));
     $this->assertEquals('%foo', $route->getDefault('foo1'));
     $this->assertEquals('foo%', $route->getDefault('foo2'));
     $this->assertEquals('f%o%o', $route->getDefault('foo3'));
     $this->assertEquals('%foo%', $route->getRequirement('foo'));
     $this->assertEquals('bar', $route->getRequirement('bar'));
     $this->assertEquals('foobar', $route->getRequirement('foobar'));
     $this->assertEquals('%foo', $route->getRequirement('foo1'));
     $this->assertEquals('foo%', $route->getRequirement('foo2'));
     $this->assertEquals('f%o%o', $route->getRequirement('foo3'));
 }
Esempio n. 9
0
 /**
  * @return string
  */
 public function generateLinkChangePassword()
 {
     if (null === $this->webHomeAuthUrl) {
         return $this->router->generate('app_home_change_password');
     }
     return $this->webHomeAuthUrl . '/change-password';
 }
Esempio n. 10
0
 /**
  * @DI\Observe("badge-resource-icap_dropzone-correction_delete-generate_validation_link")
  * @DI\Observe("badge-resource-icap_dropzone-correction_end-generate_validation_link")
  * @DI\Observe("badge-resource-icap_dropzone-correction_start-generate_validation_link")
  * @DI\Observe("badge-resource-icap_dropzone-correction_update-generate_validation_link")
  * @DI\Observe("badge-resource-icap_dropzone-correction_validation_change-generate_validation_link")
  * @DI\Observe("badge-resource-icap_dropzone-criterion_create-generate_validation_link")
  * @DI\Observe("badge-resource-icap_dropzone-criterion_delete-generate_validation_link")
  * @DI\Observe("badge-resource-icap_dropzone-criterion_update-generate_validation_link")
  * @DI\Observe("badge-resource-icap_dropzone-document_create-generate_validation_link")
  * @DI\Observe("badge-resource-icap_dropzone-document_delete-generate_validation_link")
  * @DI\Observe("badge-resource-icap_dropzone-document_open-generate_validation_link")
  * @DI\Observe("badge-resource-icap_dropzone-drop_end-generate_validation_link")
  * @DI\Observe("badge-resource-icap_dropzone-drop_evaluate-generate_validation_link")
  * @DI\Observe("badge-resource-icap_dropzone-drop_start-generate_validation_link")
  * @DI\Observe("badge-resource-icap_dropzone-dropzone_configure-generate_validation_link")
  */
 public function onBagdeCreateValidationLink($event)
 {
     $content = null;
     $log = $event->getLog();
     switch ($log->getAction()) {
         case LogCorrectionDeleteEvent::ACTION:
         case LogCorrectionEndEvent::ACTION:
         case LogCorrectionStartEvent::ACTION:
         case LogCorrectionUpdateEvent::ACTION:
         case LogCorrectionValidationChangeEvent::ACTION:
         case LogCriterionCreateEvent::ACTION:
         case LogCriterionDeleteEvent::ACTION:
         case LogCriterionUpdateEvent::ACTION:
         case LogDocumentCreateEvent::ACTION:
         case LogDocumentDeleteEvent::ACTION:
         case LogDocumentOpenEvent::ACTION:
         case LogDropEndEvent::ACTION:
         case LogDropEvaluateEvent::ACTION:
         case LogDropStartEvent::ACTION:
         case LogDropzoneConfigureEvent::ACTION:
             $logDetails = $event->getLog()->getDetails();
             $parameters = array('resourceId' => $logDetails['dropzone']['id']);
             $url = $this->router->generate('icap_dropzone_open', $parameters, UrlGeneratorInterface::ABSOLUTE_PATH);
             /** @var Dropzone $dropzone */
             $dropzone = $this->entityManager->getRepository('IcapDropzoneBundle:Dropzone')->findOneById($logDetails['dropzone']['id']);
             $title = $dropzone->getResourceNode()->getName();
             $content = sprintf('<a href="%s" title="%s">%s</a>', $url, $title, $title);
             break;
     }
     $event->setContent($content);
     $event->stopPropagation();
 }
Esempio n. 11
0
 /**
  * @param array $material
  * @return UserMaterial[]
  */
 public function create(array $material)
 {
     if (array_key_exists('filename', $material) && !empty($material['filename'])) {
         $absoluteFileUri = $this->router->generate('ilios_core_downloadlearningmaterial', ['token' => $material['token']], UrlGenerator::ABSOLUTE_URL);
     }
     /* @var UserMaterial $obj */
     $obj = new $this->decoratorClassName();
     $obj->id = $material['id'];
     $obj->session = isset($material['sessionId']) ? $material['sessionId'] : null;
     $obj->course = isset($material['courseId']) ? $material['courseId'] : null;
     $obj->sessionTitle = isset($material['sessionTitle']) ? $material['sessionTitle'] : null;
     $obj->courseTitle = isset($material['courseTitle']) ? $material['courseTitle'] : null;
     $obj->firstOfferingDate = isset($material['firstOfferingDate']) ? $material['firstOfferingDate'] : null;
     if ($material['publicNotes']) {
         $obj->publicNotes = $material['notes'];
     }
     $obj->required = $material['required'];
     $obj->title = $material['title'];
     $obj->description = $material['description'];
     $obj->originalAuthor = $material['originalAuthor'];
     $obj->absoluteFileUri = isset($absoluteFileUri) ? $absoluteFileUri : null;
     $obj->citation = $material['citation'];
     $obj->link = $material['link'];
     $obj->filename = $material['filename'];
     $obj->mimetype = $material['mimetype'];
     return $obj;
 }
Esempio n. 12
0
 /**
  * @DI\Observe("badge-resource-icap_blog-post_create-generate_validation_link")
  * @DI\Observe("badge-resource-icap_blog-post_delete-generate_validation_link")
  * @DI\Observe("badge-resource-icap_blog-post_read-generate_validation_link")
  * @DI\Observe("badge-resource-icap_blog-post_update-generate_validation_link")
  * @DI\Observe("badge-resource-icap_blog-comment_create-generate_validation_link")
  * @DI\Observe("badge-resource-icap_blog-comment_delete-generate_validation_link")
  */
 public function onBagdeCreateValidationLink($event)
 {
     $content = null;
     $log = $event->getLog();
     switch ($log->getAction()) {
         case LogPostCreateEvent::ACTION:
         case LogPostDeleteEvent::ACTION:
         case LogPostReadEvent::ACTION:
         case LogPostUpdateEvent::ACTION:
             $logDetails = $event->getLog()->getDetails();
             $parameters = array('blogId' => $logDetails['post']['blog'], 'postSlug' => $logDetails['post']['slug']);
             $url = $this->router->generate('icap_blog_post_view', $parameters, UrlGeneratorInterface::ABSOLUTE_PATH);
             $title = $logDetails['post']['title'];
             $content = sprintf('<a href="%s" title="%s">%s</a>', $url, $title, $title);
             break;
         case LogCommentCreateEvent::ACTION:
         case LogCommentDeleteEvent::ACTION:
             $logDetails = $event->getLog()->getDetails();
             $parameters = array('blogId' => $logDetails['post']['blog'], 'postSlug' => $logDetails['post']['slug']);
             $url = $this->router->generate('icap_blog_post_view', $parameters, UrlGeneratorInterface::ABSOLUTE_PATH);
             $title = $logDetails['post']['title'];
             $anchor = isset($logDetails['comment']['id']) ? '#comment-' . $logDetails['comment']['id'] : '';
             $content = sprintf('<a href="%s%s" title="%s">%s</a>', $url, $anchor, $title, $title);
             break;
     }
     $event->setContent($content);
     $event->stopPropagation();
 }
Esempio n. 13
0
 /**
  * @throws \LogicException
  *
  * @param mixed $data
  *
  * @return string
  */
 public function getLinkForFill($data)
 {
     if (!$this->router instanceof Router) {
         throw new \LogicException('Link cannot be built without a Router');
     }
     return $this->router->generate('fill_filler', ['plugin' => $this->getName(), $this->getForm()->getName() => ['url' => $data]]);
 }
Esempio n. 14
0
 /**
  * @param BadgeUnlockEvent $event
  */
 public function onUnlockBadge(BadgeUnlockEvent $event)
 {
     $unlockedBadge = $event->getUnlockedBadge();
     $user = $unlockedBadge->getUser();
     $badge = $unlockedBadge->getBadge();
     $data = ['text' => sprintf('<%s|%s> just unlocked the badge <%s|%s>!', $this->router->generate('userprofile', ['username' => $user->getUsername()], UrlGeneratorInterface::ABSOLUTE_URL), $user->getUsername(), $this->router->generate('viewbadge', ['id' => $badge->getId()], UrlGeneratorInterface::ABSOLUTE_URL), $badge->getTitle()), 'attachments' => [['color' => 'good', 'title' => $badge->getTitle(), 'text' => $badge->getDescription(), 'thumb_url' => $this->router->generate('homepage', [], UrlGeneratorInterface::ABSOLUTE_URL) . $badge->getImageWebPath()]]];
     $this->notifier->notify($data);
 }
 public function testIndexThereIsRequiredStepsAction()
 {
     $this->authenticateUser('ria', array('ROLE_RIA', 'ROLE_RIA_BASE', 'ROLE_ADMIN'));
     $crawler = $this->client->request('GET', $this->router->generate('rx_ria_dashboard'));
     $this->assertEquals(200, $this->client->getResponse()->getStatusCode(), 'Dashboard is available to see');
     $this->assertEquals(1, $crawler->filter('html:contains("You must complete the following steps before wealthbot.io will be ready to use")')->count(), 'Dashboard have notification area');
     $this->assertEquals(1, $crawler->filter('html:contains("Create billing specs")')->count(), 'There is a billing information in notication area');
 }
 /**
  * @param Request $request
  * @param TokenInterface $token
  * @return RedirectResponse
  */
 public function onAuthenticationSuccess(Request $request, TokenInterface $token)
 {
     if ($this->security->isGranted('ROLE_ADMIN')) {
         return new RedirectResponse($this->router->generate('admin_index'));
     } else {
         return new RedirectResponse($this->router->generate('blog_index'));
     }
 }
 public function onKernelRequest(GetResponseEvent $event)
 {
     if ($id = $event->getRequest()->attributes->get('customer_id')) {
         $this->router->getContext()->setParameter('customer_id', $id);
     } else {
         // maybe redirect by passing a RedirectResponse to $event->setResponse()
     }
 }
 /**
  * @return array
  * @throw InvalidConfigurationException
  */
 public function getRoleConfig()
 {
     $prefix = "vss_oauth_extension.auth.role";
     if (!$this->container->getParameter("{$prefix}.client_id")) {
         throw new InvalidConfigurationException("No {$prefix} node configured.");
     }
     return ['client_id' => $this->container->getParameter("{$prefix}.client_id"), 'client_secret' => $this->container->getParameter("{$prefix}.client_secret"), 'endpoint' => $this->container->getParameter("{$prefix}.endpoint"), 'logout_path' => $this->router->generate($this->container->getParameter("{$prefix}.logout_path"))];
 }
 /**
  * @dataProvider getTestPlaceholderData
  */
 public function testPlaceholder($expected, $parameters)
 {
     $routes = new RouteCollection();
     $routes->add('foo', new Route('/foo/{foo}/', array('foo' => '123'), array()));
     $container = $this->getServiceContainer($routes);
     $router = new Router($container, 'foo', array('generator_class' => 'Hautelook\\TemplatedUriRouter\\Routing\\Generator\\Rfc6570Generator'));
     $this->assertEquals($expected, $router->generate('foo', $parameters));
 }
Esempio n. 20
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->addEventSubscriber(new CleanFormSubscriber());
     $builder->addEventSubscriber(new FormExitSubscriber('api.client', $options));
     if (!$options['data']->getId()) {
         $builder->add('api_mode', 'choice', array('mapped' => false, 'label' => 'mautic.api.client.form.auth_protocol', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'onchange' => 'Mautic.refreshApiClientForm(\'' . $this->router->generate('mautic_client_action', array('objectAction' => 'new')) . '\', this)'), 'choices' => array('oauth1a' => 'OAuth 1.0a', 'oauth2' => 'OAuth 2'), 'required' => false, 'empty_value' => false, 'data' => $this->apiMode));
     }
     $builder->add('name', 'text', array('label' => 'mautic.core.name', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control')));
     if ($this->apiMode == 'oauth2') {
         $arrayStringTransformer = new Transformers\ArrayStringTransformer();
         $builder->add($builder->create('redirectUris', 'text', array('label' => 'mautic.api.client.redirecturis', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.api.client.form.help.requesturis')))->addViewTransformer($arrayStringTransformer));
         $builder->add('publicId', 'text', array('label' => 'mautic.api.client.form.clientid', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control'), 'disabled' => true, 'required' => false, 'mapped' => false, 'data' => $options['data']->getPublicId()));
         $builder->add('secret', 'text', array('label' => 'mautic.api.client.form.clientsecret', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control'), 'disabled' => true, 'required' => false));
         $translator = $this->translator;
         $validator = $this->validator;
         $builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) use($translator, $validator) {
             $form = $event->getForm();
             $data = $event->getData();
             if ($form->has('redirectUris')) {
                 foreach ($data->getRedirectUris() as $uri) {
                     $urlConstraint = new OAuthCallback();
                     $urlConstraint->message = $translator->trans('mautic.api.client.redirecturl.invalid', array('%url%' => $uri), 'validators');
                     $errors = $validator->validateValue($uri, $urlConstraint);
                     if (!empty($errors)) {
                         foreach ($errors as $error) {
                             $form['redirectUris']->addError(new FormError($error->getMessage()));
                         }
                     }
                 }
             }
         });
     } else {
         $builder->add($builder->create('callback', 'text', array('label' => 'mautic.api.client.form.callback', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.api.client.form.help.callback'), 'required' => false))->addModelTransformer(new Transformers\NullToEmptyTransformer()));
         $builder->add('consumerKey', 'text', array('label' => 'mautic.api.client.form.consumerkey', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'onclick' => 'this.setSelectionRange(0, this.value.length);'), 'read_only' => true, 'required' => false, 'mapped' => false, 'data' => $options['data']->getConsumerKey()));
         $builder->add('consumerSecret', 'text', array('label' => 'mautic.api.client.form.consumersecret', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'onclick' => 'this.setSelectionRange(0, this.value.length);'), 'read_only' => true, 'required' => false));
         $translator = $this->translator;
         $validator = $this->validator;
         $builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) use($translator, $validator) {
             $form = $event->getForm();
             $data = $event->getData();
             if ($form->has('callback')) {
                 $uri = $data->getCallback();
                 $urlConstraint = new OAuthCallback();
                 $urlConstraint->message = $translator->trans('mautic.api.client.redirecturl.invalid', array('%url%' => $uri), 'validators');
                 $errors = $validator->validateValue($uri, $urlConstraint);
                 if (!empty($errors)) {
                     foreach ($errors as $error) {
                         $form['callback']->addError(new FormError($error->getMessage()));
                     }
                 }
             }
         });
     }
     $builder->add('buttons', 'form_buttons');
     if (!empty($options["action"])) {
         $builder->setAction($options["action"]);
     }
 }
 /**
  * @param string $key
  * @param bool   $isOroUser
  *
  * @return string
  */
 public function renderUrl($key, $isOroUser)
 {
     $route = 'diamante_ticket_view';
     $url = $this->router->generate($route, ['key' => $key], Router::ABSOLUTE_URL);
     if (!$isOroUser) {
         $url = str_replace('desk/tickets/view', 'diamantefront/#tickets', $url);
     }
     return $url;
 }
 public function renderMenuLanguages()
 {
     $languages = $this->getDoctrine()->getRepository('BaconLanguageBundle:Language')->findAll();
     $htmlReturn = '';
     foreach ($languages as $lang) {
         $htmlReturn .= '<li><a href="' . $this->router->generate('locale_change', ['current' => $this->request->getCurrentRequest()->getLocale(), 'locale' => $lang->getAcron()]) . '"><span class="flag-icon flag-icon-' . $this->getAcronByLocale($lang->getLocale()) . '"></span>&nbsp;&nbsp;&nbsp;' . $lang->getName() . '</a></li>';
     }
     return $htmlReturn;
 }
Esempio n. 23
0
 private function handleForm(Request $request, Form $form, $id, $command)
 {
     $form->submit($request);
     if ($form->isValid()) {
         $this->handleCommand($command);
         return $this->redirectView($this->router->generate('get_game', array('id' => $id)), Codes::HTTP_CREATED);
     }
     return $form;
 }
Esempio n. 24
0
 public function __construct($clientId, $clientSecret, $version, Router $router, Session $session, TokenStorage $tokenStorage)
 {
     $this->clientId = $clientId;
     $this->clientSecret = $clientSecret;
     $this->version = $version;
     $this->redirectUri = $router->generate(C::ROUTE_VK_AUTH_TOKEN, [], UrlGeneratorInterface::ABSOLUTE_URL);
     $this->session = $session;
     $this->tokenStorage = $tokenStorage;
 }
 /**
  * @Route()
  * @Method("GET")
  *
  * @param Todo $todo
  * @return RedirectResponse
  */
 public function indexAction(Todo $todo)
 {
     try {
         $this->completeTodo->run($todo);
         $this->notification->info('タスクを完了にしました');
     } catch (\InvalidArgumentException $e) {
         $this->notification->danger('完了処理に失敗しました');
     }
     return new RedirectResponse($this->router->generate('app_todo_default_index'));
 }
Esempio n. 26
0
 /**
  * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
  * @expectedExceptionMessage  A string value must be composed of strings and/or numbers,but found parameter "object" of type object inside string value "/%object%".
  */
 public function testExceptionOnNonStringParameter()
 {
     $routes = new RouteCollection();
     $routes->add('foo', new Route('/%object%'));
     $sc = $this->getServiceContainer($routes);
     $sc->expects($this->at(1))->method('hasParameter')->with('object')->will($this->returnValue(true));
     $sc->expects($this->at(2))->method('getParameter')->with('object')->will($this->returnValue(new \stdClass()));
     $router = new Router($sc, 'foo');
     $router->getRouteCollection()->get('foo');
 }
Esempio n. 27
0
 function it_changes_media_name(ObjectEvent $event, ObjectStub $object, MediaInterface $media, Router $router)
 {
     $event->getObject()->shouldBeCalled()->willReturn($object);
     $object->getImage()->shouldBeCalled()->willReturn($media);
     $media->getName()->shouldBeCalled()->willReturn('media-name.jpg');
     $router->generate('kreta_media_image', ['name' => 'media-name.jpg'], true)->shouldBeCalled()->willReturn('http://kreta.io/media/media/media-name.jpg');
     $media->setName('http://kreta.io/media/media/media-name.jpg')->shouldBeCalled()->willReturn($media);
     $object->setImage($media)->shouldBeCalled()->willReturn($object);
     $this->onChangeObjectMedia($event);
 }
 /**
  * Initialise the PaymentOrder Model to be posted to IRIS
  */
 protected function generatePaymentOrder()
 {
     // Set the necessary data to POST to the endpoint
     // TODO: the payment types are currently hardcoded, but aren't likely to change in the near future. This will eventually need refactoring.
     $this->paymentOrder->setPaymentTypes(array(1));
     // Success: redirect to the view page of the new case
     $this->paymentOrder->setRedirectOnSuccessUrl($this->router->generate('barbon_hostedapi_landlord_reference_newreference_success_index', array(), true));
     // Failure: redirect to generic failed payment page
     $this->paymentOrder->setRedirectOnFailureUrl($this->router->generate('barbon_hostedapi_landlord_reference_newreference_failure_index', array(), true));
 }
Esempio n. 29
0
 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     parent::finishView($view, $form, $options);
     $view->vars['remote_path'] = $this->router->generate($options['remote_route'], $options['remote_params']);
     $varNames = array('minimum_input_length', 'placeholder');
     foreach ($varNames as $varName) {
         $view->vars[$varName] = $options[$varName];
     }
     $view->vars['full_name'] .= '[]';
 }
 public function testUpdateAction()
 {
     $billingSpec = $this->getLastBilling();
     $this->assertNotEquals('Test name', $billingSpec->getName());
     $this->authenticateUser('ria', array('ROLE_RIA', 'ROLE_RIA_BASE', 'ROLE_ADMIN'));
     $crawler = $this->client->request('POST', $this->router->generate('rx_ria_api_billing_specs_rest'), array('billing_spec' => array('minimalFee' => '100', 'name' => 'Test name', 'type' => BillingSpec::TYPE_TIER, 'fees' => array(0 => array('fee_without_retirement' => 23)))));
     $billingSpec = $this->getLastBilling();
     $this->assertEquals('Test name', $billingSpec->getName());
     $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
 }