AddDefaultLinkDeriver.php in Panelizer 8.3
File
src/Plugin/AddDefaultLinkDeriver.php
View source
<?php
namespace Drupal\panelizer\Plugin;
use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class AddDefaultLinkDeriver extends DeriverBase implements ContainerDeriverInterface {
protected $panelizerEntityManager;
public function __construct(PanelizerEntityManagerInterface $panelizer_entity_manager) {
$this->panelizerEntityManager = $panelizer_entity_manager;
}
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('plugin.manager.panelizer_entity'));
}
public function getDerivativeDefinitions($base_plugin_definition) {
foreach ($this->panelizerEntityManager
->getDefinitions() as $plugin_id => $definition) {
$this->derivatives["{$plugin_id}"] = $base_plugin_definition;
$this->derivatives["{$plugin_id}"]['appears_on'] = [
"entity.entity_view_display.{$plugin_id}.default",
"entity.entity_view_display.{$plugin_id}.view_mode",
];
}
return parent::getDerivativeDefinitions($base_plugin_definition);
}
}