Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 20 additions & 63 deletions Classes/Hooks/ItemsProcFunc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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'][] = [
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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
);
}
}
3 changes: 3 additions & 0 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Documentation/guides.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
interlink-shortcode="extcode/cart"
/>
<project title="Cart"
release="11.1.0"
version="11.1"
release="11.2.0"
version="11.2"
copyright="2018 - 2025"
/>
<inventory id="t3tsref" url="https://docs.typo3.org/typo3cms/TyposcriptReference/"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down