Skip to content
This repository was archived by the owner on Jul 13, 2021. It is now read-only.

Latest commit

 

History

History
26 lines (18 loc) · 2.05 KB

File metadata and controls

26 lines (18 loc) · 2.05 KB

Use TYPO3 REST for your Extbase API

As described in the Tutorial, the TYPO3 rest extension can be used as a boilerplate for your own Web Services. If you have a extbase Plugin you want to use, it can be called easily through a custom handler. To make things more convenient, a small helper function in your Handler is useful:

protected function callExtbasePlugin($pluginName, $vendorName, $extensionName, $controllerName, $actionName, $arguments) { ... }

File: Handler.php

Before using this function, some things have to be mentioned:

  • Every plugin has to be configured in ext_localconf.php using ExtensionUtility::configurePlugin of TYPO3 Core API
  • Since the request and the sent data does not come from a fluid form, your controller should take care of the property mapping and type converting of the arguments. (non-scalar argument variables)
  • Extbase's bootstrap accepts only a string as return value, the json rendering of the output has to be done in your controller (you may want to have a look at JsonView class of extbase or this Tutorial )

Example

Lets say we want to create specific domain objects with a custom validation using a web service api.

Things needed:

  • a Controller with the specific action method
  • the (custom) validator for your model (if extbase finds a validator named \YourVendor\YourExt\Domain\Validator\YourModelValidator, it will validate against it, otherwise the validator has to be configured explicitely with a '@validate' annotation (see Validating Domain Objects)
  • configure you plugin in the ext_localconf.php File
  • call it in your custom Handler

This fork has the proper adjustments to show how to do it. (untested)