diff --git a/web/typo3conf/ext/ep_events/Classes/Controller/AjaxFormController.php b/web/typo3conf/ext/ep_events/Classes/Controller/AjaxFormController.php index 69ac50d4..599588ca 100644 --- a/web/typo3conf/ext/ep_events/Classes/Controller/AjaxFormController.php +++ b/web/typo3conf/ext/ep_events/Classes/Controller/AjaxFormController.php @@ -28,6 +28,7 @@ namespace EP\EpEvents\Controller; ***************************************************************/ use EP\EpEvents\Domain\Model\Inquiry; +use EP\EpEvents\Service\ConfigurationService; use EP\EpEvents\Service\EmailService; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; @@ -41,11 +42,16 @@ class AjaxFormController extends ActionController protected $emailService; /** - * @param EmailService $service + * @var ConfigurationService */ - public function injectEmailService(EmailService $service) + protected $configurationService; + + public function __construct(EmailService $emailService, ConfigurationService $configurationService) { - $this->emailService = $service; + parent::__construct(); + + $this->emailService = $emailService; + $this->configurationService = $configurationService; } /** @@ -79,7 +85,10 @@ class AjaxFormController extends ActionController 'toName' => $this->settings['inquiryToName'], 'subject' => 'Anfrage E&P Events', 'templateName' => 'Email/Configurator', - 'variables' => [ 'inquiry' => $inquiry ] + 'variables' => [ + 'inquiry' => $inquiry, + 'config' => $this->configurationService->getConfiguratorConfig(), + ] ]); return json_encode($response); } diff --git a/web/typo3conf/ext/ep_events/Classes/Controller/FormController.php b/web/typo3conf/ext/ep_events/Classes/Controller/FormController.php index ab06a256..94f9301a 100644 --- a/web/typo3conf/ext/ep_events/Classes/Controller/FormController.php +++ b/web/typo3conf/ext/ep_events/Classes/Controller/FormController.php @@ -28,12 +28,27 @@ namespace EP\EpEvents\Controller; ***************************************************************/ use EP\EpEvents\Domain\Model\Inquiry; +use EP\EpEvents\Service\ConfigurationService; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; -use TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility; class FormController extends ActionController { + /** + * @var ConfigurationService + */ + protected $configurationService; + + /** + * @param ConfigurationService $configurationService + */ + public function __construct(ConfigurationService $configurationService) + { + parent::__construct(); + + $this->configurationService = $configurationService; + } + public function inquiryFormAction() { $inquiry = $this->getInquiryFromContext(); @@ -63,7 +78,7 @@ class FormController extends ActionController } else { $inquiry = $this->getInquiryFromContext(); } - $this->view->assign('configuratorConfig', $this->getConfiguratorConfig()); + $this->view->assign('configuratorConfig', $this->configurationService->getConfiguratorConfig()); $this->view->assign('inquiry', $inquiry); } @@ -78,7 +93,7 @@ class FormController extends ActionController $offer = $content['offer']; $inquiry = Inquiry::fromOffer($offer, $defaults); } elseif (isset($content['travelType'])) { - $config = $this->getConfiguratorConfig(); + $config = $this->configurationService->getConfiguratorConfig(); /** @var \EP\EpEvents\Domain\Model\Traveltype $travelType */ $travelType = $content['travelType']; $configuratorType = $travelType->getConfiguratorType(); @@ -113,41 +128,4 @@ class FormController extends ActionController ; } - /** - * @return array - */ - protected function getConfiguratorConfig() - { - /** @var ConfigurationUtility $configUtility */ - $configUtility = $this->objectManager->get(ConfigurationUtility::class); - $extensionConfig = $configUtility->getCurrentConfiguration('ep_events'); - - return [ - 'budgetOptions' => $this->parseConfigItem($extensionConfig, 'configuratorBudgetOptions'), - 'paxOptions' => $this->parseConfigItem($extensionConfig, 'configuratorPaxOptions'), - 'periodOptions' => $this->parseConfigItem($extensionConfig, 'configuratorPeriodOptions'), - 'travelTypeOptions' => $this->parseConfigItem($extensionConfig, 'configuratorTravelTypeOptions'), - 'locationTypeOptions' => $this->parseConfigItem($extensionConfig, 'configuratorLocationTypeOptions'), - 'accommodationTypeOptions' => $this->parseConfigItem($extensionConfig, 'configuratorAccommodationTypeOptions'), - 'programmeTypeOptions' => $this->parseConfigItem($extensionConfig, 'configuratorProgrammeTypeOptions'), - 'distanceOptions' => $this->parseConfigItem($extensionConfig, 'configuratorDistanceOptions'), - ]; - } - - /** - * @param array $configArray - * @param string $itemName - * @return array - */ - protected function parseConfigItem($configArray, $itemName) - { - $config = []; - foreach (explode(';', $configArray[$itemName]['value']) as $item) - { - list ($value, $label) = explode(':', $item); - $config[$value] = $label; - } - - return $config; - } } diff --git a/web/typo3conf/ext/ep_events/Classes/Service/ConfigurationService.php b/web/typo3conf/ext/ep_events/Classes/Service/ConfigurationService.php new file mode 100644 index 00000000..11fb4512 --- /dev/null +++ b/web/typo3conf/ext/ep_events/Classes/Service/ConfigurationService.php @@ -0,0 +1,60 @@ +configurationUtility = $configurationUtility; + } + + /** + * @return array + */ + public function getConfiguratorConfig() + { + $extensionConfig = $this->configurationUtility->getCurrentConfiguration('ep_events'); + + return [ + 'budgetOptions' => $this->parseConfigItem($extensionConfig, 'configuratorBudgetOptions'), + 'paxOptions' => $this->parseConfigItem($extensionConfig, 'configuratorPaxOptions'), + 'periodOptions' => $this->parseConfigItem($extensionConfig, 'configuratorPeriodOptions'), + 'travelTypeOptions' => $this->parseConfigItem($extensionConfig, 'configuratorTravelTypeOptions'), + 'locationTypeOptions' => $this->parseConfigItem($extensionConfig, 'configuratorLocationTypeOptions'), + 'accommodationTypeOptions' => $this->parseConfigItem($extensionConfig, 'configuratorAccommodationTypeOptions'), + 'programmeTypeOptions' => $this->parseConfigItem($extensionConfig, 'configuratorProgrammeTypeOptions'), + 'distanceOptions' => $this->parseConfigItem($extensionConfig, 'configuratorDistanceOptions'), + ]; + } + + /** + * @param array $configArray + * @param string $itemName + * @return array + */ + protected function parseConfigItem($configArray, $itemName) + { + $config = []; + foreach (explode(';', $configArray[$itemName]['value']) as $item) + { + list ($value, $label) = explode(':', $item); + $config[$value] = $label; + } + + return $config; + } + +} diff --git a/web/typo3conf/ext/ep_events/Classes/Service/EmailService.php b/web/typo3conf/ext/ep_events/Classes/Service/EmailService.php index 84a14300..dd925481 100644 --- a/web/typo3conf/ext/ep_events/Classes/Service/EmailService.php +++ b/web/typo3conf/ext/ep_events/Classes/Service/EmailService.php @@ -48,11 +48,11 @@ class EmailService implements SingletonInterface protected $settings; /** - * @param ConfigurationManagerInterface $manager + * @param ConfigurationManagerInterface $configurationManager */ - public function injectConfigurationManager(ConfigurationManagerInterface $manager) + public function __construct(ConfigurationManagerInterface $configurationManager) { - $this->configurationManager = $manager; + $this->configurationManager = $configurationManager; $settings = GeneralUtility::removeDotsFromTS( $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT) ); diff --git a/web/typo3conf/ext/ep_events/Classes/ViewHelpers/ConfiguratorTypeLabelsViewHelper.php b/web/typo3conf/ext/ep_events/Classes/ViewHelpers/ConfiguratorTypeLabelsViewHelper.php index 758b9b4b..077bc263 100644 --- a/web/typo3conf/ext/ep_events/Classes/ViewHelpers/ConfiguratorTypeLabelsViewHelper.php +++ b/web/typo3conf/ext/ep_events/Classes/ViewHelpers/ConfiguratorTypeLabelsViewHelper.php @@ -41,6 +41,7 @@ class ConfiguratorTypeLabelsViewHelper extends AbstractViewHelper parent::initializeArguments(); $this->registerArgument('type', 'string', 'The type', true); + $this->registerArgument('config', 'array', 'The config', true); $this->registerArgument('values', 'string', 'The labels', true); } @@ -61,12 +62,11 @@ class ConfiguratorTypeLabelsViewHelper extends AbstractViewHelper } $types = []; $indexes = GeneralUtility::trimExplode(',', $arguments['values']); - $templateVariableContainer = $renderingContext->getVariableProvider(); - $settings = $templateVariableContainer['settings']; $type = $arguments['type']; + $config = $arguments['config']; foreach ($indexes as $index) { - $types[] = $settings['configurator']['options'][$type][$index]; + $types[] = $config[$type][$index]; } return implode(', ', $types); } diff --git a/web/typo3conf/ext/ep_events/Resources/Private/Templates/Email/Configurator.html b/web/typo3conf/ext/ep_events/Resources/Private/Templates/Email/Configurator.html index b56c0485..3ab883c2 100644 --- a/web/typo3conf/ext/ep_events/Resources/Private/Templates/Email/Configurator.html +++ b/web/typo3conf/ext/ep_events/Resources/Private/Templates/Email/Configurator.html @@ -14,31 +14,31 @@