/**
  * @param string $action
  * @param array $arguments
  * @param string $controller
  * @param string $extensionName
  * @param string $pluginName
  * @param string $format
  * @param int $pageUid
  * 
  * @return string
  */
 public function render($action = NULL, array $arguments = array(), $controller = NULL, $extensionName = NULL, $pluginName = NULL, $format = '', $pageUid = 0)
 {
     $request = $this->mvcDispatcher->getCurrentRequest();
     if ($request) {
         if ($action === NULL) {
             $action = $request->getControllerActionName();
         }
         if ($controller === NULL) {
             $controller = $request->getControllerName();
         }
         if ($extensionName === NULL) {
             $extensionName = $request->getControllerExtensionName();
         }
         if ($pluginName === NULL && TYPO3_MODE === 'FE') {
             $pluginName = $this->extensionService->getPluginNameByAction($extensionName, $controller, $action);
         }
         if ($pluginName === NULL) {
             $pluginName = $request->getPluginName();
         }
     }
     $additionalArguments = array();
     $this->hA('r[0][arguments]', $arguments, $additionalArguments);
     $language = intval($GLOBALS['TSFE'] ? $GLOBALS['TSFE']->sys_language_content : 0);
     $additionalParams = "&r[0][extension]={$extensionName}&r[0][plugin]={$pluginName}&r[0][controller]={$controller}&r[0][action]={$action}&r[0][format]={$format}&eID=extbase_hijax_dispatcher&L={$language}";
     if ($additionalArguments) {
         $additionalParams .= '&' . implode('&', $additionalArguments);
     }
     /* @var $cObj \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer */
     $cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
     return $cObj->typoLink('', array('returnLast' => 'url', 'additionalParams' => $additionalParams, 'parameter' => $pageUid ? $pageUid : ($GLOBALS['TSFE'] ? $GLOBALS['TSFE']->id : 0)));
 }
 /**
  * @param string $action
  * @param array $arguments
  * @param string $controller
  * @param string $extensionName
  * @param string $pluginName
  * @param string $format
  * @param int $pageUid
  * @param boolean $cachedAjaxIfPossible TRUE if the URI should be cached (with respect to non-cacheable actions)
  * @param boolean $forceContext TRUE if the controller/action/... should be passed
  * @param boolean $noAjax
  *
  * @return string
  */
 public function render($action = NULL, array $arguments = array(), $controller = NULL, $extensionName = NULL, $pluginName = NULL, $format = '', $pageUid = NULL, $cachedAjaxIfPossible = TRUE, $forceContext = TRUE, $noAjax = FALSE)
 {
     $request = $this->mvcDispatcher->getCurrentRequest();
     if ($forceContext) {
         $requestArguments = $this->controllerContext->getRequest()->getArguments();
         $requestArguments = array_merge($requestArguments, $this->hijaxEventDispatcher->getContextArguments());
         $requestArguments = array_merge($requestArguments, $arguments);
         $arguments = $requestArguments;
     }
     if ($noAjax) {
         return parent::render($action, $arguments, $controller, $extensionName, $pluginName, $pageUid);
     } else {
         /* @var $listener \EssentialDots\ExtbaseHijax\Event\Listener */
         $listener = $this->mvcDispatcher->getCurrentListener();
         if ($request) {
             if ($action === NULL) {
                 $action = $request->getControllerActionName();
             }
             if ($controller === NULL) {
                 $controller = $request->getControllerName();
             }
             if ($extensionName === NULL) {
                 $extensionName = $request->getControllerExtensionName();
             }
             if ($pluginName === NULL && TYPO3_MODE === 'FE') {
                 $pluginName = $this->extensionService->getPluginNameByAction($extensionName, $controller, $action);
             }
             if ($pluginName === NULL) {
                 $pluginName = $request->getPluginName();
             }
             $cachedAjaxIfPossible = $cachedAjaxIfPossible ? $this->configurationManager->getContentObject()->getUserObjectType() != ContentObjectRenderer::OBJECTTYPE_USER_INT : false;
             if ($cachedAjaxIfPossible) {
                 /* @var $cacheHash \TYPO3\CMS\Frontend\Page\CacheHashCalculator */
                 $cacheHash = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\CacheHashCalculator');
                 $chash = $cacheHash->calculateCacheHash(array('encryptionKey' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], 'action' => $action, 'controller' => $controller, 'extension' => $extensionName, 'plugin' => $pluginName, 'arguments' => $this->array_map_recursive('strval', $arguments), 'settingsHash' => $listener->getId()));
             }
         }
         $additionalArguments = array();
         $this->hA('r[0][arguments]', $arguments, $additionalArguments);
         $language = intval($GLOBALS['TSFE'] ? $GLOBALS['TSFE']->sys_language_content : 0);
         $additionalParams = "&r[0][extension]={$extensionName}&r[0][plugin]={$pluginName}&r[0][controller]={$controller}&r[0][action]={$action}&r[0][format]={$format}&r[0][settingsHash]={$listener->getId()}&eID=extbase_hijax_dispatcher&L={$language}";
         if ($additionalArguments) {
             $additionalParams .= '&' . implode('&', $additionalArguments);
         }
         if ($chash) {
             $additionalParams .= '&r[0][chash]=' . $chash;
         }
         /* @var $cObj \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer */
         $cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
         $uri = $cObj->typoLink('', array('returnLast' => 'url', 'additionalParams' => $additionalParams, 'parameter' => $pageUid ? $pageUid : ($GLOBALS['TSFE'] ? $GLOBALS['TSFE']->id : 0)));
         $this->tag->addAttribute('href', $uri);
         $this->tag->setContent($this->renderChildren());
         $this->tag->forceClosingTag(TRUE);
         return $this->tag->render();
     }
 }
 /**
  * Returns JS callback for the given action
  *
  * @param null $action
  * @param array $arguments
  * @param null $controller
  * @param null $extensionName
  * @param null $pluginName
  * @param string $format
  * @param string $section
  * @return string
  */
 public function getAjaxFunction($action = NULL, array $arguments = array(), $controller = NULL, $extensionName = NULL, $pluginName = NULL, $format = '', $section = 'footer')
 {
     // current element needs to have additional logic...
     $this->hijaxEventDispatcher->setIsHijaxElement(true);
     $request = $this->mvcDispatcher->getCurrentRequest();
     if ($request) {
         if ($action === NULL) {
             $action = $request->getControllerActionName();
         }
         if ($controller === NULL) {
             $controller = $request->getControllerName();
         }
         if ($extensionName === NULL) {
             $extensionName = $request->getControllerExtensionName();
         }
         if ($pluginName === NULL && TYPO3_MODE === 'FE') {
             $pluginName = $this->extensionService->getPluginNameByAction($extensionName, $controller, $action);
         }
         if ($pluginName === NULL) {
             $pluginName = $request->getPluginName();
         }
     }
     $settings = array('extension' => $extensionName, 'plugin' => $pluginName, 'controller' => $controller, 'format' => $format ? $format : 'html', 'action' => $action, 'arguments' => $arguments, 'settingsHash' => $this->mvcDispatcher->getCurrentListener() ? $this->mvcDispatcher->getCurrentListener()->getId() : '', 'namespace' => $extensionName && $pluginName ? $this->extensionService->getPluginNamespace($extensionName, $pluginName) : '');
     $functionName = 'extbaseHijax_' . md5(serialize($settings));
     $content = "; {$functionName}=function(settings, pendingElement, loaders) {";
     foreach ($settings as $k => $v) {
         $content .= "if (typeof settings.{$k} == 'undefined') settings.{$k}=" . json_encode($v) . ";";
     }
     $content .= "return jQuery.hijax(settings, pendingElement, loaders);};";
     if ($this->isCached()) {
         if ($section == 'footer') {
             $this->pageRenderer->addJsFooterInlineCode(md5($content), $content, FALSE, TRUE);
         } else {
             $this->pageRenderer->addJsInlineCode(md5($content), $content, FALSE, TRUE);
         }
     } else {
         // additionalFooterData not possible in USER_INT
         $GLOBALS['TSFE']->additionalHeaderData[md5($content)] = \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS($content);
     }
     return $functionName;
 }