Skip to content

Commit

Permalink
Add views display manager through DI (#3646)
Browse files Browse the repository at this point in the history
  • Loading branch information
LOBsTerr authored and jmolivas committed Jan 7, 2018
1 parent 268569a commit f30e6e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config/services/debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ services:
- { name: drupal.command }
console.views_debug:
class: Drupal\Console\Command\Debug\ViewsCommand
arguments: ['@entity_type.manager']
arguments: ['@entity_type.manager', '@plugin.manager.views.display']
tags:
- { name: drupal.command }
console.views_plugins_debug:
Expand Down
12 changes: 9 additions & 3 deletions src/Command/Debug/ViewsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Drupal\Console\Core\Command\Command;
use Drupal\views\Entity\View;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Console\Core\Style\DrupalStyle;

/**
Expand All @@ -27,15 +28,21 @@ class ViewsCommand extends Command
* @var EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* @var PluginManagerInterface
*/
protected $viewsDisplayManager;

/**
* DebugCommand constructor.
*
* @param EntityTypeManagerInterface $entityTypeManager
* @param PluginManagerInterface $viewsDisplayManager
*/
public function __construct(EntityTypeManagerInterface $entityTypeManager)
public function __construct(EntityTypeManagerInterface $entityTypeManager, PluginManagerInterface $viewsDisplayManager)
{
$this->entityTypeManager = $entityTypeManager;
$this->viewsDisplayManager = $viewsDisplayManager;
parent::__construct();
}

Expand Down Expand Up @@ -215,10 +222,9 @@ protected function viewDisplayPaths(View $view, $display_id = null)
*/
protected function viewDisplayList(View $view)
{
$displayManager = $this->getViewDisplayManager();
$displays = [];
foreach ($view->get('display') as $display) {
$definition = $displayManager->getDefinition($display['display_plugin']);
$definition = $this->viewsDisplayManager->getDefinition($display['display_plugin']);
if (!empty($definition['admin'])) {
// Cast the admin label to a string since it is an object.
$displays[$definition['id']]['name'] = (string) $definition['admin'];
Expand Down

0 comments on commit f30e6e5

Please sign in to comment.