Chris@0: 'entity.manager']; Chris@18: Chris@18: /** Chris@18: * The entity type manager service. Chris@0: * Chris@18: * @var \Drupal\Core\Entity\EntityTypeManagerInterface Chris@0: */ Chris@18: protected $entityTypeManager; Chris@0: Chris@0: /** Chris@0: * Constructs a FieldUiRouteEnhancer object. Chris@0: * Chris@18: * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager Chris@18: * The entity type manager service. Chris@0: */ Chris@18: public function __construct(EntityTypeManagerInterface $entity_type_manager) { Chris@18: $this->entityTypeManager = $entity_type_manager; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function enhance(array $defaults, Request $request) { Chris@14: if (!$this->applies($defaults[RouteObjectInterface::ROUTE_OBJECT])) { Chris@14: return $defaults; Chris@14: } Chris@18: if (($bundle = $this->entityTypeManager->getDefinition($defaults['entity_type_id'])->getBundleEntityType()) && isset($defaults[$bundle])) { Chris@0: // Field UI forms only need the actual name of the bundle they're dealing Chris@0: // with, not an upcasted entity object, so provide a simple way for them Chris@0: // to get it. Chris@0: $defaults['bundle'] = $defaults['_raw_variables']->get($bundle); Chris@0: } Chris@0: Chris@0: return $defaults; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@14: protected function applies(Route $route) { Chris@0: return ($route->hasOption('_field_ui')); Chris@0: } Chris@0: Chris@0: }