当前位置: 首页>>代码示例>>PHP>>正文


PHP Router::generate方法代码示例

本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Routing\Router::generate方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::generate方法的具体用法?PHP Router::generate怎么用?PHP Router::generate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Bundle\FrameworkBundle\Routing\Router的用法示例。


在下文中一共展示了Router::generate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onBagdeCreateValidationLink

 /**
  * @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();
 }
开发者ID:claroline,项目名称:distribution,代码行数:39,代码来源:BadgeListener.php

示例2: generateLinkChangePassword

 /**
  * @return string
  */
 public function generateLinkChangePassword()
 {
     if (null === $this->webHomeAuthUrl) {
         return $this->router->generate('app_home_change_password');
     }
     return $this->webHomeAuthUrl . '/change-password';
 }
开发者ID:nicolasdewez,项目名称:webhome-common,代码行数:10,代码来源:UserBar.php

示例3: __construct

 /**
  * 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();
 }
开发者ID:ChrisdAutume,项目名称:EtuUTT,代码行数:13,代码来源:OrgaMenuBuilder.php

示例4: testDeleteMultiple

 /**
  * @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());
 }
开发者ID:gorvelyfab,项目名称:KoopaBaseAdminer,代码行数:10,代码来源:MediaControllerTest.php

示例5: getLinkForFill

 /**
  * @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]]);
 }
开发者ID:anime-db,项目名称:catalog-bundle,代码行数:14,代码来源:Filler.php

示例6: create

 /**
  * @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;
 }
开发者ID:stopfstedt,项目名称:ilios,代码行数:31,代码来源:UserMaterialFactory.php

示例7: getPortalLink

 /**
  * @return string
  */
 public function getPortalLink()
 {
     $origContext = $this->updateRequestContext();
     $url = $this->router->generate('diamante_front', [], Router::ABSOLUTE_URL);
     $this->router->setContext($origContext);
     return $url;
 }
开发者ID:gitter-badger,项目名称:diamantedesk-application,代码行数:10,代码来源:PortalURLExtension.php

示例8: __construct

 /**
  * 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.flux')->setIcon('edit-list.png')->setUrl($router->generate('homepage'))->end()->add('base.user.menu.account')->setIcon('user.png')->setUrl($router->generate('user_profile'))->end()->add('base.user.menu.table')->setIcon('table.png')->setUrl($router->generate('user_schedule'))->end()->add('base.user.menu.orgas')->setIcon('bank.png')->setUrl($router->generate('memberships_index'))->end()->add('base.user.menu.logout')->setIcon('control-power.png')->setUrl($router->generate('user_disconnect'))->end();
 }
开发者ID:ChrisdAutume,项目名称:EtuUTT,代码行数:13,代码来源:UserMenuBuilder.php

示例9: onBagdeCreateValidationLink

 /**
  * @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();
 }
开发者ID:claroline,项目名称:distribution,代码行数:49,代码来源:BadgeListener.php

示例10: generateTabsView

 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;
 }
开发者ID:ojs,项目名称:ojs,代码行数:34,代码来源:FieldDisplayExtension.php

示例11: onKernelResponse

 /**
  * 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);
     }
 }
开发者ID:smoskalenko,项目名称:graviton,代码行数:42,代码来源:SelfLinkResponseListener.php

示例12: convertToPHPValue

 /**
  * get php value when field is used as identifier
  *
  * @param \MongoDBRef $value ref from mongodb
  *
  * @return string
  */
 public function convertToPHPValue($value)
 {
     if (!array_key_exists('$ref', $value) && !array_key_exists($value['$ref'], $this->mapping) && !array_key_exists('$id', $value)) {
         return '';
     }
     return $this->router->generate($this->mapping[$value['$ref']], ['id' => $value['$id']]);
 }
开发者ID:smoskalenko,项目名称:graviton,代码行数:14,代码来源:ExtReference.php

示例13: onBagdeCreateValidationLink

 /**
  * @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();
 }
开发者ID:rbs-aferreira,项目名称:BlogBundle,代码行数:36,代码来源:BadgeListener.php

示例14: getRoleConfig

 /**
  * @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"))];
 }
开发者ID:NathanVss,项目名称:oauth-extension-bundle,代码行数:12,代码来源:ConfigProvider.php

示例15: onAuthenticationSuccess

 /**
  * @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'));
     }
 }
开发者ID:alfonsomga,项目名称:symfony.demo.on.roids,代码行数:13,代码来源:AuthenticationSuccessHandler.php


注:本文中的Symfony\Bundle\FrameworkBundle\Routing\Router::generate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。