<?php
namespace App\EventListener;
use Pimcore\Event\Model\ElementEventInterface;
use Pimcore\Bundle\AdminBundle\Event\IndexActionSettingsEvent;
use Pimcore\Tool\Admin;
class IntercomListener {
private $intercomSecret;
public function __construct(string $intercomSecret) {
$this->intercomSecret = $intercomSecret;
}
public function onIndexActionSettings (IndexActionSettingsEvent $e) {
$userHash = '';
$currentUser = Admin::getCurrentUser();
if($currentUser) {
$userHash = hash_hmac(
'sha256', // hash function
$currentUser->getEmail(), // user's email address
$this->intercomSecret // web secret key (keep safe!)
);
}
$e->addSetting('intercomUserHash', $userHash);
}
}