Created
July 7, 2018 11:56
-
-
Save cyberlex404/6ed1269321da85a4d4404d95ffd34f47 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function housing_entity_type_alter(array &$entity_types) { | |
| $form_modes = \Drupal::service('entity_display.repository')->getAllFormModes(); | |
| foreach ($form_modes as $entity_type => $display_modes) { | |
| if ($entity_type !== 'housing') { | |
| // We are only interested in adding a handler to the Node entity. | |
| continue; | |
| } | |
| /* @var \Drupal\Core\Entity\EntityTypeInterface $entity */ | |
| $entity = $entity_types[$entity_type]; | |
| foreach ($display_modes as $machine_name => $form_display) { | |
| if ($machine_name != 'register') { | |
| // Get the correct canonical path to add operation. | |
| $path = $entity->getLinkTemplate('canonical') . "/$machine_name"; | |
| $default_handler_class = $entity->getHandlerClasses()['form']['default']; | |
| $entity->setFormClass($machine_name, $default_handler_class) | |
| ->setLinkTemplate($machine_name, $path); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment