Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 9 |
| FieldUiRouteEnhancer | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
30 | |
0.00% |
0 / 9 |
| __construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| enhance | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 5 |
|||
| applies | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| <?php | |
| /** | |
| * @file | |
| * Contains \Drupal\field_ui\Routing\FieldUiRouteEnhancer. | |
| */ | |
| namespace Drupal\field_ui\Routing; | |
| use Drupal\Core\Entity\EntityManagerInterface; | |
| use Drupal\Core\Routing\Enhancer\RouteEnhancerInterface; | |
| use Symfony\Component\HttpFoundation\Request; | |
| use Symfony\Component\Routing\Route; | |
| /** | |
| * Enhances Field UI routes by adding proper information about the bundle name. | |
| */ | |
| class FieldUiRouteEnhancer implements RouteEnhancerInterface { | |
| /** | |
| * The entity manager. | |
| * | |
| * @var \Drupal\Core\Entity\EntityManagerInterface | |
| */ | |
| protected $entityManager; | |
| /** | |
| * Constructs a FieldUiRouteEnhancer object. | |
| * | |
| * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager | |
| * The entity manager. | |
| */ | |
| public function __construct(EntityManagerInterface $entity_manager) { | |
| $this->entityManager = $entity_manager; | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function enhance(array $defaults, Request $request) { | |
| if (($bundle = $this->entityManager->getDefinition($defaults['entity_type_id'])->getBundleEntityType()) && isset($defaults[$bundle])) { | |
| // Field UI forms only need the actual name of the bundle they're dealing | |
| // with, not an upcasted entity object, so provide a simple way for them | |
| // to get it. | |
| $defaults['bundle'] = $defaults['_raw_variables']->get($bundle); | |
| } | |
| return $defaults; | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function applies(Route $route) { | |
| return ($route->hasOption('_field_ui')); | |
| } | |
| } |