Controller since 11.5

03. Mai 2022TYPO3 11

Convert to ResponseInterface now, see 
https://docs.typo3.org/m/typo3/book-extbasefluid/main/en-us/7-Controllers/1-Creating-Controllers-and-Actions.html
https://usetypo3.com/extbase-in-typo3-v10-and-v11.html

 

Example without caching

<?php
/**
* @return ResponseInterface
*/
public function listAction(): ResponseInterface
{
  $records = $this->yourRepository->findAll();
  $this->view->assign('records', $records);
  return $this->htmlResponse();
}

Example with custom caching

<?php
/**
* @return ResponseInterface
*/
public function listAction(): ResponseInterface
{
	$cObjData = $this->configurationManager->getContentObject();

	$cachekey = 'record-list-' . $cObjData->data['pid'];
    $output = $this->cachingFramework->get($cachekey);

	if (!$output) {
    	$records = $this->yourRepository->findAll();
     	$this->view->assign('records', $records);
     	$output = $this->htmlResponse();
		$this->cachingFramework->set($cachekey, $output, ['records'], 300);
	}

	return $output;
}