本文整理汇总了PHP中Drupal\views\Views::fetchPluginNames方法的典型用法代码示例。如果您正苦于以下问题:PHP Views::fetchPluginNames方法的具体用法?PHP Views::fetchPluginNames怎么用?PHP Views::fetchPluginNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\views\Views
的用法示例。
在下文中一共展示了Views::fetchPluginNames方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initDisplay
/**
* Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::initDisplay().
*/
public function initDisplay(ViewExecutable $view, array &$display, array &$options = NULL)
{
parent::initDisplay($view, $display, $options);
// Set the default row style. Ideally this would be part of the option
// definition, but in this case it's dependent on the view's base table,
// which we don't know until init().
$row_plugins = Views::fetchPluginNames('row', $this->getType(), array($view->storage->get('base_table')));
$default_row_plugin = key($row_plugins);
if (empty($this->options['row']['type'])) {
$this->options['row']['type'] = $default_row_plugin;
}
}
示例2: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$form = parent::buildForm($form, $form_state);
$config = $this->config('views.settings');
$form['cache'] = array('#type' => 'details', '#title' => $this->t('Caching'), '#open' => TRUE);
$form['cache']['skip_cache'] = array('#type' => 'checkbox', '#title' => $this->t('Disable views data caching'), '#description' => $this->t("Views caches data about tables, modules and views available, to increase performance. By checking this box, Views will skip this cache and always rebuild this data when needed. This can have a serious performance impact on your site."), '#default_value' => $config->get('skip_cache'));
$form['cache']['clear_cache'] = array('#type' => 'submit', '#value' => $this->t("Clear Views' cache"), '#submit' => array('::cacheSubmit'));
$form['debug'] = array('#type' => 'details', '#title' => $this->t('Debugging'), '#open' => TRUE);
$form['debug']['sql_signature'] = array('#type' => 'checkbox', '#title' => $this->t('Add Views signature to all SQL queries'), '#description' => $this->t("All Views-generated queries will include the name of the views and display 'view-name:display-name' as a string at the end of the SELECT clause. This makes identifying Views queries in database server logs simpler, but should only be used when troubleshooting."), '#default_value' => $config->get('sql_signature'));
$options = Views::fetchPluginNames('display_extender');
if (!empty($options)) {
$form['extenders'] = array('#type' => 'details', '#open' => TRUE);
$form['extenders']['display_extenders'] = array('#title' => $this->t('Display extenders'), '#default_value' => array_filter($config->get('display_extenders')), '#options' => $options, '#type' => 'checkboxes', '#description' => $this->t('Select extensions of the views interface.'));
}
return $form;
}
示例3: 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;
//.........这里部分代码省略.........
示例4: renderDisplayTop
/**
* Render the top of the display so it can be updated during ajax operations.
*/
public function renderDisplayTop(ViewUI $view)
{
$display_id = $this->displayID;
$element['#theme_wrappers'][] = 'views_ui_container';
$element['#attributes']['class'] = array('views-display-top', 'clearfix');
$element['#attributes']['id'] = array('views-display-top');
// Extra actions for the display
$element['extra_actions'] = array('#type' => 'dropbutton', '#attributes' => array('id' => 'views-display-extra-actions'), '#links' => array('edit-details' => array('title' => $this->t('Edit view name/description'), 'url' => Url::fromRoute('views_ui.form_edit_details', ['js' => 'nojs', 'view' => $view->id(), 'display_id' => $display_id]), 'attributes' => array('class' => array('views-ajax-link'))), 'analyze' => array('title' => $this->t('Analyze view'), 'url' => Url::fromRoute('views_ui.form_analyze', ['js' => 'nojs', 'view' => $view->id(), 'display_id' => $display_id]), 'attributes' => array('class' => array('views-ajax-link'))), 'duplicate' => array('title' => $this->t('Duplicate view'), 'url' => $view->urlInfo('duplicate-form')), 'reorder' => array('title' => $this->t('Reorder displays'), 'url' => Url::fromRoute('views_ui.form_reorder_displays', ['js' => 'nojs', 'view' => $view->id(), 'display_id' => $display_id]), 'attributes' => array('class' => array('views-ajax-link')))));
if ($view->access('delete')) {
$element['extra_actions']['#links']['delete'] = array('title' => $this->t('Delete view'), 'url' => $view->urlInfo('delete-form'));
}
// Let other modules add additional links here.
\Drupal::moduleHandler()->alter('views_ui_display_top_links', $element['extra_actions']['#links'], $view, $display_id);
if (isset($view->type) && $view->type != $this->t('Default')) {
if ($view->type == $this->t('Overridden')) {
$element['extra_actions']['#links']['revert'] = array('title' => $this->t('Revert view'), 'href' => "admin/structure/views/view/{$view->id()}/revert", 'query' => array('destination' => $view->url('edit-form')));
} else {
$element['extra_actions']['#links']['delete'] = array('title' => $this->t('Delete view'), 'url' => $view->urlInfo('delete-form'));
}
}
// Determine the displays available for editing.
if ($tabs = $this->getDisplayTabs($view)) {
if ($display_id) {
$tabs[$display_id]['#active'] = TRUE;
}
$tabs['#prefix'] = '<h2 class="visually-hidden">' . $this->t('Secondary tabs') . '</h2><ul id = "views-display-menu-tabs" class="tabs secondary">';
$tabs['#suffix'] = '</ul>';
$element['tabs'] = $tabs;
}
// Buttons for adding a new display.
foreach (Views::fetchPluginNames('display', NULL, array($view->get('base_table'))) as $type => $label) {
$element['add_display'][$type] = array('#type' => 'submit', '#value' => $this->t('Add @display', array('@display' => $label)), '#limit_validation_errors' => array(), '#submit' => array('::submitDisplayAdd', '::submitDelayDestination'), '#attributes' => array('class' => array('add-display')), '#process' => array_merge(array('views_ui_form_button_was_clicked'), $this->elementInfo->getInfoProperty('submit', '#process', array())), '#values' => array($this->t('Add @display', array('@display' => $label)), $label));
}
return $element;
}
示例5: rowStyleOptions
/**
* Retrieves row style plugin names.
*
* @return array
* Returns the plugin names available for the base table of the wizard.
*/
protected function rowStyleOptions()
{
// Get all available row plugins by default.
$options = Views::fetchPluginNames('row', 'normal', array($this->base_table));
return $options;
}
示例6: 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':
//.........这里部分代码省略.........
示例7: testViewsFetchPluginNames
/**
* Tests the \Drupal\views\Views::fetchPluginNames() method.
*/
public function testViewsFetchPluginNames()
{
// All style plugins should be returned, as we have not specified a type.
$plugins = Views::fetchPluginNames('style');
$definitions = $this->container->get('plugin.manager.views.style')->getDefinitions();
$expected = array();
foreach ($definitions as $id => $definition) {
$expected[$id] = $definition['title'];
}
asort($expected);
$this->assertIdentical(array_keys($plugins), array_keys($expected));
// Test using the 'test' style plugin type only returns the test_style and
// mapping_test plugins.
$plugins = Views::fetchPluginNames('style', 'test');
$this->assertIdentical(array_keys($plugins), array('mapping_test', 'test_style', 'test_template_style'));
// Test a non existent style plugin type returns no plugins.
$plugins = Views::fetchPluginNames('style', $this->randomString());
$this->assertIdentical($plugins, array());
}
示例8: newDisplay
/**
* {@inheritdoc}
*/
public function newDisplay()
{
parent::newDisplay();
// Set the default row style. Ideally this would be part of the option
// definition, but in this case it's dependent on the view's base table,
// which we don't know until init().
if (empty($this->options['row']['type']) || $this->options['row']['type'] === 'rss_fields') {
$row_plugins = Views::fetchPluginNames('row', $this->getType(), array($this->view->storage->get('base_table')));
$default_row_plugin = key($row_plugins);
$options = $this->getOption('row');
$options['type'] = $default_row_plugin;
$this->setOption('row', $options);
}
}