Configuration
This chapter describes the parameters that can be used to configure the JSON connector service.
uri
- Type
- string
- Description
-
URI of the JSON resource to read. This may be any of the following syntaxes:
- absolute file path:
/var/
(within the TYPO3 root path orfoo/ web/ fileadmin/ import/ bar. json TYPO3_
)CONF_ VARS [BE] [lock Root Path] - file path relative to the TYPO3 root:
fileadmin/
import/ foo. json - file path using
EXT:
:EXT:
foo/ Resources/ Private/ Data/ bar. json - fully qualified URL, e.g.
http://
www. example. com/ foo. json - FAL reference with storage ID and file identifier:
FAL:
2:/ foo. json - custom syntax:
MYKEY:
, see Connector Serviceswhatever_ you_ want
- absolute file path:
encoding
- Type
- string
- Description
- Encoding of the data found in the file. This value must match any of the encoding values recognized by the PHP libray "mbstring". See https://www.php.net/manual/en/mbstring.supported-encodings.php
headers
- Type
- array
- Description
- Key-value pairs of headers that should be sent along with the request.
- Example
-
Example headers for setting an alternate user agent and defining what reponse format to accept.
'headers' => [ 'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:75.0) Gecko/20100101 Firefox/75.0', 'Accept' => 'application/json', ]
Copied!
method
- Type
- string
- Description
- Method to use for querying the external data source. Optional, defaults to
GET
.
queryParameters
- Type
- array
- Description
- Key-value pairs of query parameters that should be added to the URI. This will only when the URI is a fully qualified URL and not in any of the other possibilities described above.
- Example
-
Assuming that the
uri
parameter is "https://example.com", with the following quey parameters:'queryParameters' => [ 'foo' => 'bar', ]
Copied!the full URI to be queried will be "https://example.com?foo=bar".
paginator
- Type
- string
- Description
-
Many APIs present results that are paginated. Since these pagination mechanisms can be quite diverse, this extension cannot provide a solution that fits all situations.
Out of the box, the JSON-Hydra pagination format is supported, with the use of the "hydra" keyword.
For any other pagination mechanism, you will need to develop your own Paginator class.
The results are aggregated as if all data had been fetched in a single call.
Important
This works only with
fetch
andArray () fetch
. SinceXMLl () fetch
returns the original JSON data as a string, it only ever returns the result of the first page.Raw Warning
If you use pagination, you need to pass any other quey parameter from the
uri
with thequery
and not have them directly in theParameters uri
. - Example
-
To enable pagination for a Hydra data source:
'paginator' => 'hydra'
Copied!To enable pagination for another type of data source with a custom Paginator:
'paginator' => \MyVendorName\MyExtension\Paginator\FooPaginator::class
Copied!