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


PHP Routing\RouteMatchInterface类代码示例

本文整理汇总了PHP中Drupal\Core\Routing\RouteMatchInterface的典型用法代码示例。如果您正苦于以下问题:PHP RouteMatchInterface类的具体用法?PHP RouteMatchInterface怎么用?PHP RouteMatchInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: build

 /**
  * {@inheritdoc}
  */
 public function build(RouteMatchInterface $route_match)
 {
     $book_nids = array();
     $links = array(Link::createFromRoute($this->t('Home'), '<front>'));
     $book = $route_match->getParameter('node')->book;
     $depth = 1;
     // We skip the current node.
     while (!empty($book['p' . ($depth + 1)])) {
         $book_nids[] = $book['p' . $depth];
         $depth++;
     }
     $parent_books = $this->nodeStorage->loadMultiple($book_nids);
     if (count($parent_books) > 0) {
         $depth = 1;
         while (!empty($book['p' . ($depth + 1)])) {
             if (!empty($parent_books[$book['p' . $depth]]) && ($parent_book = $parent_books[$book['p' . $depth]])) {
                 if ($parent_book->access('view', $this->account)) {
                     $links[] = Link::createFromRoute($parent_book->label(), 'entity.node.canonical', array('node' => $parent_book->id()));
                 }
             }
             $depth++;
         }
     }
     return $links;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:28,代码来源:BookBreadcrumbBuilder.php

示例2: access

 /**
  * Checks if the user has access to underlying storage for a Panels display.
  *
  * @param \Symfony\Component\Routing\Route $route
  *   The route to check against.
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *   The parametrized route.
  * @param \Drupal\Core\Session\AccountInterface $account
  *   The currently logged in account.
  *
  * @return \Drupal\Core\Access\AccessResultInterface
  *   The access result.
  */
 public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account)
 {
     $panels_storage_type = $route_match->getParameter('panels_storage_type');
     $panels_storage_id = $route_match->getParameter('panels_storage_id');
     $op = $route->getRequirement('_panels_storage_access');
     return $this->panelsStorage->access($panels_storage_type, $panels_storage_id, $op, $account);
 }
开发者ID:neeravbm,项目名称:unify-d8,代码行数:20,代码来源:PanelsStorageAccess.php

示例3: build

 /**
  * {@inheritdoc}
  */
 public function build(RouteMatchInterface $route_match)
 {
     $breadcrumb = new Breadcrumb();
     $breadcrumb->addLink(Link::createFromRoute($this->t('Home'), '<front>'));
     $term = $route_match->getParameter('taxonomy_term');
     // Breadcrumb needs to have terms cacheable metadata as a cacheable
     // dependency even though it is not shown in the breadcrumb because e.g. its
     // parent might have changed.
     $breadcrumb->addCacheableDependency($term);
     // @todo This overrides any other possible breadcrumb and is a pure
     //   hard-coded presumption. Make this behavior configurable per
     //   vocabulary or term.
     $parents = $this->termStorage->loadAllParents($term->id());
     // Remove current term being accessed.
     array_shift($parents);
     foreach (array_reverse($parents) as $term) {
         $term = $this->entityManager->getTranslationFromContext($term);
         $breadcrumb->addCacheableDependency($term);
         $breadcrumb->addLink(Link::createFromRoute($term->getName(), 'entity.taxonomy_term.canonical', array('taxonomy_term' => $term->id())));
     }
     // This breadcrumb builder is based on a route parameter, and hence it
     // depends on the 'route' cache context.
     $breadcrumb->addCacheContexts(['route']);
     return $breadcrumb;
 }
开发者ID:papillon-cendre,项目名称:d8,代码行数:28,代码来源:TermBreadcrumbBuilder.php

示例4: getEntityFromRouteMatch

 /**
  * {@inheritdoc}
  */
 public function getEntityFromRouteMatch(RouteMatchInterface $route_match, $entity_type_id)
 {
     // The URL of this entity form contains only the ID of the field_config
     // but we are actually editing a field_storage_config entity.
     $field_config = FieldConfig::load($route_match->getRawParameter('field_config'));
     return $field_config->getFieldStorageDefinition();
 }
开发者ID:neetumorwani,项目名称:blogging,代码行数:10,代码来源:FieldStorageConfigEditForm.php

示例5: access

 /**
  * Checks access to the translation overview for the entity and bundle.
  *
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *   The parametrized route.
  * @param \Drupal\Core\Session\AccountInterface $account
  *   The currently logged in account.
  * @param string $entity_type_id
  *   The entity type ID.
  *
  * @return \Drupal\Core\Access\AccessResultInterface
  *   The access result.
  */
 public function access(RouteMatchInterface $route_match, AccountInterface $account, $entity_type_id)
 {
     /* @var \Drupal\Core\Entity\ContentEntityInterface $entity */
     $entity = $route_match->getParameter($entity_type_id);
     if ($entity && $entity->isTranslatable()) {
         // Get entity base info.
         $bundle = $entity->bundle();
         // Get entity access callback.
         $definition = $this->entityManager->getDefinition($entity_type_id);
         $translation = $definition->get('translation');
         $access_callback = $translation['content_translation']['access_callback'];
         $access = call_user_func($access_callback, $entity);
         if ($access->isAllowed()) {
             return $access;
         }
         // Check "translate any entity" permission.
         if ($account->hasPermission('translate any entity')) {
             return AccessResult::allowed()->cachePerPermissions()->inheritCacheability($access);
         }
         // Check per entity permission.
         $permission = "translate {$entity_type_id}";
         if ($definition->getPermissionGranularity() == 'bundle') {
             $permission = "translate {$bundle} {$entity_type_id}";
         }
         return AccessResult::allowedIfHasPermission($account, $permission)->inheritCacheability($access);
     }
     // No opinion.
     return AccessResult::neutral();
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:42,代码来源:ContentTranslationOverviewAccess.php

示例6: access

 /**
  * Checks translation access for the entity and operation on the given route.
  *
  * @param \Symfony\Component\Routing\Route $route
  *   The route to check against.
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *   The parametrized route.
  * @param \Drupal\Core\Session\AccountInterface $account
  *   The currently logged in account.
  * @param string $source
  *   (optional) For a create operation, the language code of the source.
  * @param string $target
  *   (optional) For a create operation, the language code of the translation.
  * @param string $language
  *   (optional) For an update or delete operation, the language code of the
  *   translation being updated or deleted.
  * @param string $entity_type_id
  *   (optional) The entity type ID.
  *
  * @return \Drupal\Core\Access\AccessResultInterface
  *   The access result.
  */
 public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account, $source = NULL, $target = NULL, $language = NULL, $entity_type_id = NULL)
 {
     /* @var \Drupal\Core\Entity\ContentEntityInterface $entity */
     if ($entity = $route_match->getParameter($entity_type_id)) {
         if ($account->hasPermission('translate any entity')) {
             return AccessResult::allowed()->cachePerRole();
         }
         $operation = $route->getRequirement('_access_content_translation_manage');
         /* @var \Drupal\content_translation\ContentTranslationHandlerInterface $handler */
         $handler = $this->entityManager->getHandler($entity->getEntityTypeId(), 'translation');
         // Load translation.
         $translations = $entity->getTranslationLanguages();
         $languages = $this->languageManager->getLanguages();
         switch ($operation) {
             case 'create':
                 $source_language = $this->languageManager->getLanguage($source) ?: $entity->language();
                 $target_language = $this->languageManager->getLanguage($target) ?: $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT);
                 $is_new_translation = $source_language->getId() != $target_language->getId() && isset($languages[$source_language->getId()]) && isset($languages[$target_language->getId()]) && !isset($translations[$target_language->getId()]);
                 return AccessResult::allowedIf($is_new_translation)->cachePerRole()->cacheUntilEntityChanges($entity)->andIf($handler->getTranslationAccess($entity, $operation));
             case 'update':
             case 'delete':
                 $language = $this->languageManager->getLanguage($language) ?: $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT);
                 $has_translation = isset($languages[$language->getId()]) && $language->getId() != $entity->getUntranslated()->language()->getId() && isset($translations[$language->getId()]);
                 return AccessResult::allowedIf($has_translation)->cachePerRole()->cacheUntilEntityChanges($entity)->andIf($handler->getTranslationAccess($entity, $operation));
         }
     }
     // No opinion.
     return AccessResult::neutral();
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:51,代码来源:ContentTranslationManageAccessCheck.php

示例7: handle

 /**
  * Handler a response for a given view and display.
  *
  * @param string $view_id
  *   The ID of the view
  * @param string $display_id
  *   The ID of the display.
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *   The route match.
  * @return null|void
  */
 public function handle($view_id, $display_id, RouteMatchInterface $route_match)
 {
     $args = array();
     $route = $route_match->getRouteObject();
     $map = $route->hasOption('_view_argument_map') ? $route->getOption('_view_argument_map') : array();
     foreach ($map as $attribute => $parameter_name) {
         // Allow parameters be pulled from the request.
         // The map stores the actual name of the parameter in the request. Views
         // which override existing controller, use for example 'node' instead of
         // arg_nid as name.
         if (isset($map[$attribute])) {
             $attribute = $map[$attribute];
         }
         if ($arg = $route_match->getRawParameter($attribute)) {
         } else {
             $arg = $route_match->getParameter($attribute);
         }
         if (isset($arg)) {
             $args[] = $arg;
         }
     }
     /** @var \Drupal\views\Plugin\views\display\DisplayPluginBase $class */
     $class = $route->getOption('_view_display_plugin_class');
     if ($route->getOption('returns_response')) {
         /** @var \Drupal\views\Plugin\views\display\ResponseDisplayPluginInterface $class */
         return $class::buildResponse($view_id, $display_id, $args);
     } else {
         $build = $class::buildBasicRenderable($view_id, $display_id, $args, $route);
         Page::setPageRenderArray($build);
         return $build;
     }
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:43,代码来源:ViewPageController.php

示例8: getRouteParameters

 /**
  * {@inheritdoc}
  */
 public function getRouteParameters(RouteMatchInterface $route_match)
 {
     $parameters = isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : array();
     $route = $this->routeProvider()->getRouteByName($this->getRouteName());
     $variables = $route->compile()->getVariables();
     // Normally the \Drupal\Core\ParamConverter\ParamConverterManager has
     // processed the Request attributes, and in that case the _raw_variables
     // attribute holds the original path strings keyed to the corresponding
     // slugs in the path patterns. For example, if the route's path pattern is
     // /filter/tips/{filter_format} and the path is /filter/tips/plain_text then
     // $raw_variables->get('filter_format') == 'plain_text'.
     $raw_variables = $route_match->getRawParameters();
     foreach ($variables as $name) {
         if (isset($parameters[$name])) {
             continue;
         }
         if ($raw_variables && $raw_variables->has($name)) {
             $parameters[$name] = $raw_variables->get($name);
         } elseif ($value = $route_match->getRawParameter($name)) {
             $parameters[$name] = $value;
         }
     }
     // The UrlGenerator will throw an exception if expected parameters are
     // missing. This method should be overridden if that is possible.
     return $parameters;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:29,代码来源:LocalTaskDefault.php

示例9: testEdit

 /**
  * Displays the 'Edit existing entity_test' form.
  *
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *   The route match object to get entity type from.
  * @param string $entity_type_id
  *   The entity type ID.
  *
  * @return array
  *   The processed form for the edited entity.
  *
  * @see \Drupal\entity_test\Routing\EntityTestRoutes::routes()
  */
 public function testEdit(RouteMatchInterface $route_match, $entity_type_id)
 {
     $entity = $route_match->getParameter($entity_type_id);
     $form = $this->entityFormBuilder()->getForm($entity);
     $form['#title'] = $entity->label();
     return $form;
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:20,代码来源:EntityTestController.php

示例10: build

 /**
  * {@inheritdoc}
  */
 public function build(RouteMatchInterface $route_match)
 {
     $book_nids = array();
     $breadcrumb = new Breadcrumb();
     $links = array(Link::createFromRoute($this->t('Home'), '<front>'));
     $book = $route_match->getParameter('node')->book;
     $depth = 1;
     // We skip the current node.
     while (!empty($book['p' . ($depth + 1)])) {
         $book_nids[] = $book['p' . $depth];
         $depth++;
     }
     $parent_books = $this->nodeStorage->loadMultiple($book_nids);
     if (count($parent_books) > 0) {
         $depth = 1;
         while (!empty($book['p' . ($depth + 1)])) {
             if (!empty($parent_books[$book['p' . $depth]]) && ($parent_book = $parent_books[$book['p' . $depth]])) {
                 $access = $parent_book->access('view', $this->account, TRUE);
                 $breadcrumb->addCacheableDependency($access);
                 if ($access->isAllowed()) {
                     $breadcrumb->addCacheableDependency($parent_book);
                     $links[] = Link::createFromRoute($parent_book->label(), 'entity.node.canonical', array('node' => $parent_book->id()));
                 }
             }
             $depth++;
         }
     }
     $breadcrumb->setLinks($links);
     $breadcrumb->addCacheContexts(['route.book_navigation']);
     return $breadcrumb;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:34,代码来源:BookBreadcrumbBuilder.php

示例11: build

 /**
  * {@inheritdoc}
  */
 public function build(RouteMatchInterface $route_match)
 {
     $breadcrumb = array();
     $breadcrumb[] = $this->l($this->t('Home'), '<front>');
     $entity = $this->entityManager->getStorage($route_match->getParameter('entity_type'))->load($route_match->getParameter('entity_id'));
     $breadcrumb[] = \Drupal::linkGenerator()->generateFromUrl($entity->label(), $entity->urlInfo());
     return $breadcrumb;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:11,代码来源:CommentBreadcrumbBuilder.php

示例12: build

 /**
  * {@inheritdoc}
  */
 public function build(RouteMatchInterface $route_match)
 {
     $breadcrumb = array();
     $breadcrumb[] = Link::createFromRoute($this->t('Home'), '<front>');
     $entity = $route_match->getParameter('entity');
     $breadcrumb[] = new Link($entity->label(), $entity->urlInfo());
     return $breadcrumb;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:11,代码来源:CommentBreadcrumbBuilder.php

示例13: applies

 /**
  * {@inheritdoc}
  */
 public function applies(RouteMatchInterface $route_match)
 {
     if ($route_match->getRouteObject() !== null) {
         $URI = $route_match->getRouteObject()->getPath();
         // Use this theme on a certain route.
         return substr($URI, 1, 4) == 'view';
     }
 }
开发者ID:kataku,项目名称:Drupal8JSON,代码行数:11,代码来源:JsonThemeHelperNegotiator.php

示例14: applies

 /**
  * {@inheritdoc}
  */
 public function applies(RouteMatchInterface $route_match)
 {
     if ($route_match->getRouteName() == 'diff.revisions_diff') {
         if ($route_match->getParameter('filter') == 'raw-plain') {
             return TRUE;
         }
     }
 }
开发者ID:sedurzu,项目名称:ildeposito8,代码行数:11,代码来源:DiffBreadcrumbBuilder.php

示例15: access

 /**
  * Check if the filter is used for the given filter.
  *
  * @param \Drupal\Core\Routing\RouteMatchInterface $route
  *   The route.
  *
  * @return \Drupal\Core\Access\AccessResult
  *   An access result.
  */
 public function access(RouteMatchInterface $route)
 {
     $filter = $route->getParameter('filter_format');
     if (!$filter || empty($filter->filters()->get('video_embed_wysiwyg')->getConfiguration()['status'])) {
         return AccessResult::forbidden()->addCacheableDependency($filter);
     }
     return AccessResult::allowed()->addCacheableDependency($filter);
 }
开发者ID:eric-shell,项目名称:eric-shell-d8,代码行数:17,代码来源:FilterInUse.php


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