2 namespace TYPO3\CMS\Core\ExtDirect;
37 if (isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'ExtDirect']) && is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'ExtDirect'])) {
38 $this->settings =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'ExtDirect'];
58 $response->
getBody()->write(json_encode([]));
73 if (!empty($javascriptNamespaces)) {
75 if (!Ext.isObject(Ext.app.ExtDirectAPI)) {
76 Ext.app.ExtDirectAPI = {};
78 Ext.apply(Ext.app.ExtDirectAPI, ' . json_encode($javascriptNamespaces) .
');
82 throw new \InvalidArgumentException($errorMessage, 1297645190);
95 $javascriptNamespaces = array();
96 if (is_array($this->settings)) {
97 foreach ($this->settings as $javascriptName => $configuration) {
98 $splittedJavascriptName = explode(
'.', $javascriptName);
99 $javascriptObjectName = array_pop($splittedJavascriptName);
100 $javascriptNamespace = implode(
'.', $splittedJavascriptName);
102 if (!$this->
findNamespace($javascriptNamespace, $filterNamespaces)) {
105 if (!isset($javascriptNamespaces[$javascriptNamespace])) {
106 $javascriptNamespaces[$javascriptNamespace] = array(
108 'type' =>
'remoting',
109 'actions' => array(),
110 'namespace' => $javascriptNamespace
113 if (is_array($configuration)) {
114 $className = $configuration[
'callbackClass'];
116 $javascriptNamespaces[$javascriptNamespace][
'actions'][$javascriptObjectName] = array();
117 foreach (get_class_methods($serverObject) as $methodName) {
118 $reflectionMethod = new \ReflectionMethod($serverObject, $methodName);
119 $numberOfParameters = $reflectionMethod->getNumberOfParameters();
120 $docHeader = $reflectionMethod->getDocComment();
121 $formHandler = strpos($docHeader,
'@formHandler') !==
false;
122 $javascriptNamespaces[$javascriptNamespace][
'actions'][$javascriptObjectName][] = array(
123 'name' => $methodName,
124 'len' => $numberOfParameters,
125 'formHandler' => $formHandler
131 return $javascriptNamespaces;
142 if (TYPO3_MODE ===
'FE') {
145 $url = BackendUtility::getAjaxUrl(
'ext_direct_route', array(
'namespace' => $namespace));
160 $cacheIdentifier =
'ExtDirectApi';
164 if ($noCache || !is_array(($javascriptNamespaces = \TYPO3\CMS\Frontend\Page\PageRepository::getHash($cacheHash)))) {
165 $javascriptNamespaces = $this->
generateAPI($filterNamespaces);
166 if (!empty($javascriptNamespaces)) {
167 \TYPO3\CMS\Frontend\Page\PageRepository::storeHash($cacheHash, $javascriptNamespaces, $cacheIdentifier);
170 return $javascriptNamespaces;
181 if (!empty($filterNamespaces)) {
183 $errorMessage = sprintf(
$GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:ExtDirect.namespaceError'), __CLASS__, implode(
',', $filterNamespaces));
186 $errorMessage = sprintf(
$GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:ExtDirect.noNamespace'), __CLASS__);
188 return $errorMessage;
200 if ($filterNamespaces === array(
'TYPO3')) {
204 foreach ($filterNamespaces as $filter) {