You are here

class FlexiformRouteEnhancer in Flexiform 8

Enhances Flexiform routes.

To get the form display object from request attributes.

Hierarchy

Expanded class hierarchy of FlexiformRouteEnhancer

1 string reference to 'FlexiformRouteEnhancer'
flexiform.services.yml in ./flexiform.services.yml
flexiform.services.yml
1 service uses FlexiformRouteEnhancer
flexiform.route_enhancer in ./flexiform.services.yml
Drupal\flexiform\Routing\FlexiformRouteEnhancer

File

src/Routing/FlexiformRouteEnhancer.php, line 15

Namespace

Drupal\flexiform\Routing
View source
class FlexiformRouteEnhancer implements EnhancerInterface {

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Constructs a FlexiformRouteEnhancer object.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
    $this->entityTypeManager = $entity_type_manager;
  }

  /**
   * {@inheritdoc}
   */
  public function enhance(array $defaults, Request $request) {

    /* @var \Symfony\Component\Routing\Route $route */
    $route = $defaults[RouteObjectInterface::ROUTE_OBJECT];
    if (!$route
      ->hasOption('_flexiform_form_entity')) {
      return $defaults;
    }
    $defaults['form_display'] = $this->entityTypeManager
      ->getStorage('entity_form_display')
      ->load($defaults['entity_type_id'] . '.' . $defaults['bundle'] . '.' . $defaults['form_mode_name']);
    return $defaults;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FlexiformRouteEnhancer::$entityTypeManager protected property The entity type manager.
FlexiformRouteEnhancer::enhance public function
FlexiformRouteEnhancer::__construct public function Constructs a FlexiformRouteEnhancer object.