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


PHP Drupal::PathValidator方法代码示例

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


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

示例1: bootstrap_preprocess_input

/**
 * Preprocess input.
 */
function bootstrap_preprocess_input(&$variables)
{
    $element =& $variables['element'];
    $attributes = new Attribute($variables['attributes']);
    // Set the element's attributes.
    \Drupal\Core\Render\Element::setAttributes($element, array('id', 'name', 'value', 'type'));
    // Handle button inputs.
    if (_bootstrap_is_button($element)) {
        $variables['attributes']['class'][] = 'btn';
        _bootstrap_colorize_button($variables);
        _bootstrap_iconize_button($element);
        // Add button size, if necessary.
        if ($size = bootstrap_setting('button_size')) {
            $variables['attributes']['class'][] = $size;
        }
        // Add in the button type class.
        $variables['attributes']['class'][] = 'form-' . $element['#type'];
        $variables['label'] = $element['#value'];
    }
    _bootstrap_prerender_input($variables);
    // Autocomplete fields.
    if (!empty($element['#autocomplete_route_name']) && Drupal::PathValidator($element['#autocomplete_route_name'])) {
        $variables['autocomplete'] = TRUE;
        // Attributes for hidden input field.
        $autocomplete_attributes = new Attribute();
        $autocomplete_attributes['type'] = 'hidden';
        $autocomplete_attributes['id'] = $element['#attributes']['id'] . '-autocomplete';
        $autocomplete_attributes['value'] = Drupal::Url($element['#autocomplete_route_name'], $element['#autocomplete_route_parameters']);
        $autocomplete_attributes['disabled'] = 'disabled';
        $autocomplete_attributes['class'] = 'autocomplete';
        // Uses icon for autocomplete "throbber".
        $icon = _bootstrap_icon('refresh');
        // Fallback to using core's throbber.
        if (empty($icon)) {
            $icon = array('#type' => 'container', '#attributes' => array('class' => array('ajax-progress', 'ajax-progress-throbber', 'invisible')), 'throbber' => array('#type' => 'html_tag', '#tag' => 'div', '#attributes' => array('class' => array('throbber'))));
        }
        $variables['autocomplete_icon'] = $icon;
        $variables['autocomplete_attributes'] = $autocomplete_attributes;
    }
    // Search fields.
    if ($element['#type'] == 'search') {
        $attributes['placeholder'] = t('Search');
        $attributes['data-original-title'] = t('Enter the terms you wish to search for.');
    }
    // Additional Twig variables.
    $variables['icon'] = $element['#icon'];
    $variables['element'] = $element;
}
开发者ID:sathishRio,项目名称:themes,代码行数:51,代码来源:input.vars.php

示例2: bootstrap_preprocess_form_element

/**
 * Preprocess form_element.
 */
function bootstrap_preprocess_form_element(&$variables)
{
    $element =& $variables['element'];
    $title_display = $element['#title_display'];
    $name = !empty($element['#name']) ? $element['#name'] : FALSE;
    $type = !empty($element['#type']) ? $element['#type'] : FALSE;
    $checkbox = $type && $type === 'checkbox';
    $radio = $type && $type === 'radio';
    $has_tooltip = FALSE;
    // This function is invoked as theme wrapper, but the rendered form element
    // may not necessarily have been processed by Drupal::formBuilder()->doBuildForm().
    $element += array('#title_display' => 'before');
    // Check for errors and set correct error class.
    $formState = new FormState();
    if (isset($element['#parents']) && $formState->getError($element) || !empty($element['#required']) && bootstrap_setting('forms_required_has_error')) {
        $variables['has_error'] = TRUE;
    }
    if (!empty($element['#autocomplete_route_name']) && Drupal::PathValidator($element['#autocomplete_route_name'])) {
        $variables['is_autocomplete'] = TRUE;
    }
    // See http://getbootstrap.com/css/#forms-controls.
    if (isset($element['#type'])) {
        if ($radio) {
            $variables['is_radio'] = TRUE;
        } elseif ($checkbox) {
            $variables['is_checkbox'] = TRUE;
        } elseif ($type != 'hidden') {
            $variables['is_form_group'] = TRUE;
        }
    }
    // If #title is not set, we don't display any label or required marker.
    if (!isset($element['#title'])) {
        $element['#title_display'] = 'none';
    }
    $variables['title_display'] = $element['#title_display'];
    // Add label_display and label variables to template.
    $variables['label_display'] = $element['#title_display'];
    // Place single checkboxes and radios in the label field.
    if (($checkbox || $radio) && $title_display != 'none' && $title_display != 'invisible') {
        $variables['label']['#children'] = $variables['children'];
        unset($variables['children']);
        unset($variables['description']);
        // Pass the label attributes to the label, if available.
        if (isset($variables['element']['#label_attributes'])) {
            $variables['label']['#label_attributes'] = $variables['element']['#label_attributes'];
        }
    }
    // Create variables for #input_group and #input_group_button flags.
    if (isset($element['#input_group'])) {
        $variables['input_group'] = $element['#input_group'];
    }
    if (isset($element['#input_group_button'])) {
        $variables['input_group_button'] = $element['#input_group_button'];
    }
    $prefix = '';
    $suffix = '';
    if (isset($element['#field_prefix']) || isset($element['#field_suffix'])) {
        // Determine if "#input_group" was specified.
        if (!empty($element['#input_group'])) {
            $prefix = array('#markup' => '<div class="input-group">' . (isset($element['#field_prefix']) ? '<span class="input-group-addon">' . $element['#field_prefix'] . '</span>' : ''));
            $suffix = array('#markup' => (isset($element['#field_suffix']) ? '<span class="input-group-addon">' . $element['#field_suffix'] . '</span>' : '') . '</div>');
        } elseif (!empty($element['#input_group_button'])) {
            $prefix = array('#markup' => '<div class="input-group">' . (isset($element['#field_prefix']) ? '<span class="input-group-btn">' . $element['#field_prefix'] . '</span>' : ''));
            $suffix = array('#markup' => (isset($element['#field_suffix']) ? '<span class="input-group-btn">' . $element['#field_suffix'] . '</span>' : '') . '</div>');
        }
        $render = \Drupal::service('renderer');
        $variables['prefix'] = $render->render($prefix);
        $variables['suffix'] = $render->render($suffix);
    } else {
        $variables['prefix'] = '';
        $variables['suffix'] = '';
    }
}
开发者ID:sathishRio,项目名称:themes,代码行数:76,代码来源:form-element.vars.php


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