Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 23 |
| FieldUiLocalAction | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
42 | |
0.00% |
0 / 23 |
| __construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
| create | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 5 |
|||
| getDerivativeDefinitions | |
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 15 |
|||
| <?php | |
| /** | |
| * @file | |
| * Contains \Drupal\field_ui\Plugin\Derivative\FieldUiLocalAction. | |
| */ | |
| namespace Drupal\field_ui\Plugin\Derivative; | |
| use Drupal\Component\Plugin\Derivative\DeriverBase; | |
| use Drupal\Core\Entity\EntityManagerInterface; | |
| use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; | |
| use Drupal\Core\Routing\RouteProviderInterface; | |
| use Drupal\Core\StringTranslation\StringTranslationTrait; | |
| use Symfony\Component\DependencyInjection\ContainerInterface; | |
| /** | |
| * Provides local action definitions for all entity bundles. | |
| */ | |
| class FieldUiLocalAction extends DeriverBase implements ContainerDeriverInterface { | |
| use StringTranslationTrait; | |
| /** | |
| * The entity manager | |
| * | |
| * @var \Drupal\Core\Entity\EntityManagerInterface | |
| */ | |
| protected $entityManager; | |
| /** | |
| * Constructs a FieldUiLocalAction object. | |
| * | |
| * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider | |
| * The route provider to load routes by name. | |
| * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager | |
| * The entity manager. | |
| */ | |
| public function __construct(RouteProviderInterface $route_provider, EntityManagerInterface $entity_manager) { | |
| $this->routeProvider = $route_provider; | |
| $this->entityManager = $entity_manager; | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public static function create(ContainerInterface $container, $base_plugin_id) { | |
| return new static( | |
| $container->get('router.route_provider'), | |
| $container->get('entity.manager') | |
| ); | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function getDerivativeDefinitions($base_plugin_definition) { | |
| $this->derivatives = array(); | |
| foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { | |
| if ($entity_type->get('field_ui_base_route')) { | |
| $this->derivatives["field_storage_config_add_$entity_type_id"] = array( | |
| 'route_name' => "field_ui.field_storage_config_add_$entity_type_id", | |
| 'title' => $this->t('Add field'), | |
| 'appears_on' => array("entity.$entity_type_id.field_ui_fields"), | |
| ); | |
| } | |
| } | |
| foreach ($this->derivatives as &$entry) { | |
| $entry += $base_plugin_definition; | |
| } | |
| return $this->derivatives; | |
| } | |
| } |