ext_localconf.php
<?php
defined('TYPO3_MODE') or die();
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin('Trafo2.'.$_EXTKEY, 'JsonList', [ 'Json' =-->'findJsonData' ], [ 'Json' => 'findJsonData' ]);
Controller-Action (JsonController.php)
<?php
/**
* @var \Trafo2\T2Extension\Domain\Repository\JsonDataRepository * @inject
*/
protected $jsonDataRepository;
public function findJsonDataAction(){
$jsonData = $this->jsonDataRepository->findAll()->toArray();
return json_encode($jsonData);
}
TS-Setup
myJson = PAGE
myJson {
typeNum = 112233
config {
additionalHeaders = Content-Type: application/json
additionalHeaders.10.header = Content-Type: application/json
no_cache = 1
disableAllHeaderCode = 1
disablePrefixComment = 1
xhtml_cleaning = 0
admPanel = 0
debug = 0
}
10 = USER_INT
10 {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
pluginName = JsonPlugin
vendorName = Trafo2
extensionName = T2Extension
controller = Json
switchableControllerActions {
Json{
1 = jsonData
}
}
features.requireCHashArgumentForActionArguments = 0
}
}