You are here

class UserFormModesSubscriber in Form mode manager 8

Subscriber for form_mode_manager routes.

Hierarchy

Expanded class hierarchy of UserFormModesSubscriber

1 string reference to 'UserFormModesSubscriber'
form_mode_manager.services.yml in ./form_mode_manager.services.yml
form_mode_manager.services.yml
1 service uses UserFormModesSubscriber
form_mode_manager.user_route_subscriber in ./form_mode_manager.services.yml
Drupal\form_mode_manager\Routing\EventSubscriber\UserFormModesSubscriber

File

src/Routing/EventSubscriber/UserFormModesSubscriber.php, line 11

Namespace

Drupal\form_mode_manager\Routing\EventSubscriber
View source
class UserFormModesSubscriber extends FormModesSubscriber {

  /**
   * {@inheritdoc}
   */
  const FORM_MODE_DEFAULT_CONTROLLER = '\\Drupal\\form_mode_manager\\Controller\\UserFormModeController';

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    $form_modes_definitions = $this->formModeManager
      ->getAllFormModesDefinitions();
    $entity_type_id = 'user';
    if (isset($form_modes_definitions[$entity_type_id])) {
      $form_modes = $form_modes_definitions[$entity_type_id];
      $entity_type = $this->entityTypeManager
        ->getDefinition($entity_type_id);
      $this
        ->addFormModesRoutes($collection, $entity_type, $form_modes);
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {

    // Ensure fire after FormModesSubscriber alters.
    $events[RoutingEvents::ALTER] = [
      'onAlterRoutes',
      10,
    ];
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FormModesSubscriber::$entityDisplayRepository protected property The entity display repository.
FormModesSubscriber::$entityRoutingMap protected property The Routes Manager Plugin.
FormModesSubscriber::$entityTypeManager protected property The entity type manager service.
FormModesSubscriber::$formModeManager protected property The entity display repository.
FormModesSubscriber::addFormModesRoutes protected function Generate all operations routes for entities.
FormModesSubscriber::getFormModeListPageRoute public function Generate route to Form Mode Manager `add-list` route.
FormModesSubscriber::getFormModeRoute public function Get the Form Mode Manager route for given operation.
FormModesSubscriber::getFormModeRouteDefaults protected function Get defaults parameters nedeed to build Form Mode Manager routes.
FormModesSubscriber::getFormModeRouteOptions protected function Get options parameters nedeed to build Form Mode Manager routes.
FormModesSubscriber::getFormModeRouteRequirements protected function Get options requirements nedeed to build Form Mode Manager routes.
FormModesSubscriber::isEditRoute public static function Evaluate if current context is edit.
FormModesSubscriber::ROUTE_PATH_CONTEXT_REGEX constant The Regex pattern to contextualize process by route path.
FormModesSubscriber::setAddPageCollection public function Set one add_page route per form_mode for compatible entities.
FormModesSubscriber::setFormModeCollection public function Create a route per form_mode for given operation form.
FormModesSubscriber::setRoutes private function Set Form Mode Manager routes based on parent entity routes.
FormModesSubscriber::userListEnhancements public function Set a specific callback for Edit context of User entity.
FormModesSubscriber::__construct public function Constructs a new RouteSubscriber object.
RouteSubscriberBase::onAlterRoutes public function Delegates the route altering to self::alterRoutes(). 1
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
UserFormModesSubscriber::alterRoutes protected function Alters existing routes for a specific collection. Overrides FormModesSubscriber::alterRoutes
UserFormModesSubscriber::FORM_MODE_DEFAULT_CONTROLLER constant The Regex pattern to contextualize process by route path. Overrides FormModesSubscriber::FORM_MODE_DEFAULT_CONTROLLER
UserFormModesSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to. Overrides RouteSubscriberBase::getSubscribedEvents