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


PHP RouteMatchInterface::getRawParameter方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: getEntityFromRouteMatch

 /**
  * {@inheritdoc}
  */
 public function getEntityFromRouteMatch(RouteMatchInterface $route_match, $entity_type_id)
 {
     // Overridden to customize creation of new entities.
     if ($route_match->getRawParameter($entity_type_id) !== NULL) {
         $entity = $route_match->getParameter($entity_type_id);
     } else {
         $values = [];
         // @todo: Create the right expression depending on the route.
         $entity = $this->entityTypeManager->getStorage($entity_type_id)->create($values);
         $entity->setExpression($this->expressionManager->createRule());
     }
     return $entity;
 }
开发者ID:Progressable,项目名称:openway8,代码行数:16,代码来源:RulesComponentAddForm.php

示例5: access

 /**
  * Checks access to the form mode.
  *
  * @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 $form_mode_name
  *   (optional) The form mode. Defaults to 'default'.
  * @param string $bundle
  *   (optional) The bundle. Different entity types can have different names
  *   for their bundle key, so if not specified on the route via a {bundle}
  *   parameter, the access checker determines the appropriate key name, and
  *   gets the value from the corresponding request attribute. For example,
  *   for nodes, the bundle key is "node_type", so the value would be
  *   available via the {node_type} parameter rather than a {bundle}
  *   parameter.
  *
  * @return \Drupal\Core\Access\AccessResultInterface
  *   The access result.
  */
 public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account, $form_mode_name = 'default', $bundle = NULL)
 {
     $access = AccessResult::neutral();
     if ($entity_type_id = $route->getDefault('entity_type_id')) {
         if (empty($bundle)) {
             $entity_type = $this->entityManager->getDefinition($entity_type_id);
             $bundle = $route_match->getRawParameter($entity_type->getBundleEntityType());
         }
         $visibility = FALSE;
         if ($form_mode_name == 'default') {
             $visibility = TRUE;
         } elseif ($entity_display = $this->entityManager->getStorage('entity_form_display')->load($entity_type_id . '.' . $bundle . '.' . $form_mode_name)) {
             $visibility = $entity_display->status();
         }
         if ($form_mode_name != 'default' && $entity_display) {
             $access->addCacheableDependency($entity_display);
         }
         if ($visibility) {
             $permission = $route->getRequirement('_field_ui_form_mode_access');
             $access = $access->orIf(AccessResult::allowedIfHasPermission($account, $permission));
         }
     }
     return $access;
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:47,代码来源:FormModeAccessCheck.php

示例6: getEntityFromRouteMatch

 /**
  * {@inheritdoc}
  */
 public function getEntityFromRouteMatch(RouteMatchInterface $route_match, $entity_type_id)
 {
     if ($route_match->getRawParameter($entity_type_id) !== NULL) {
         $entity = $route_match->getParameter($entity_type_id);
     } else {
         $entity = $this->entityManager->getStorage($entity_type_id)->create([]);
     }
     return $entity;
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:12,代码来源:EntityForm.php

示例7: getEntityFromRouteMatch

 /**
  * {@inheritdoc}
  */
 public function getEntityFromRouteMatch(RouteMatchInterface $route_match, $entity_type_id)
 {
     if ($route_match->getRawParameter($entity_type_id) !== NULL) {
         $entity = $route_match->getParameter($entity_type_id);
     } else {
         $values = [];
         // If the entity has bundles, fetch it from the route match.
         $entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
         if ($bundle_key = $entity_type->getKey('bundle')) {
             if (($bundle_entity_type_id = $entity_type->getBundleEntityType()) && $route_match->getRawParameter($bundle_entity_type_id)) {
                 $values[$bundle_key] = $route_match->getParameter($bundle_entity_type_id)->id();
             } elseif ($route_match->getRawParameter($bundle_key)) {
                 $values[$bundle_key] = $route_match->getParameter($bundle_key);
             }
         }
         $entity = $this->entityTypeManager->getStorage($entity_type_id)->create($values);
     }
     return $entity;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:22,代码来源:EntityForm.php

示例8: testGetRawParameter

 /**
  * @covers ::getRawParameter
  * @covers \Drupal\Core\Routing\RouteMatch::getParameterNames
  * @dataProvider routeMatchProvider
  */
 public function testGetRawParameter(RouteMatchInterface $route_match, Route $route, $parameters, $expected_filtered_parameters)
 {
     foreach ($expected_filtered_parameters as $name => $expected_value) {
         $this->assertSame($expected_value, $route_match->getRawParameter($name));
     }
     foreach (array_diff_key($parameters, $expected_filtered_parameters) as $name) {
         $this->assertNull($route_match->getRawParameter($name));
     }
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:14,代码来源:RouteMatchTestBase.php

示例9: 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 \Symfony\Component\HttpFoundation\Request $request
  *   The request.
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *   The route match.
  * @return null|void
  */
 public function handle($view_id, $display_id, Request $request, RouteMatchInterface $route_match)
 {
     $entity = $this->storage->load($view_id);
     if (empty($entity)) {
         throw new NotFoundHttpException(String::format('Page controller for view %id requested, but view was not found.', array('%id' => $view_id)));
     }
     $view = $this->executableFactory->get($entity);
     $view->setRequest($request);
     $view->setDisplay($display_id);
     $view->initHandlers();
     $args = array();
     $map = $route_match->getRouteObject()->getOption('_view_argument_map', array());
     $arguments_length = count($view->argument);
     for ($argument_index = 0; $argument_index < $arguments_length; $argument_index++) {
         // 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.
         $attribute = 'arg_' . $argument_index;
         if (isset($map[$attribute])) {
             $attribute = $map[$attribute];
         }
         if ($arg = $route_match->getRawParameter($attribute)) {
         } else {
             $arg = $route_match->getParameter($attribute);
         }
         if (isset($arg)) {
             $args[] = $arg;
         }
     }
     $plugin_definition = $view->display_handler->getPluginDefinition();
     if (!empty($plugin_definition['returns_response'])) {
         return $view->executeDisplay($display_id, $args);
     } else {
         return $view->buildRenderable($display_id, $args);
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:50,代码来源:ViewPageController.php

示例10: addBundleTitle

 /**
  * Provides a generic add title callback for entities with bundles.
  *
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *   The route match.
  * @param string $entity_type_id
  *   The entity type ID.
  * @param string $bundle_parameter
  *   The name of the route parameter that holds the bundle.
  *
  * @return string
  *    The title for the entity add page, if the bundle was found.
  */
 public function addBundleTitle(RouteMatchInterface $route_match, $entity_type_id, $bundle_parameter)
 {
     $bundles = $this->entityTypeBundleInfo->getBundleInfo($entity_type_id);
     // If the entity has bundle entities, the parameter might have been upcasted
     // so fetch the raw parameter.
     $bundle = $route_match->getRawParameter($bundle_parameter);
     if (count($bundles) > 1 && isset($bundles[$bundle])) {
         return $this->t('Add @bundle', ['@bundle' => $bundles[$bundle]['label']]);
     } else {
         return $this->addTitle($entity_type_id);
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:25,代码来源:EntityController.php

示例11: addFormTitle

 /**
  * The title callback for the add form.
  *
  * @param string $entity_type_id
  *   The entity type ID.
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *   The route match.
  *
  * @return string
  *   The page title.
  */
 public function addFormTitle($entity_type_id, RouteMatchInterface $route_match)
 {
     $entity_type = $this->entityTypeManager()->getDefinition($entity_type_id);
     $bundle_key = $entity_type->getKey('bundle');
     $bundles = $this->entityTypeBundleInfo->getBundleInfo($entity_type_id);
     if ($bundle_key && count($bundles) > 1) {
         $bundle_name = $route_match->getRawParameter($bundle_key);
         $title = $this->t('Add @bundle', ['@bundle' => $bundles[$bundle_name]['label']]);
     } else {
         $title = $this->t('Add @entity-type', ['@entity-type' => $entity_type->getLowercaseLabel()]);
     }
     return $title;
 }
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:24,代码来源:EntityCreateController.php


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