Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add views display manager through DI #3646

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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