JuiceboxConfFieldContextualLinks.php in Juicebox HTML5 Responsive Image Galleries 8.2
File
src/Plugin/Derivative/JuiceboxConfFieldContextualLinks.php
View source
<?php
namespace Drupal\juicebox\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class JuiceboxConfFieldContextualLinks extends DeriverBase implements ContainerDeriverInterface {
protected $entityTypeManager;
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('entity_type.manager'));
}
public function getDerivativeDefinitions($base_plugin_definition) {
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type_id => $entity_type) {
if ($entity_type
->isSubclassOf('\\Drupal\\Core\\Entity\\ContentEntityInterface')) {
$bundle_entity_type = $entity_type
->getBundleEntityType();
$type_name = $bundle_entity_type == 'bundle' ? $entity_type_id : $bundle_entity_type;
$this->derivatives['juicebox.conf_field_' . $entity_type_id]['title'] = t('Configure galleries of this field instance');
$this->derivatives['juicebox.conf_field_' . $entity_type_id]['route_name'] = 'entity.entity_view_display.' . $entity_type_id . '.view_mode';
$this->derivatives['juicebox.conf_field_' . $entity_type_id]['group'] = 'juicebox_conf_field_' . $entity_type_id;
}
}
return parent::getDerivativeDefinitions($base_plugin_definition);
}
}