/**
  * @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');
 }
 /**
  * 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.'));
 }
Exemple #3
0
 /**
  * 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.'));
 }
Exemple #4
0
 /**
  * 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.');
     }
 }