/** * Configure the form submissions link on top of the form in the sub action menu * * @param ConfigureActionMenuEvent $event */ public function onSubActionMenuConfigure(ConfigureActionMenuEvent $event) { $menu = $event->getMenu(); $activeNodeVersion = $event->getActiveNodeVersion(); if (!is_null($activeNodeVersion)) { $page = $activeNodeVersion->getRef($this->em); if ($page instanceof AbstractFormPage) { $activeNodeTranslation = $activeNodeVersion->getNodeTranslation(); $menu->addChild('subaction.formsubmissions', array('uri' => $this->router->generate('KunstmaanFormBundle_formsubmissions_list', array('nodeTranslationId' => $activeNodeTranslation->getId())))); } } }
public function finishView(FormView $view, FormInterface $form, array $options) { parent::finishView($view, $form, $options); // make variables available to the view $view->vars['remote_path'] = $options['remote_path'] ?: $this->router->generate($options['remote_route'], array_merge($options['remote_params'], ['page_limit' => $options['page_limit']])); $varNames = array('multiple', 'minimum_input_length', 'placeholder', 'language'); foreach ($varNames as $varName) { $view->vars[$varName] = $options[$varName]; } if ($options['multiple']) { $view->vars['full_name'] .= '[]'; } }
/** * @method onAuthenticationFailure * * @param Request $request The request for the authentification * @param TokenInterface $token The security token * * This function will response true if the AuthenticationSuccess was proceded with Ajax * Otherwise it will redirect the user toward the a paged based on the role of the user and defined in parameters.yml */ public function onAuthenticationSuccess(Request $request, TokenInterface $token) { if ($request->isXmlHttpRequest()) { $response = new JsonResponse('true'); } else { $user = $token->getUser(); $roles = $user->getRoles(); $role = reset($roles); $referer_url = $request->headers->get('referer'); if (@array_key_exists($role, $this->routes)) { return new RedirectResponse($this->router->generate($this->routes[$role])); } return new RedirectResponse($referer_url); } return $response; }
/** * Generate url based on $name and $parameters * * @param string $name Name of the route to use. * @param array $parameters Parameters for the route * @param bool $absolute * @return string */ public function generate($name, $parameters = array(), $absolute = false) { asort($parameters); $key = $this->context->getHost() . '#' . $this->context->getBaseUrl() . $name . json_encode($parameters) . intval($absolute); if ($this->cache->hasKey($key)) { return $this->cache->get($key); } else { $url = parent::generate($name, $parameters, $absolute); $this->cache->set($key, $url, 3600); return $url; } }
<strong>Parameters:</strong> <pre><?php var_dump($route->getParameters()); ?> </pre> <?php } else { ?> <pre>No route matched.</pre> <?php } ?> <h3>Try out these URL's.</h3> <p><a href="<?php echo $router->generate('users_edit', array('id' => 5)); ?> "><?php echo $router->generate('users_edit', array('id' => 5)); ?> </a></p> <p><a href="<?php echo $router->generate('contact'); ?> "><?php echo $router->generate('contact'); ?> </a></p> <p><form action="" method="POST"><input type="submit" value="Post request to current URL" /></form></p> <p><form action="<?php echo $router->generate('users_create');
/** * Method redirects unauthorized user to beta login * @param GetResponseType $event */ private function redirectToBetaAuthentication($event) { $url = $this->router->generate('buggl_beta_login'); $event->setResponse(new RedirectResponse($url)); }