EntityFlagTypeDeriver.php in Flag 8.4
File
src/Plugin/Derivative/EntityFlagTypeDeriver.php
View source
<?php
namespace Drupal\flag\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\Core\Entity\ContentEntityTypeInterface;
class EntityFlagTypeDeriver extends DeriverBase {
public function getDerivativeDefinitions($base_plugin_def) {
$derivatives = [];
foreach (\Drupal::entityTypeManager()
->getDefinitions() as $entity_id => $entity_type) {
if (!$entity_type instanceof ContentEntityTypeInterface) {
continue;
}
$derivatives[$entity_id] = [
'title' => $entity_type
->getLabel(),
'entity_type' => $entity_id,
'config_dependencies' => [
'module' => [
$entity_type
->getProvider(),
],
],
] + $base_plugin_def;
}
return $derivatives;
}
}