src/EventListener/IntercomListener.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use Pimcore\Event\Model\ElementEventInterface;
  4. use Pimcore\Bundle\AdminBundle\Event\IndexActionSettingsEvent;
  5. use Pimcore\Tool\Admin;
  6. class IntercomListener {
  7.     private $intercomSecret;
  8.     public function __construct(string $intercomSecret) {
  9.         $this->intercomSecret $intercomSecret;
  10.     }
  11.     public function onIndexActionSettings (IndexActionSettingsEvent $e) {
  12.     $userHash '';    
  13.     $currentUser Admin::getCurrentUser();
  14.     if($currentUser) {
  15.         $userHash hash_hmac(
  16.               'sha256'// hash function
  17.               $currentUser->getEmail(), // user's email address
  18.               $this->intercomSecret // web secret key (keep safe!)
  19.         );
  20.     }
  21.     $e->addSetting('intercomUserHash'$userHash);
  22.     }
  23. }