diff --git a/Classes/Hooks/ItemsProcFunc.php b/Classes/Hooks/ItemsProcFunc.php
index 49b4a663..17b470cb 100644
--- a/Classes/Hooks/ItemsProcFunc.php
+++ b/Classes/Hooks/ItemsProcFunc.php
@@ -9,25 +9,22 @@
* LICENSE file that was distributed with this source code.
*/
use Extcode\Cart\Utility\TemplateLayout;
-use Psr\Log\LoggerAwareInterface;
use TYPO3\CMS\Backend\Utility\BackendUtility as BackendUtilityCore;
-use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Localization\LanguageService;
-use TYPO3\CMS\Core\Resource\ResourceFactory;
-use TYPO3\CMS\Core\Resource\StorageRepository;
-use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Form\Mvc\Configuration\ConfigurationManager;
-use TYPO3\CMS\Form\Mvc\Configuration\YamlSource;
-use TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManager;
-use TYPO3\CMS\Form\Slot\FilePersistenceSlot;
+use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
+use TYPO3\CMS\Form\Mvc\Configuration\ConfigurationManagerInterface as ExtFormConfigurationManagerInterface;
+use TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManagerInterface;
class ItemsProcFunc
{
protected TemplateLayout $templateLayoutsUtility;
- public function __construct()
- {
+ public function __construct(
+ private readonly FormPersistenceManagerInterface $formPersistenceManager,
+ private readonly ConfigurationManagerInterface $configurationManager,
+ private readonly ExtFormConfigurationManagerInterface $extFormConfigurationManager,
+ ) {
$this->templateLayoutsUtility = GeneralUtility::makeInstance(TemplateLayout::class);
}
@@ -68,11 +65,11 @@ public function user_formDefinition(array &$config): void
$prototypeName = $config['config']['itemsProcFuncConfig']['prototypeName'];
}
- $formPersistenceManager = $this->getFormPersistenceManager();
- $availableForms = $formPersistenceManager->listForms();
+ $formSettings = $this->getFormSettings();
+ $availableForms = $this->formPersistenceManager->listForms($formSettings);
foreach ($availableForms as $availableForm) {
- $form = $formPersistenceManager->load($availableForm['persistenceIdentifier']);
+ $form = $this->formPersistenceManager->load($availableForm['persistenceIdentifier'], $formSettings, []);
if ($form['prototypeName'] === $prototypeName) {
$config['items'][] = [
@@ -83,15 +80,16 @@ public function user_formDefinition(array &$config): void
}
}
- protected function getExtKey($listType)
+ private function getFormSettings(): array
{
- [$ext, $plugin] = explode('_', (string)$listType, 2);
-
- if (str_starts_with($ext, 'cart')) {
- return 'cart_' . substr($ext, 4);
+ $typoScriptSettings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'form');
+ $formSettings = $this->extFormConfigurationManager->getYamlConfiguration($typoScriptSettings, false);
+ if (!isset($formSettings['formManager'])) {
+ // Config sub array formManager is crucial and should always exist. If it does
+ // not, this indicates an issue in config loading logic. Except in this case.
+ throw new \LogicException('Configuration could not be loaded', 1723717461);
}
-
- return $ext;
+ return $formSettings;
}
/**
@@ -138,49 +136,8 @@ protected function getPageId(int $pid): int
return $row['pid'];
}
- /**
- * Returns LanguageService
- *
- * @return LanguageService
- */
- protected function getLanguageService()
+ protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
-
- /**
- * @return object|LoggerAwareInterface|SingletonInterface
- */
- protected function getFormPersistenceManager()
- {
- $resourceFactory = GeneralUtility::makeInstance(
- ResourceFactory::class
- );
- $storageRepository = GeneralUtility::makeInstance(
- StorageRepository::class
- );
- $yamlSource = GeneralUtility::makeInstance(
- YamlSource::class
- );
-
- $filePersistenceSlot = GeneralUtility::makeInstance(
- FilePersistenceSlot::class
- );
- $configurationManager = GeneralUtility::makeInstance(
- ConfigurationManager::class
- );
- $cacheManager = GeneralUtility::makeInstance(
- CacheManager::class
- );
-
- return GeneralUtility::makeInstance(
- FormPersistenceManager::class,
- $yamlSource,
- $storageRepository,
- $filePersistenceSlot,
- $resourceFactory,
- $configurationManager,
- $cacheManager
- );
- }
}
diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml
index ea2e7ae5..70499fed 100644
--- a/Configuration/Services.yaml
+++ b/Configuration/Services.yaml
@@ -136,6 +136,9 @@ services:
identifier: 'cart--order--update--log-service-update'
event: Extcode\Cart\Event\Order\UpdateServiceEvent
+ Extcode\Cart\Hooks\ItemsProcFunc:
+ public: true
+
Extcode\Cart\Service\CurrencyTranslationServiceInterface:
alias: Extcode\Cart\Service\CurrencyTranslationService
public: true
diff --git a/Documentation/guides.xml b/Documentation/guides.xml
index 0d1fc770..800de69f 100644
--- a/Documentation/guides.xml
+++ b/Documentation/guides.xml
@@ -11,8 +11,8 @@
interlink-shortcode="extcode/cart"
/>
diff --git a/Tests/Functional/EventListener/Mail/AttachmentFromOrderItemTest.php b/Tests/Functional/EventListener/Mail/AttachmentFromOrderItemTest.php
index 38217d48..90912145 100644
--- a/Tests/Functional/EventListener/Mail/AttachmentFromOrderItemTest.php
+++ b/Tests/Functional/EventListener/Mail/AttachmentFromOrderItemTest.php
@@ -22,13 +22,13 @@ class AttachmentFromOrderItemTest extends FunctionalTestCase
{
use TestingFramework;
- protected array $testExtensionsToLoad = [
- 'extcode/cart',
- 'typo3conf/ext/cart/Tests/Fixtures/cart_example',
- ];
-
public function setUp(): void
{
+ $this->coreExtensionsToLoad[] = 'typo3/cms-form';
+
+ $this->testExtensionsToLoad[] = 'extcode/cart';
+ $this->testExtensionsToLoad[] = 'typo3conf/ext/cart/Tests/Fixtures/cart_example';
+
parent::setUp();
$GLOBALS['TYPO3_REQUEST'] = (new ServerRequest())
diff --git a/Tests/Functional/EventListener/Mail/AttachmentFromTypoScriptTest.php b/Tests/Functional/EventListener/Mail/AttachmentFromTypoScriptTest.php
index e4f09c49..af29eee2 100644
--- a/Tests/Functional/EventListener/Mail/AttachmentFromTypoScriptTest.php
+++ b/Tests/Functional/EventListener/Mail/AttachmentFromTypoScriptTest.php
@@ -24,13 +24,13 @@ class AttachmentFromTypoScriptTest extends FunctionalTestCase
{
use TestingFramework;
- protected array $testExtensionsToLoad = [
- 'extcode/cart',
- 'typo3conf/ext/cart/Tests/Fixtures/cart_example',
- ];
-
public function setUp(): void
{
+ $this->coreExtensionsToLoad[] = 'typo3/cms-form';
+
+ $this->testExtensionsToLoad[] = 'extcode/cart';
+ $this->testExtensionsToLoad[] = 'typo3conf/ext/cart/Tests/Fixtures/cart_example';
+
parent::setUp();
$GLOBALS['TYPO3_REQUEST'] = (new ServerRequest())
diff --git a/ext_emconf.php b/ext_emconf.php
index 6a89ba44..b0be0674 100644
--- a/ext_emconf.php
+++ b/ext_emconf.php
@@ -4,7 +4,7 @@
'title' => 'Cart',
'description' => 'Shopping Cart(s) for TYPO3',
'category' => 'plugin',
- 'version' => '11.1.0',
+ 'version' => '11.2.0',
'state' => 'stable',
'author' => 'Daniel Gohlke',
'author_email' => 'ext@extco.de',