本文整理汇总了PHP中Drupal\views\Plugin\views\PluginBase类的典型用法代码示例。如果您正苦于以下问题:PHP PluginBase类的具体用法?PHP PluginBase怎么用?PHP PluginBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PluginBase类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getEntityTranslationRenderer
/**
* Returns the current renderer.
*
* @return \Drupal\views\Entity\Render\EntityTranslationRendererBase
* The configured renderer.
*/
protected function getEntityTranslationRenderer()
{
if (!isset($this->entityTranslationRenderer)) {
$view = $this->getView();
$rendering_language = $view->display_handler->getOption('rendering_language');
$langcode = NULL;
$dynamic_renderers = array('***LANGUAGE_entity_translation***' => 'TranslationLanguageRenderer', '***LANGUAGE_entity_default***' => 'DefaultLanguageRenderer');
if (isset($dynamic_renderers[$rendering_language])) {
// Dynamic language set based on result rows or instance defaults.
$renderer = $dynamic_renderers[$rendering_language];
} else {
if (strpos($rendering_language, '***LANGUAGE_') !== FALSE) {
$langcode = PluginBase::queryLanguageSubstitutions()[$rendering_language];
} else {
// Specific langcode set.
$langcode = $rendering_language;
}
$renderer = 'ConfigurableLanguageRenderer';
}
$class = '\\Drupal\\views\\Entity\\Render\\' . $renderer;
$entity_type = $this->getEntityManager()->getDefinition($this->getEntityTypeId());
$this->entityTranslationRenderer = new $class($view, $this->getLanguageManager(), $entity_type, $langcode);
}
return $this->entityTranslationRenderer;
}
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:31,代码来源:EntityTranslationRenderTrait.php
示例2: __construct
/**
* Constructs a WizardPluginBase object.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition)
{
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->base_table = $this->definition['base_table'];
$entity_types = \Drupal::entityManager()->getDefinitions();
foreach ($entity_types as $entity_type_id => $entity_type) {
if ($this->base_table == $entity_type->getBaseTable()) {
$this->entityType = $entity_type;
$this->entityTypeId = $entity_type_id;
}
}
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:15,代码来源:WizardPluginBase.php
示例3: __construct
/**
* Constructs a CachePluginBase object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Render\RendererInterface $renderer
* The HTML renderer.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, RendererInterface $renderer)
{
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->renderer = $renderer;
}
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:17,代码来源:CachePluginBase.php
示例4: __construct
/**
* Constructs a WizardPluginBase object.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeBundleInfoInterface $bundle_info_service)
{
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->bundleInfoService = $bundle_info_service;
$this->base_table = $this->definition['base_table'];
$entity_types = \Drupal::entityManager()->getDefinitions();
foreach ($entity_types as $entity_type_id => $entity_type) {
if ($this->base_table == $entity_type->getBaseTable() || $this->base_table == $entity_type->getDataTable()) {
$this->entityType = $entity_type;
$this->entityTypeId = $entity_type_id;
}
}
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:16,代码来源:WizardPluginBase.php
示例5: buildOptionsForm
/**
* Provide a form for setting options.
*/
public function buildOptionsForm(&$form, &$form_state)
{
parent::buildOptionsForm($form, $form_state);
if (isset($this->base_table)) {
$executable = $form_state['view']->getExecutable();
// A whole bunch of code to figure out what relationships are valid for
// this item.
$relationships = $executable->display_handler->getOption('relationships');
$relationship_options = array();
foreach ($relationships as $relationship) {
$relationship_handler = Views::handlerManager('relationship')->getHandler($relationship);
// If this relationship is valid for this type, add it to the list.
$data = Views::viewsData()->get($relationship['table']);
$base = $data[$relationship['field']]['relationship']['base'];
if ($base == $this->base_table) {
$relationship_handler->init($executable, $relationship);
$relationship_options[$relationship['id']] = $relationship_handler->adminLabel();
}
}
if (!empty($relationship_options)) {
$relationship_options = array_merge(array('none' => t('Do not use a relationship')), $relationship_options);
$rel = empty($this->options['relationship']) ? 'none' : $this->options['relationship'];
if (empty($relationship_options[$rel])) {
// Pick the first relationship.
$rel = key($relationship_options);
}
$form['relationship'] = array('#type' => 'select', '#title' => t('Relationship'), '#options' => $relationship_options, '#default_value' => $rel);
} else {
$form['relationship'] = array('#type' => 'value', '#value' => 'none');
}
}
}
开发者ID:alnutile,项目名称:drunatra,代码行数:35,代码来源:RowPluginBase.php
示例6: buildOptionsForm
public function buildOptionsForm(&$form, FormStateInterface $form_state)
{
parent::buildOptionsForm($form, $form_state);
$form['submit_button'] = array('#type' => 'textfield', '#title' => t('Submit button text'), '#default_value' => $this->options['submit_button'], '#required' => TRUE);
$form['reset_button'] = array('#type' => 'checkbox', '#title' => t('Include reset button (resets all applied exposed filters).'), '#default_value' => $this->options['reset_button']);
$form['reset_button_label'] = array('#type' => 'textfield', '#title' => t('Reset button label'), '#description' => t('Text to display in the reset button of the exposed form.'), '#default_value' => $this->options['reset_button_label'], '#required' => TRUE, '#states' => array('invisible' => array('input[name="exposed_form_options[reset_button]"]' => array('checked' => FALSE))));
$form['exposed_sorts_label'] = array('#type' => 'textfield', '#title' => t('Exposed sorts label'), '#default_value' => $this->options['exposed_sorts_label'], '#required' => TRUE);
$form['expose_sort_order'] = array('#type' => 'checkbox', '#title' => t('Allow people to choose the sort order'), '#description' => t('If sort order is not exposed, the sort criteria settings for each sort will determine its order.'), '#default_value' => $this->options['expose_sort_order']);
$form['sort_asc_label'] = array('#type' => 'textfield', '#title' => t('Label for ascending sort'), '#default_value' => $this->options['sort_asc_label'], '#required' => TRUE, '#states' => array('visible' => array('input[name="exposed_form_options[expose_sort_order]"]' => array('checked' => TRUE))));
$form['sort_desc_label'] = array('#type' => 'textfield', '#title' => t('Label for descending sort'), '#default_value' => $this->options['sort_desc_label'], '#required' => TRUE, '#states' => array('visible' => array('input[name="exposed_form_options[expose_sort_order]"]' => array('checked' => TRUE))));
}
开发者ID:anatalsceo,项目名称:en-classe,代码行数:11,代码来源:ExposedFormPluginBase.php
示例7: query
public function query()
{
parent::query();
if (isset($this->view->rowPlugin)) {
$this->view->rowPlugin->query();
}
}
开发者ID:HakS,项目名称:drupal8_training,代码行数:7,代码来源:StylePluginBase.php
示例8: buildOptionsForm
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state)
{
parent::buildOptionsForm($form, $form_state);
$section = $form_state->get('section');
if ($this->defaultableSections($section)) {
views_ui_standard_display_dropdown($form, $form_state, $section);
}
$form['#title'] = $this->display['display_title'] . ': ';
// Set the 'section' to highlight on the form.
// If it's the item we're looking at is pulling from the default display,
// reflect that. Don't use is_defaulted since we want it to show up even
// on the default display.
if (!empty($this->options['defaults'][$section])) {
$form['#section'] = 'default-' . $section;
} else {
$form['#section'] = $this->display['id'] . '-' . $section;
}
switch ($section) {
case 'display_id':
$form['#title'] .= $this->t('The machine name of this display');
$form['display_id'] = array('#type' => 'textfield', '#title' => $this->t('Machine name of the display'), '#default_value' => !empty($this->display['new_id']) ? $this->display['new_id'] : $this->display['id'], '#required' => TRUE, '#size' => 64);
break;
case 'display_title':
$form['#title'] .= $this->t('The name and the description of this display');
$form['display_title'] = array('#title' => $this->t('Administrative name'), '#type' => 'textfield', '#default_value' => $this->display['display_title']);
$form['display_description'] = array('#title' => $this->t('Administrative description'), '#type' => 'textfield', '#default_value' => $this->getOption('display_description'));
break;
case 'display_comment':
$form['#title'] .= $this->t('Administrative comment');
$form['display_comment'] = array('#type' => 'textarea', '#title' => $this->t('Administrative comment'), '#description' => $this->t('This description will only be seen within the administrative interface and can be used to document this display.'), '#default_value' => $this->getOption('display_comment'));
break;
case 'title':
$form['#title'] .= $this->t('The title of this view');
$form['title'] = array('#title' => $this->t('Title'), '#type' => 'textfield', '#description' => $this->t('This title will be displayed with the view, wherever titles are normally displayed; i.e, as the page title, block title, etc.'), '#default_value' => $this->getOption('title'), '#maxlength' => 255);
break;
case 'css_class':
$form['#title'] .= $this->t('CSS class');
$form['css_class'] = array('#type' => 'textfield', '#title' => $this->t('CSS class name(s)'), '#description' => $this->t('Separate multiple classes by spaces.'), '#default_value' => $this->getOption('css_class'));
break;
case 'use_ajax':
$form['#title'] .= $this->t('AJAX');
$form['use_ajax'] = array('#description' => $this->t('Options such as paging, table sorting, and exposed filters will not initiate a page refresh.'), '#type' => 'checkbox', '#title' => $this->t('Use AJAX'), '#default_value' => $this->getOption('use_ajax') ? 1 : 0);
break;
case 'hide_attachment_summary':
$form['#title'] .= $this->t('Hide attachments when displaying a contextual filter summary');
$form['hide_attachment_summary'] = array('#type' => 'checkbox', '#title' => $this->t('Hide attachments in summary'), '#default_value' => $this->getOption('hide_attachment_summary') ? 1 : 0);
break;
case 'show_admin_links':
$form['#title'] .= $this->t('Show contextual links on this view.');
$form['show_admin_links'] = array('#type' => 'checkbox', '#title' => $this->t('Show contextual links'), '#default_value' => $this->getOption('show_admin_links'));
break;
case 'use_more':
$form['#title'] .= $this->t('Add a more link to the bottom of the display.');
$form['use_more'] = array('#type' => 'checkbox', '#title' => $this->t('Create more link'), '#description' => $this->t("This will add a more link to the bottom of this view, which will link to the page view. If you have more than one page view, the link will point to the display specified in 'Link display' section under pager. You can override the URL at the link display setting."), '#default_value' => $this->getOption('use_more'));
$form['use_more_always'] = array('#type' => 'checkbox', '#title' => $this->t('Always display the more link'), '#description' => $this->t('Check this to display the more link even if there are no more items to display.'), '#default_value' => $this->getOption('use_more_always'), '#states' => array('visible' => array(':input[name="use_more"]' => array('checked' => TRUE))));
$form['use_more_text'] = array('#type' => 'textfield', '#title' => $this->t('More link text'), '#description' => $this->t('The text to display for the more link.'), '#default_value' => $this->getOption('use_more_text'), '#states' => array('visible' => array(':input[name="use_more"]' => array('checked' => TRUE))));
break;
case 'group_by':
$form['#title'] .= $this->t('Allow grouping and aggregation (calculation) of fields.');
$form['group_by'] = array('#type' => 'checkbox', '#title' => $this->t('Aggregate'), '#description' => $this->t('If enabled, some fields may become unavailable. All fields that are selected for grouping will be collapsed to one record per distinct value. Other fields which are selected for aggregation will have the function run on them. For example, you can group nodes on title and count the number of nids in order to get a list of duplicate titles.'), '#default_value' => $this->getOption('group_by'));
break;
case 'access':
$form['#title'] .= $this->t('Access restrictions');
$form['access'] = array('#prefix' => '<div class="clearfix">', '#suffix' => '</div>', '#tree' => TRUE);
$access = $this->getOption('access');
$form['access']['type'] = array('#title' => $this->t('Access'), '#title_display' => 'invisible', '#type' => 'radios', '#options' => Views::fetchPluginNames('access', $this->getType(), array($this->view->storage->get('base_table'))), '#default_value' => $access['type']);
$access_plugin = $this->getPlugin('access');
if ($access_plugin->usesOptions()) {
$form['markup'] = array('#prefix' => '<div class="js-form-item form-item description">', '#markup' => $this->t('You may also adjust the @settings for the currently selected access restriction.', array('@settings' => $this->optionLink($this->t('settings'), 'access_options'))), '#suffix' => '</div>');
}
break;
case 'access_options':
$plugin = $this->getPlugin('access');
$form['#title'] .= $this->t('Access options');
if ($plugin) {
$form['access_options'] = array('#tree' => TRUE);
$plugin->buildOptionsForm($form['access_options'], $form_state);
}
break;
case 'cache':
$form['#title'] .= $this->t('Caching');
$form['cache'] = array('#prefix' => '<div class="clearfix">', '#suffix' => '</div>', '#tree' => TRUE);
$cache = $this->getOption('cache');
$form['cache']['type'] = array('#title' => $this->t('Caching'), '#title_display' => 'invisible', '#type' => 'radios', '#options' => Views::fetchPluginNames('cache', $this->getType(), array($this->view->storage->get('base_table'))), '#default_value' => $cache['type']);
$cache_plugin = $this->getPlugin('cache');
if ($cache_plugin->usesOptions()) {
$form['markup'] = array('#prefix' => '<div class="js-form-item form-item description">', '#suffix' => '</div>', '#markup' => $this->t('You may also adjust the @settings for the currently selected cache mechanism.', array('@settings' => $this->optionLink($this->t('settings'), 'cache_options'))));
}
break;
case 'cache_options':
$plugin = $this->getPlugin('cache');
$form['#title'] .= $this->t('Caching options');
if ($plugin) {
$form['cache_options'] = array('#tree' => TRUE);
$plugin->buildOptionsForm($form['cache_options'], $form_state);
}
break;
//.........这里部分代码省略.........
开发者ID:318io,项目名称:318-io,代码行数:101,代码来源:DisplayPluginBase.php
示例9: buildOptionsForm
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state)
{
// Some form elements belong in a fieldset for presentation, but can't
// be moved into one because of the $form_state->getValues() hierarchy. Those
// elements can add a #fieldset => 'fieldset_name' property, and they'll
// be moved to their fieldset during pre_render.
$form['#pre_render'][] = array(get_class($this), 'preRenderAddFieldsetMarkup');
parent::buildOptionsForm($form, $form_state);
$form['fieldsets'] = array('#type' => 'value', '#value' => array('more', 'admin_label'));
$form['admin_label'] = array('#type' => 'details', '#title' => $this->t('Administrative title'), '#weight' => 150);
$form['admin_label']['admin_label'] = array('#type' => 'textfield', '#title' => $this->t('Administrative title'), '#description' => $this->t('This title will be displayed on the views edit page instead of the default one. This might be useful if you have the same item twice.'), '#default_value' => $this->options['admin_label'], '#parents' => array('options', 'admin_label'));
// This form is long and messy enough that the "Administrative title" option
// belongs in "Administrative title" fieldset at the bottom of the form.
$form['more'] = array('#type' => 'details', '#title' => $this->t('More'), '#weight' => 200, '#optional' => TRUE);
// Allow to alter the default values brought into the form.
// @todo Do we really want to keep this hook.
$this->getModuleHandler()->alter('views_handler_options', $this->options, $this->view);
}
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:21,代码来源:HandlerBase.php
示例10: buildOptionsForm
/**
* Provide the default form for setting options.
*/
public function buildOptionsForm(&$form, &$form_state)
{
parent::buildOptionsForm($form, $form_state);
if ($this->defaultableSections($form_state['section'])) {
views_ui_standard_display_dropdown($form, $form_state, $form_state['section']);
}
$form['#title'] = String::checkPlain($this->display['display_title']) . ': ';
// Set the 'section' to hilite on the form.
// If it's the item we're looking at is pulling from the default display,
// reflect that. Don't use is_defaulted since we want it to show up even
// on the default display.
if (!empty($this->options['defaults'][$form_state['section']])) {
$form['#section'] = 'default-' . $form_state['section'];
} else {
$form['#section'] = $this->display['id'] . '-' . $form_state['section'];
}
switch ($form_state['section']) {
case 'display_id':
$form['#title'] .= t('The machine name of this display');
$form['display_id'] = array('#type' => 'textfield', '#title' => t('Machine name of the display'), '#default_value' => !empty($this->display['new_id']) ? $this->display['new_id'] : $this->display['id'], '#required' => TRUE, '#size' => 64);
break;
case 'display_title':
$form['#title'] .= t('The name and the description of this display');
$form['display_title'] = array('#title' => t('Administrative name'), '#type' => 'textfield', '#default_value' => $this->display['display_title']);
$form['display_description'] = array('#title' => t('Administrative description'), '#type' => 'textfield', '#default_value' => $this->getOption('display_description'));
break;
case 'display_comment':
$form['#title'] .= t('Administrative comment');
$form['display_comment'] = array('#type' => 'textarea', '#title' => t('Administrative comment'), '#description' => t('This description will only be seen within the administrative interface and can be used to document this display.'), '#default_value' => $this->getOption('display_comment'));
break;
case 'title':
$form['#title'] .= t('The title of this view');
$form['title'] = array('#title' => t('Title'), '#type' => 'textfield', '#description' => t('This title will be displayed with the view, wherever titles are normally displayed; i.e, as the page title, block title, etc.'), '#default_value' => $this->getOption('title'), '#maxlength' => 255);
break;
case 'css_class':
$form['#title'] .= t('CSS class');
$form['css_class'] = array('#type' => 'textfield', '#title' => t('CSS class name(s)'), '#description' => t('Multiples classes should be separated by spaces.'), '#default_value' => $this->getOption('css_class'));
break;
case 'use_ajax':
$form['#title'] .= t('Use AJAX when available to load this view');
$form['use_ajax'] = array('#description' => t('When viewing a view, things like paging, table sorting, and exposed filters will not trigger a page refresh.'), '#type' => 'checkbox', '#title' => t('Use AJAX'), '#default_value' => $this->getOption('use_ajax') ? 1 : 0);
break;
case 'hide_attachment_summary':
$form['#title'] .= t('Hide attachments when displaying a contextual filter summary');
$form['hide_attachment_summary'] = array('#type' => 'checkbox', '#title' => t('Hide attachments in summary'), '#default_value' => $this->getOption('hide_attachment_summary') ? 1 : 0);
break;
case 'show_admin_links':
$form['#title'] .= t('Show contextual links on this view.');
$form['show_admin_links'] = array('#type' => 'checkbox', '#title' => t('Show contextual links'), '#default_value' => $this->getOption('show_admin_links'));
break;
case 'use_more':
$form['#title'] .= t('Add a more link to the bottom of the display.');
$form['use_more'] = array('#type' => 'checkbox', '#title' => t('Create more link'), '#description' => t("This will add a more link to the bottom of this view, which will link to the page view. If you have more than one page view, the link will point to the display specified in 'Link display' section under pager. You can override the url at the link display setting."), '#default_value' => $this->getOption('use_more'));
$form['use_more_always'] = array('#type' => 'checkbox', '#title' => t('Always display the more link'), '#description' => t('Check this to display the more link even if there are no more items to display.'), '#default_value' => $this->getOption('use_more_always'), '#states' => array('visible' => array(':input[name="use_more"]' => array('checked' => TRUE))));
$form['use_more_text'] = array('#type' => 'textfield', '#title' => t('More link text'), '#description' => t('The text to display for the more link.'), '#default_value' => $this->getOption('use_more_text'), '#states' => array('visible' => array(':input[name="use_more"]' => array('checked' => TRUE))));
break;
case 'group_by':
$form['#title'] .= t('Allow grouping and aggregation (calculation) of fields.');
$form['group_by'] = array('#type' => 'checkbox', '#title' => t('Aggregate'), '#description' => t('If enabled, some fields may become unavailable. All fields that are selected for grouping will be collapsed to one record per distinct value. Other fields which are selected for aggregation will have the function run on them. For example, you can group nodes on title and count the number of nids in order to get a list of duplicate titles.'), '#default_value' => $this->getOption('group_by'));
break;
case 'access':
$form['#title'] .= t('Access restrictions');
$form['access'] = array('#prefix' => '<div class="clearfix">', '#suffix' => '</div>', '#tree' => TRUE);
$access = $this->getOption('access');
$form['access']['type'] = array('#title' => t('Access'), '#title_display' => 'invisible', '#type' => 'radios', '#options' => Views::fetchPluginNames('access', $this->getType(), array($this->view->storage->get('base_table'))), '#default_value' => $access['type']);
$access_plugin = $this->getPlugin('access');
if ($access_plugin->usesOptions()) {
$form['markup'] = array('#prefix' => '<div class="form-item description">', '#markup' => t('You may also adjust the !settings for the currently selected access restriction.', array('!settings' => $this->optionLink(t('settings'), 'access_options'))), '#suffix' => '</div>');
}
break;
case 'access_options':
$plugin = $this->getPlugin('access');
$form['#title'] .= t('Access options');
if ($plugin) {
$form['access_options'] = array('#tree' => TRUE);
$plugin->buildOptionsForm($form['access_options'], $form_state);
}
break;
case 'cache':
$form['#title'] .= t('Caching');
$form['cache'] = array('#prefix' => '<div class="clearfix">', '#suffix' => '</div>', '#tree' => TRUE);
$cache = $this->getOption('cache');
$form['cache']['type'] = array('#title' => t('Caching'), '#title_display' => 'invisible', '#type' => 'radios', '#options' => Views::fetchPluginNames('cache', $this->getType(), array($this->view->storage->get('base_table'))), '#default_value' => $cache['type']);
$cache_plugin = $this->getPlugin('cache');
if ($cache_plugin->usesOptions()) {
$form['markup'] = array('#prefix' => '<div class="form-item description">', '#suffix' => '</div>', '#markup' => t('You may also adjust the !settings for the currently selected cache mechanism.', array('!settings' => $this->optionLink(t('settings'), 'cache_options'))));
}
break;
case 'cache_options':
$plugin = $this->getPlugin('cache');
$form['#title'] .= t('Caching options');
if ($plugin) {
$form['cache_options'] = array('#tree' => TRUE);
$plugin->buildOptionsForm($form['cache_options'], $form_state);
}
break;
case 'query':
//.........这里部分代码省略.........
开发者ID:shumer,项目名称:blog,代码行数:101,代码来源:DisplayPluginBase.php
示例11: viewsTokenReplace
public function viewsTokenReplace($text, $tokens)
{
return parent::viewsTokenReplace($text, $tokens);
}
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:4,代码来源:PluginBaseTest.php
注:本文中的Drupal\views\Plugin\views\PluginBase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论