Skip to content

Commit 4419224

Browse files
committed
[FEATURE] Add new "requestOptions" parameter, resolves #14
1 parent 74a8a67 commit 4419224

File tree

7 files changed

+81
-5
lines changed

7 files changed

+81
-5
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2026-03-13 Francois Suter (Idéative) <typo3@ideative.ch>
2+
3+
* Add new "requestOptions" parameter, resolves #14
4+
15
2026-02-02 Francois Suter (Idéative) <typo3@ideative.ch>
26

37
* Ensure compatibility with TYPO3 14 and PHP 8.5, resolves #13

Classes/Service/ConnectorFeed.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ public function checkConfiguration(): array
6161
'LLL:EXT:svconnector_feed/Resources/Private/Language/locallang.xlf:no_feed_defined'
6262
);
6363
}
64+
// The "requestOptions" parameter is expected to be an array
65+
if (isset($this->parameters['requestOptions']) && !is_array($this->parameters['requestOptions'])) {
66+
$result[ContextualFeedbackSeverity::WARNING->value][] = $this->sL(
67+
'LLL:EXT:svconnector_feed/Resources/Private/Language/locallang.xlf:request_options_must_be_array'
68+
);
69+
}
6470
return $result;
6571
}
6672

@@ -142,12 +148,26 @@ protected function query(): mixed
142148
);
143149
}
144150

145-
$headers = $this->parameters['headers'] ?? [];
151+
// Define the request options
152+
$requestOptions = $this->parameters['requestOptions'] ?? [];
153+
// Include deprecated headers property
154+
// TODO: remove in next major version
155+
if (is_array($this->parameters['headers'] ?? null) && count($this->parameters['headers']) > 0) {
156+
$requestOptions = array_merge_recursive($requestOptions, ['headers' => $this->parameters['headers']]);
157+
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
158+
$caller = end($backtrace);
159+
$callerLocation = sprintf('file %s, line %d', $caller['file'], $caller['line']);
160+
161+
trigger_error(sprintf(
162+
'Property "headers" is deprecated. Pass headers as part of the "requestOptions" property instead. Location: %s',
163+
$callerLocation,
164+
), E_USER_DEPRECATED);
165+
}
146166
$fileUtility = GeneralUtility::makeInstance(FileUtility::class);
147167
$data = $fileUtility->getFileContent(
148168
$this->parameters['uri'],
149-
count($headers) > 0 ? $headers : null,
150-
$this->parameters['method'] ?? 'GET'
169+
$this->parameters['method'] ?? 'GET',
170+
$requestOptions
151171
);
152172
if ($data === false) {
153173
$message = sprintf(

Documentation/Configuration/Index.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,36 @@ Description
4646
This parameter is optional and the method defaults to GET.
4747

4848

49+
.. _configuration-request-options:
50+
51+
requestOptions
52+
^^^^^^^^^^^^^^
53+
54+
Type
55+
array
56+
57+
Description
58+
Key-value pairs of options that can be passed to the request. Any of the
59+
`request options supported by Guzzle HTTP <https://docs.guzzlephp.org/en/stable/request-options.html>`_
60+
may be used.
61+
62+
.. note::
63+
64+
This makes sense only when using fully qualified URLs in the :ref:`uir parameter <configuration-uri>`.
65+
66+
Example
67+
Passing a "page" information in the body and setting an accepted mime type in the headers.
68+
69+
.. code-block:: php
70+
71+
'requestOptions' => [
72+
'body' => '{"page": 1}',
73+
'headers' => [
74+
'Accept' => 'application/xml',
75+
],
76+
],
77+
78+
4979
.. _configuration-headers:
5080

5181
headers
@@ -57,6 +87,11 @@ Type
5787
Description
5888
Key-value pairs of headers that should be sent along with the request.
5989

90+
.. warning::
91+
92+
This parameter has been deprecated. It will be removed in the next major version.
93+
Use :ref:`requestOptions <configuration-request-options>` instead.
94+
6095
Example
6196
Example headers for setting an alternate user agent and defining what reponse
6297
format to accept.

Documentation/Index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Feed/XML Connector Service
2727
xml, rss, feed, data import, fetch data
2828

2929
:Copyright:
30-
2009-2025
30+
2009-2026
3131

3232
:Author:
3333
François Suter (Idéative)

Documentation/Installation/Index.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ XML files inside your own code. It requires extension “svconnector”
1616
which provides the base for all connector services.
1717

1818

19+
.. _installation-update-600:
20+
21+
Updating to 6.0.0
22+
^^^^^^^^^^^^^^^^^
23+
24+
Version 6.0.0 adds support for TYPO3 13 and PHP 8.5, while dropping support
25+
for TYPO3 12 and PHP 8.1.
26+
27+
A new parameter :ref:`requestOptions <configuration-request-options>` is available.
28+
It makes it possible to use any of the request options supported by Guzzle HTTP.
29+
The "headers" parameter has been deprecated. Headers should be passed as part of the
30+
"requestOptions" instead.
31+
32+
1933
.. _installation-update-500:
2034

2135
Updating to 5.0.0

Documentation/guides.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<project
1414
title="XML/RSS feed Connector Service"
1515
release="5.0.0"
16-
copyright="2009-2025"
16+
copyright="2009-2026"
1717
/>
1818
<inventory id="svconnector" url="https://docs.typo3.org/p/cobweb/svconnector/main/en-us/"/>
1919
</guides>

Resources/Private/Language/locallang.xlf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
<trans-unit id="feed_not_fetched" xml:space="preserve">
1010
<source>XML file %1$s could not be fetched with error: %2$s</source>
1111
</trans-unit>
12+
<trans-unit id="request_options_must_be_array" xml:space="preserve">
13+
<source>The "requestOptions" parameter must be an array. It will be ignored.</source>
14+
</trans-unit>
1215
</body>
1316
</file>
1417
</xliff>

0 commit comments

Comments
 (0)