diff --git a/config/sync/core.entity_view_display.node.offre.default.yml b/config/sync/core.entity_view_display.node.offre.default.yml index fd471fa..ee43c3a 100644 --- a/config/sync/core.entity_view_display.node.offre.default.yml +++ b/config/sync/core.entity_view_display.node.offre.default.yml @@ -71,7 +71,7 @@ content: type: entity_reference_label label: above settings: - link: true + link: false third_party_settings: { } weight: 1 region: content diff --git a/config/sync/core.entity_view_display.node.offre.teaser.yml b/config/sync/core.entity_view_display.node.offre.teaser.yml index d3d651e..f421873 100644 --- a/config/sync/core.entity_view_display.node.offre.teaser.yml +++ b/config/sync/core.entity_view_display.node.offre.teaser.yml @@ -25,7 +25,7 @@ content: type: image label: visually_hidden settings: - image_link: '' + image_link: content image_style: large image_loading: attribute: lazy @@ -43,7 +43,7 @@ content: type: entity_reference_label label: above settings: - link: true + link: false third_party_settings: { } weight: 1 region: content diff --git a/web/modules/custom/loginregisterblock/src/Plugin/Block/LoginRegisterBlock.php b/web/modules/custom/loginregisterblock/src/Plugin/Block/LoginRegisterBlock.php index 82b5fe7..0f402eb 100644 --- a/web/modules/custom/loginregisterblock/src/Plugin/Block/LoginRegisterBlock.php +++ b/web/modules/custom/loginregisterblock/src/Plugin/Block/LoginRegisterBlock.php @@ -3,6 +3,8 @@ namespace Drupal\loginregisterblock\Plugin\Block; use Drupal\Core\Block\BlockBase; +use Symfony\Component\HttpFoundation\RedirectResponse; +// use RedirectDestinationTrait; /** * Provides a 'login register' Block. @@ -19,23 +21,28 @@ class LoginRegisterBlock extends BlockBase { * {@inheritdoc} */ public function build() { - $loginform = \Drupal::formBuilder()->getForm('Drupal\user\Form\UserLoginForm'); - $newuser = \Drupal::entityTypeManager()->getStorage('user')->create(); - $registerform = \Drupal::service('entity.form_builder')->getForm($newuser, 'register'); - - return [ - 'login' => [ - '#markup' => '

' . $this->t('Se connecter') . '

', - 'form' => $loginform, - ], - 'register' => [ - '#markup' => '

' . $this->t('ou créer un nouveau compte') . '

', - 'form' => $registerform - ] - ]; - // return [ - // '#markup' => $this->t('Hello, World!'), - // ]; + + $user = \Drupal::currentUser(); + if ($user->id() === 0) { + $loginform = \Drupal::formBuilder()->getForm('Drupal\user\Form\UserLoginForm'); + $newuser = \Drupal::entityTypeManager()->getStorage('user')->create(); + $registerform = \Drupal::service('entity.form_builder')->getForm($newuser, 'register'); + + return [ + 'login' => [ + '#markup' => '

' . $this->t('Se connecter') . '

', + 'form' => $loginform, + ], + 'register' => [ + '#markup' => '

' . $this->t('ou créer un nouveau compte') . '

', + 'form' => $registerform + ] + ]; + } else { + $destination = \Drupal::service('redirect.destination')->getAsArray(); + $response = new RedirectResponse($destination['destination']); + $response->send(); + } }