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


PHP Url::getOption方法代码示例

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


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

示例1: actions

 /**
  * {@inheritdoc}
  */
 protected function actions(array $form, FormStateInterface $form_state)
 {
     $actions = parent::actions($form, $form_state);
     $actions['submit']['#value'] = $this->t('Save settings');
     if (!$this->entity->isNew()) {
         $target_entity_type = $this->entityManager->getDefinition($this->entity->getTargetEntityTypeId());
         $route_parameters = ['field_config' => $this->entity->id()] + FieldUI::getRouteBundleParameter($target_entity_type, $this->entity->bundle);
         $url = new Url('entity.field_config.' . $target_entity_type->id() . '_field_delete_form', $route_parameters);
         if ($this->getRequest()->query->has('destination')) {
             $query = $url->getOption('query');
             $query['destination'] = $this->getRequest()->query->get('destination');
             $url->setOption('query', $query);
         }
         $actions['delete'] = array('#type' => 'link', '#title' => $this->t('Delete'), '#url' => $url, '#access' => $this->entity->access('delete'), '#attributes' => array('class' => array('button', 'button--danger')));
     }
     return $actions;
 }
开发者ID:brstde,项目名称:gap1,代码行数:20,代码来源:FieldConfigEditForm.php

示例2: getPropertiesList

 /**
  * Creates an items list for the given properties.
  *
  * @param \Drupal\Core\TypedData\DataDefinitionInterface[] $properties
  *   The property definitions, keyed by their property names.
  * @param string $active_property_path
  *   The relative property path to the active property.
  * @param \Drupal\Core\Url $base_url
  *   The base URL to which property path parameters should be added for
  *   the navigation links.
  * @param string $parent_path
  *   (optional) The common property path prefix of the given properties.
  * @param string $label_prefix
  *   (optional) The prefix to use for the labels of created fields.
  *
  * @return array
  *   A render array representing the given properties and, possibly, nested
  *   properties.
  */
 protected function getPropertiesList(array $properties, $active_property_path, Url $base_url, $parent_path = '', $label_prefix = '')
 {
     $list = array('#theme' => 'search_api_form_item_list');
     $active_item = '';
     if ($active_property_path) {
         list($active_item, $active_property_path) = explode(':', $active_property_path, 2) + array(1 => '');
     }
     $type_mapping = Utility::getFieldTypeMapping();
     $query_base = $base_url->getOption('query');
     foreach ($properties as $key => $property) {
         $this_path = $parent_path ? $parent_path . ':' : '';
         $this_path .= $key;
         $label = $property->getLabel();
         $property = Utility::getInnerProperty($property);
         $can_be_indexed = TRUE;
         $nested_properties = array();
         $parent_child_type = NULL;
         if ($property instanceof ComplexDataDefinitionInterface) {
             $can_be_indexed = FALSE;
             $nested_properties = $property->getPropertyDefinitions();
             $main_property = $property->getMainPropertyName();
             if ($main_property && isset($nested_properties[$main_property])) {
                 $parent_child_type = $property->getDataType() . '.';
                 $property = $nested_properties[$main_property];
                 $parent_child_type .= $property->getDataType();
                 unset($nested_properties[$main_property]);
                 $can_be_indexed = TRUE;
             }
             // Don't add the additional 'entity' property for entity reference
             // fields which don't target a content entity type.
             if ($property instanceof FieldItemDataDefinition && in_array($property->getDataType(), array('field_item:entity_reference', 'field_item:image', 'field_item:file'))) {
                 $entity_type = $this->getEntityTypeManager()->getDefinition($property->getSetting('target_type'));
                 if (!$entity_type->isSubclassOf('Drupal\\Core\\Entity\\ContentEntityInterface')) {
                     unset($nested_properties['entity']);
                 }
             }
         }
         // Don't allow indexing of properties with unmapped types. Also, prefer
         // a "parent.child" type mapping (taking into account the parent property
         // for, e.g., text fields).
         $type = $property->getDataType();
         if ($parent_child_type && !empty($type_mapping[$parent_child_type])) {
             $type = $parent_child_type;
         } elseif (empty($type_mapping[$type])) {
             // Remember the type only if it was not explicitly mapped to FALSE.
             if (!isset($type_mapping[$type])) {
                 $this->unmappedFields[$type][] = $label_prefix . $label;
             }
             $can_be_indexed = FALSE;
         }
         // If the property can neither be expanded nor indexed, just skip it.
         if (!($nested_properties || $can_be_indexed)) {
             continue;
         }
         $nested_list = array();
         $expand_link = array();
         if ($nested_properties) {
             if ($key == $active_item) {
                 $link_url = clone $base_url;
                 $query_base['property_path'] = $parent_path;
                 $link_url->setOption('query', $query_base);
                 $expand_link = array('#type' => 'link', '#title' => '(-) ', '#url' => $link_url);
                 $nested_list = $this->getPropertiesList($nested_properties, $active_property_path, $base_url, $this_path, $label_prefix . $label . ' » ');
             } else {
                 $link_url = clone $base_url;
                 $query_base['property_path'] = $this_path;
                 $link_url->setOption('query', $query_base);
                 $expand_link = array('#type' => 'link', '#title' => '(+) ', '#url' => $link_url);
             }
         }
         $item = array('#type' => 'container', '#attributes' => array('class' => array('container-inline')));
         if ($expand_link) {
             $item['expand_link'] = $expand_link;
         }
         $item['label']['#markup'] = Html::escape($label) . ' ';
         if ($can_be_indexed) {
             $item['add'] = array('#type' => 'submit', '#name' => Utility::createCombinedId($this->getParameter('datasource') ?: NULL, $this_path), '#value' => $this->t('Add'), '#submit' => array('::addField', '::save'), '#property' => $property, '#prefixed_label' => $label_prefix . $label, '#data_type' => $type_mapping[$type]);
         }
         if ($nested_list) {
             $item['properties'] = $nested_list;
         }
//.........这里部分代码省略.........
开发者ID:curveagency,项目名称:intranet,代码行数:101,代码来源:IndexAddFieldsForm.php

示例3: assertUrl

 /**
  * Asserts that a given URL object matches the expectations.
  *
  * @param string $expected_route_name
  *   The expected route name of the generated URL.
  * @param array $expected_route_parameters
  *   The expected route parameters of the generated URL.
  * @param \Drupal\Core\Entity\Entity|\PHPUnit_Framework_MockObject_MockObject $entity
  *   The entity that is expected to be set as a URL option.
  * @param bool $has_language
  *   Whether or not the URL is expected to have a language option.
  * @param \Drupal\Core\Url $url
  *   The URL option to make the assertions on.
  */
 protected function assertUrl($expected_route_name, array $expected_route_parameters, $entity, $has_language, Url $url)
 {
     $this->assertEquals($expected_route_name, $url->getRouteName());
     $this->assertEquals($expected_route_parameters, $url->getRouteParameters());
     $this->assertEquals($this->entityTypeId, $url->getOption('entity_type'));
     $this->assertEquals($entity, $url->getOption('entity'));
     if ($has_language) {
         $this->assertEquals($this->langcode, $url->getOption('language')->getId());
     } else {
         $this->assertNull($url->getOption('language'));
     }
 }
开发者ID:DrupalCamp-NYC,项目名称:dcnyc16,代码行数:26,代码来源:EntityUrlTest.php

示例4: parseLink

  /**
   * {@inheritDoc}
   */
  public function parseLink(Url $link) {
    $query = $link->getOption('query');

    if (!$query) {
      throw new \InvalidArgumentException('The \Drupal\Core\Url you pass in must
      have its \'query\' option set.');
    }

    $request_context = [
      'entity_ids' => NULL,
      'fid' => NULL,
      'sample' => NULL,
      'force_download' => FALSE,
      'flatten' => TRUE,
    ];

    if (!empty($query['sample'])) {
      $sample = TRUE;
    }

    // Is this just the PDF populated with sample data?
    $request_context['sample'] = $sample;

    if (!empty($query['fid'])) {
      $request_context['fid'] = $query['fid'];
    }
    else {
      throw new \InvalidArgumentException('fid parameter missing from query
      string; cannot determine how to proceed, so failing.');
    }

    if (!empty($query['entity_type'])) {
      $request_context['entity_type'] = $query['entity_type'];
    }

    $request_context['entity_ids'] = $entity_ids = [];
    if (!empty($query['entity_id']) || !empty($query['entity_ids'])) {
      $entity_ids = (!empty($query['entity_id']) ? [$query['entity_id']] : $query['entity_ids']);

      // Re-key entity IDs so they can be loaded easily with loadMultiple().
      // If we have type information, add it to the types array, and remove it
      // in order to make sure we only store the ID in the entity_ids key.
      foreach ($entity_ids as $entity_id) {
        $entity_id_parts = explode(':', $entity_id);

        if (count($entity_id_parts) == 2) {
          $entity_type = $entity_id_parts[0];
          $entity_id = $entity_id_parts[1];
        }
        elseif (!empty($request_context['entity_type'])) {
          $entity_type = $request_context['entity_type'];
        }
        else {
          $entity_type = 'node';
        }
        $request_context['entity_ids'] += [
          $entity_type => [],
        ];

        $request_context['entity_ids'][$entity_type][$entity_id] = $entity_id;
      }
    }
    else {
      // Populate defaults.
      $fillpdf_form = FillPdfForm::load($request_context['fid']);
      $default_entity_id = $fillpdf_form->default_entity_id->value;
      if ($default_entity_id) {
        $default_entity_type = $fillpdf_form->default_entity_type->value;
        if (empty($default_entity_type)) {
          $default_entity_type = 'node';
        }

        $request_context['entity_ids'] = [
          $default_entity_type => [$default_entity_id => $default_entity_id],
        ];
      }
    }

    // We've processed the shorthand forms, so unset them.
    unset($request_context['entity_id'], $request_context['entity_type']);

    if (!$query['download'] && (int) $query['download'] == 1) {
      $request_context['force_download'] = TRUE;
    }
    if ($query['flatten'] && (int) $query['flatten'] == 0) {
      $request_context['flatten'] = FALSE;
    }

    return $request_context;
  }
开发者ID:AshishNaik021,项目名称:iimisac-d8,代码行数:93,代码来源:FillPdfLinkManipulator.php


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