本文整理汇总了PHP中Drupal\views\Views::pluginList方法的典型用法代码示例。如果您正苦于以下问题:PHP Views::pluginList方法的具体用法?PHP Views::pluginList怎么用?PHP Views::pluginList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\views\Views
的用法示例。
在下文中一共展示了Views::pluginList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pluginList
/**
* @param \Drupal\Console\Style\DrupalStyle $io
* @param $tag
* @param $status
*/
protected function pluginList(DrupalStyle $io, $type)
{
$plugins = Views::pluginList();
$rows = [];
foreach ($plugins as &$plugin) {
if ($type && $plugin['type'] != $type) {
continue;
}
$views = [];
// Link each view name to the view itself.
foreach ($plugin['views'] as $plugin_name => $view) {
$views[] = $view;
}
$rows[] = [$plugin['type'], $plugin['title'], $plugin['provider'], implode(",", $views)];
}
// Sort rows by field name.
ksort($rows);
$tableHeader = [$this->trans('commands.views.plugins.debug.messages.type'), $this->trans('commands.views.plugins.debug.messages.name'), $this->trans('commands.views.plugins.debug.messages.provider'), $this->trans('commands.views.plugins.debug.messages.views')];
$io->table($tableHeader, $rows, 'compact');
}
示例2: reportPlugins
/**
* Lists all plugins and what enabled Views use them.
*
* @return array
* The Views plugins report page.
*/
public function reportPlugins()
{
$rows = Views::pluginList();
foreach ($rows as &$row) {
$views = [];
// Link each view name to the view itself.
foreach ($row['views'] as $row_name => $view) {
$views[] = $this->l($view, new Url('entity.view.edit_form', array('view' => $view)));
}
unset($row['views']);
$row['views']['data'] = ['#theme' => 'item_list', '#items' => $views, '#context' => ['list_style' => 'comma-list']];
}
// Sort rows by field name.
ksort($rows);
return array('#type' => 'table', '#header' => array(t('Type'), t('Name'), t('Provided by'), t('Used in')), '#rows' => $rows, '#empty' => t('There are no enabled views.'));
}
示例3: reportPlugins
/**
* Lists all plugins and what enabled Views use them.
*
* @return array
* The Views plugins report page.
*/
public function reportPlugins()
{
$rows = Views::pluginList();
foreach ($rows as &$row) {
// Link each view name to the view itself.
foreach ($row['views'] as $row_name => $view) {
$row['views'][$row_name] = $this->l($view, new Url('entity.view.edit_form', array('view' => $view)));
}
$row['views'] = SafeMarkup::set(implode(', ', $row['views']));
}
// Sort rows by field name.
ksort($rows);
return array('#type' => 'table', '#header' => array(t('Type'), t('Name'), t('Provided by'), t('Used in')), '#rows' => $rows, '#empty' => t('There are no enabled views.'));
}
示例4: testViewsPluginList
/**
* Tests the \Drupal\views\Views::pluginList() method.
*/
public function testViewsPluginList()
{
$plugin_list = Views::pluginList();
// Only plugins used by 'test_view' should be in the plugin list.
foreach (array('display:default', 'pager:none') as $key) {
list($plugin_type, $plugin_id) = explode(':', $key);
$plugin_def = $this->container->get("plugin.manager.views.{$plugin_type}")->getDefinition($plugin_id);
$this->assertTrue(isset($plugin_list[$key]), SafeMarkup::format('The expected @key plugin list key was found.', array('@key' => $key)));
$plugin_details = $plugin_list[$key];
$this->assertEqual($plugin_details['type'], $plugin_type, 'The expected plugin type was found.');
$this->assertEqual($plugin_details['title'], $plugin_def['title'], 'The expected plugin title was found.');
$this->assertEqual($plugin_details['provider'], $plugin_def['provider'], 'The expected plugin provider was found.');
$this->assertTrue(in_array('test_view', $plugin_details['views']), 'The test_view View was found in the list of views using this plugin.');
}
}