Guest User

Untitled

a guest
Nov 15th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. class SsoSessionBlock extends BlockBase {
  2. /**
  3. * {@inheritdoc}
  4. */
  5. public function build(){
  6. $value = 'dav';
  7. $session = Drupal::service('user.private_tempstore')->get('achva_sso');
  8. $session->set('name', $value);
  9.  
  10.  
  11. return [
  12. '#type' => 'markup',
  13. '#markup' => $this->t('The output of super SsoSessionBlock block.'),
  14. ];
  15. }
  16. }
  17.  
  18. <?php
  19.  
  20. namespace Drupalachva_ssoController;
  21.  
  22. use DrupalCoreControllerControllerBase;
  23. use DrupalCoreRoutingTrustedRedirectResponse;
  24. use Drupaluser;
  25.  
  26.  
  27. class SsoController extends ControllerBase{
  28. public function ssoLogout(){
  29.  
  30. $session = Drupal::service('user.private_tempstore')->get('achva_sso');
  31. PrivateTempStore::delete('name');
  32.  
  33. if(isset($session)){
  34. $status = $session .' is logged in';
  35. }else{
  36. $status = 'is logged out';
  37. }
  38. return[
  39. '#type' => 'markup',
  40. '#markup' => '<p>' . $status . '</p>' ,
  41. ];
  42.  
  43.  
  44.  
  45. }
  46. }
Add Comment
Please, Sign In to add comment