/**
  * Constructs a new \EssentialDots\ExtbaseHijax\Event\Listener.
  *
  * @param \TYPO3\CMS\Extbase\Mvc\RequestInterface		$request		The request
  * @param array 								$configuration 	Framework configuraiton
  * @param \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer	 						$cObj	 	An array of parameters
  */
 public function __construct(\TYPO3\CMS\Extbase\Mvc\RequestInterface $request, $configuration = null, $cObj = null)
 {
     $this->injectObjectManager(\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'));
     $this->injectConfigurationManager($this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface'));
     $this->injectAutoIDService($this->objectManager->get('EssentialDots\\ExtbaseHijax\\Service\\AutoIDService'));
     $this->request = $request;
     if (method_exists($this->request, 'setMethod')) {
         $this->request->setMethod('GET');
     }
     if ($configuration) {
         $this->configuration = $this->ksortRecursive($configuration);
     } else {
         $this->configuration = $this->ksortRecursive($this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK));
     }
     if ($cObj) {
         $this->cObj = $cObj;
     } else {
         $this->cObj = $this->configurationManager->getContentObject();
     }
     /* @var $listenerFactory \EssentialDots\ExtbaseHijax\Service\Serialization\ListenerFactory */
     $listenerFactory = $this->objectManager->get('EssentialDots\\ExtbaseHijax\\Service\\Serialization\\ListenerFactory');
     // old logic - using autoincrement
     //$this->id = $this->autoIDService->getAutoId(get_class($this));
     // new logic - determine the id based on md5 hash
     $this->id = '';
     // resetting the id so it doesn't affect the hash
     $serialized = $listenerFactory->serialize($this);
     list($table, $uid) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(':', $this->cObj->currentRecord);
     if ($table == 'tt_content' && $uid) {
         $this->id = str_replace(':', '-', $this->cObj->currentRecord) . '-' . md5($serialized);
     } else {
         // test if this is ExtbaseHijax Pi1
         if (method_exists($this->request, 'getControllerExtensionName') && method_exists($this->request, 'getPluginName') && $this->request->getControllerExtensionName() == 'ExtbaseHijax' && $this->request->getPluginName() == 'Pi1') {
             $encodedSettings = str_replace('.', '---', $this->configuration['settings']['loadContentFromTypoScript']);
             $settingsHash = \TYPO3\CMS\Core\Utility\GeneralUtility::hmac($encodedSettings);
             if ($this->configuration['switchableControllerActions']['ContentElement'][0] == 'user') {
                 $this->id = 'h-' . $settingsHash . '-' . $encodedSettings;
             } else {
                 $this->id = 'hInt-' . $settingsHash . '-' . $encodedSettings;
             }
         } elseif ($this->configuration['settings']['fallbackTypoScriptConfiguration']) {
             $encodedSettings = str_replace('.', '---', $this->configuration['settings']['fallbackTypoScriptConfiguration']);
             $settingsHash = \TYPO3\CMS\Core\Utility\GeneralUtility::hmac($encodedSettings);
             $this->id = 'f-' . $settingsHash . '-' . $encodedSettings;
         } else {
             $this->id = md5($serialized);
         }
     }
 }