-1

I try to have an admin theme for admin user and custom theme for user logged in without /admin/.... in the url.

I create an entity content module, the routing is like that :

    # AnnonceEntity routing definition
entity.annonce_entity.canonical:
  path: '/admin/annonce_entity/{annonce_entity}'
  defaults:
    _entity_view: 'annonce_entity'
    _title: 'Gestion des annonces'
  requirements:
    _entity_access: 'annonce_entity.view'

entity.annonce_entity.collection:
  path: '/annonce/liste'
  defaults:
    _entity_list: 'annonce_entity'
    _title: 'Liste des annonces'
  requirements:
    _user_is_logged_in: 'TRUE'

entity.annonce_entity.add_form:
  path: '/annonce/ajout'
  defaults:
    _entity_form: annonce_entity.add
    _title: 'Ajouter une annonce'
  requirements:
    _user_is_logged_in: 'TRUE'


entity.annonce_entity.edit_form:
  path: '/annonce/{annonce_entity}/edit'
  defaults:
    _entity_form: annonce_entity.edit
    _title: 'Edit Gestion des annonces'
  requirements:
    _user_is_logged_in: 'TRUE'

entity.annonce_entity.delete_form:
  path: '/annonce/{annonce_entity}/delete'
  defaults:
    _entity_form: annonce_entity.delete
    _title: 'Delete Gestion des annonces'
  requirements:
    _user_is_logged_in: 'TRUE'

annonce_entity.settings:
  path: 'admin/structure/annonce_entity'
  defaults:
   _form: '\Drupal\annonce\Entity\Form\AnnonceEntitySettingsForm'
   _title: 'Configuration des annonces'
  requirements:
    _permission: 'administer gestion des annonces entities'

I remove all /admin/ path for get better url for the simple user.

If i do that, it's ok for user admin and simple user but url is not good

entity.annonce_entity.collection:
  path: '/admin/annonce/liste'
  defaults:
    _entity_list: 'annonce_entity'
    _title: 'Liste des annonces'
  requirements:
    _user_is_logged_in: 'TRUE'

All is good but the path is /admin/annonce/liste, i prefer /annonce/liste.

Anyone have a suggestion ?

i have take a look into the user module, for the edit profil but i can't find the way to do same, admin theme for user admin and site theme for simple user.

edit: i have a way with AdminsNegociator service i check that

0

What you are looking for is the _admin_route option.

For example:

entity.annonce_entity.collection:
  path: '/annonce/liste'
  defaults:
    _entity_list: 'annonce_entity'
    _title: 'Liste des annonces'
  requirements:
    _user_is_logged_in: 'TRUE'
  options:
    _admin_route: TRUE

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.