Controller¶
Defines the Extbase Action, that must be executed when request is triggered.
1 2 3 4 5 | demo_photos-all:
path: api/demo/photos
controller: LMS\Demo\Controller\PhotoApiController::all
defaults:
plugin: PhotoApi
|
Tip
Required: Yes
<?php
declare(strict_types = 1);
namespace LMS\Demo\Controller;
use LMS\Demo\Repository\PhotoRepository;
class PhotoApiController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
/**
* @return string
*/
public function allAction(): string
{
$photos = PhotoRepository::make()->findAll()->toArray();
return json_encode($photos);
}
}
Warning
Corresponding plugin should be configured in ext_localconf.php
Example request¶
curl --location --request GET 'https://demo.ddev.site/api/demo/photos' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json'