pino-8.x-1.2-no-core/modules/member/src/MemberHtmlRouteProvider.php
modules/member/src/MemberHtmlRouteProvider.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | <?php namespace Drupal\member; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider; use Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider; use Symfony\Component\Routing\Route; /** * Provides routes for Member entities. * * @see \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider * @see \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider */ class MemberHtmlRouteProvider extends DefaultHtmlRouteProvider { /** * {@inheritdoc} */ public function getRoutes(EntityTypeInterface $entity_type ) { $collection = parent::getRoutes( $entity_type ); $entity_type_id = $entity_type ->id(); if ( $history_route = $this ->getHistoryRoute( $entity_type )) { $collection ->add( "entity.{$entity_type_id}.version_history" , $history_route ); } if ( $revision_route = $this ->getRevisionRoute( $entity_type )) { $collection ->add( "entity.{$entity_type_id}.revision" , $revision_route ); } if ( $revert_route = $this ->getRevisionRevertRoute( $entity_type )) { $collection ->add( "entity.{$entity_type_id}.revision_revert" , $revert_route ); } if ( $delete_route = $this ->getRevisionDeleteRoute( $entity_type )) { $collection ->add( "entity.{$entity_type_id}.revision_delete" , $delete_route ); } if ( $translation_route = $this ->getRevisionTranslationRevertRoute( $entity_type )) { $collection ->add( "{$entity_type_id}.revision_revert_translation_confirm" , $translation_route ); } if ( $settings_form_route = $this ->getSettingsFormRoute( $entity_type )) { $collection ->add( "$entity_type_id.settings" , $settings_form_route ); } return $collection ; } /** * Gets the version history route. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type. * * @return \Symfony\Component\Routing\Route|null * The generated route, if available. */ protected function getHistoryRoute(EntityTypeInterface $entity_type ) { if ( $entity_type ->hasLinkTemplate( 'version-history' )) { $route = new Route( $entity_type ->getLinkTemplate( 'version-history' )); $route ->setDefaults([ '_title' => "{$entity_type->getLabel()} revisions" , '_controller' => '\Drupal\member\Controller\MemberController::revisionOverview' , ]) ->setRequirement( '_permission' , 'access member revisions' ) ->setOption( '_admin_route' , TRUE); return $route ; } } /** * Gets the revision route. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type. * * @return \Symfony\Component\Routing\Route|null * The generated route, if available. */ protected function getRevisionRoute(EntityTypeInterface $entity_type ) { if ( $entity_type ->hasLinkTemplate( 'revision' )) { $route = new Route( $entity_type ->getLinkTemplate( 'revision' )); $route ->setDefaults([ '_controller' => '\Drupal\member\Controller\MemberController::revisionShow' , '_title_callback' => '\Drupal\member\Controller\MemberController::revisionPageTitle' , ]) ->setRequirement( '_permission' , 'access member revisions' ) ->setOption( '_admin_route' , TRUE); return $route ; } } /** * Gets the revision revert route. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type. * * @return \Symfony\Component\Routing\Route|null * The generated route, if available. */ protected function getRevisionRevertRoute(EntityTypeInterface $entity_type ) { if ( $entity_type ->hasLinkTemplate( 'revision_revert' )) { $route = new Route( $entity_type ->getLinkTemplate( 'revision_revert' )); $route ->setDefaults([ '_form' => '\Drupal\member\Form\MemberRevisionRevertForm' , '_title' => 'Revert to earlier revision' , ]) ->setRequirement( '_permission' , 'revert all member revisions' ) ->setOption( '_admin_route' , TRUE); return $route ; } } /** * Gets the revision delete route. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type. * * @return \Symfony\Component\Routing\Route|null * The generated route, if available. */ protected function getRevisionDeleteRoute(EntityTypeInterface $entity_type ) { if ( $entity_type ->hasLinkTemplate( 'revision_delete' )) { $route = new Route( $entity_type ->getLinkTemplate( 'revision_delete' )); $route ->setDefaults([ '_form' => '\Drupal\member\Form\MemberRevisionDeleteForm' , '_title' => 'Delete earlier revision' , ]) ->setRequirement( '_permission' , 'delete all member revisions' ) ->setOption( '_admin_route' , TRUE); return $route ; } } /** * Gets the revision translation revert route. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type. * * @return \Symfony\Component\Routing\Route|null * The generated route, if available. */ protected function getRevisionTranslationRevertRoute(EntityTypeInterface $entity_type ) { if ( $entity_type ->hasLinkTemplate( 'translation_revert' )) { $route = new Route( $entity_type ->getLinkTemplate( 'translation_revert' )); $route ->setDefaults([ '_form' => '\Drupal\member\Form\MemberRevisionRevertTranslationForm' , '_title' => 'Revert to earlier revision of a translation' , ]) ->setRequirement( '_permission' , 'revert all member revisions' ) ->setOption( '_admin_route' , TRUE); return $route ; } } /** * Gets the settings form route. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type. * * @return \Symfony\Component\Routing\Route|null * The generated route, if available. */ protected function getSettingsFormRoute(EntityTypeInterface $entity_type ) { if (! $entity_type ->getBundleEntityType()) { $route = new Route( "/admin/structure/{$entity_type->id()}/settings" ); $route ->setDefaults([ '_form' => 'Drupal\member\Form\MemberSettingsForm' , '_title' => "{$entity_type->getLabel()} settings" , ]) ->setRequirement( '_permission' , $entity_type ->getAdminPermission()) ->setOption( '_admin_route' , TRUE); return $route ; } } } |