Fix configurator email not being sent due to missing config
This commit is contained in:
@@ -28,6 +28,7 @@ namespace EP\EpEvents\Controller;
|
|||||||
***************************************************************/
|
***************************************************************/
|
||||||
|
|
||||||
use EP\EpEvents\Domain\Model\Inquiry;
|
use EP\EpEvents\Domain\Model\Inquiry;
|
||||||
|
use EP\EpEvents\Service\ConfigurationService;
|
||||||
use EP\EpEvents\Service\EmailService;
|
use EP\EpEvents\Service\EmailService;
|
||||||
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
||||||
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
|
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
|
||||||
@@ -41,11 +42,16 @@ class AjaxFormController extends ActionController
|
|||||||
protected $emailService;
|
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'],
|
'toName' => $this->settings['inquiryToName'],
|
||||||
'subject' => 'Anfrage E&P Events',
|
'subject' => 'Anfrage E&P Events',
|
||||||
'templateName' => 'Email/Configurator',
|
'templateName' => 'Email/Configurator',
|
||||||
'variables' => [ 'inquiry' => $inquiry ]
|
'variables' => [
|
||||||
|
'inquiry' => $inquiry,
|
||||||
|
'config' => $this->configurationService->getConfiguratorConfig(),
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
return json_encode($response);
|
return json_encode($response);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,12 +28,27 @@ namespace EP\EpEvents\Controller;
|
|||||||
***************************************************************/
|
***************************************************************/
|
||||||
|
|
||||||
use EP\EpEvents\Domain\Model\Inquiry;
|
use EP\EpEvents\Domain\Model\Inquiry;
|
||||||
|
use EP\EpEvents\Service\ConfigurationService;
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
||||||
use TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility;
|
|
||||||
|
|
||||||
class FormController extends ActionController
|
class FormController extends ActionController
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var ConfigurationService
|
||||||
|
*/
|
||||||
|
protected $configurationService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ConfigurationService $configurationService
|
||||||
|
*/
|
||||||
|
public function __construct(ConfigurationService $configurationService)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->configurationService = $configurationService;
|
||||||
|
}
|
||||||
|
|
||||||
public function inquiryFormAction()
|
public function inquiryFormAction()
|
||||||
{
|
{
|
||||||
$inquiry = $this->getInquiryFromContext();
|
$inquiry = $this->getInquiryFromContext();
|
||||||
@@ -63,7 +78,7 @@ class FormController extends ActionController
|
|||||||
} else {
|
} else {
|
||||||
$inquiry = $this->getInquiryFromContext();
|
$inquiry = $this->getInquiryFromContext();
|
||||||
}
|
}
|
||||||
$this->view->assign('configuratorConfig', $this->getConfiguratorConfig());
|
$this->view->assign('configuratorConfig', $this->configurationService->getConfiguratorConfig());
|
||||||
$this->view->assign('inquiry', $inquiry);
|
$this->view->assign('inquiry', $inquiry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +93,7 @@ class FormController extends ActionController
|
|||||||
$offer = $content['offer'];
|
$offer = $content['offer'];
|
||||||
$inquiry = Inquiry::fromOffer($offer, $defaults);
|
$inquiry = Inquiry::fromOffer($offer, $defaults);
|
||||||
} elseif (isset($content['travelType'])) {
|
} elseif (isset($content['travelType'])) {
|
||||||
$config = $this->getConfiguratorConfig();
|
$config = $this->configurationService->getConfiguratorConfig();
|
||||||
/** @var \EP\EpEvents\Domain\Model\Traveltype $travelType */
|
/** @var \EP\EpEvents\Domain\Model\Traveltype $travelType */
|
||||||
$travelType = $content['travelType'];
|
$travelType = $content['travelType'];
|
||||||
$configuratorType = $travelType->getConfiguratorType();
|
$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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace EP\EpEvents\Service;
|
||||||
|
|
||||||
|
use TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility;
|
||||||
|
|
||||||
|
class ConfigurationService
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ConfigurationUtility
|
||||||
|
*/
|
||||||
|
protected $configurationUtility;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ConfigurationUtility $configurationUtility
|
||||||
|
*/
|
||||||
|
public function __construct(ConfigurationUtility $configurationUtility)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -48,11 +48,11 @@ class EmailService implements SingletonInterface
|
|||||||
protected $settings;
|
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(
|
$settings = GeneralUtility::removeDotsFromTS(
|
||||||
$this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT)
|
$this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT)
|
||||||
);
|
);
|
||||||
|
|||||||
+3
-3
@@ -41,6 +41,7 @@ class ConfiguratorTypeLabelsViewHelper extends AbstractViewHelper
|
|||||||
parent::initializeArguments();
|
parent::initializeArguments();
|
||||||
|
|
||||||
$this->registerArgument('type', 'string', 'The type', true);
|
$this->registerArgument('type', 'string', 'The type', true);
|
||||||
|
$this->registerArgument('config', 'array', 'The config', true);
|
||||||
$this->registerArgument('values', 'string', 'The labels', true);
|
$this->registerArgument('values', 'string', 'The labels', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,12 +62,11 @@ class ConfiguratorTypeLabelsViewHelper extends AbstractViewHelper
|
|||||||
}
|
}
|
||||||
$types = [];
|
$types = [];
|
||||||
$indexes = GeneralUtility::trimExplode(',', $arguments['values']);
|
$indexes = GeneralUtility::trimExplode(',', $arguments['values']);
|
||||||
$templateVariableContainer = $renderingContext->getVariableProvider();
|
|
||||||
$settings = $templateVariableContainer['settings'];
|
|
||||||
$type = $arguments['type'];
|
$type = $arguments['type'];
|
||||||
|
$config = $arguments['config'];
|
||||||
foreach ($indexes as $index)
|
foreach ($indexes as $index)
|
||||||
{
|
{
|
||||||
$types[] = $settings['configurator']['options'][$type][$index];
|
$types[] = $config[$type][$index];
|
||||||
}
|
}
|
||||||
return implode(', ', $types);
|
return implode(', ', $types);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,31 +14,31 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Reiseart</th>
|
<th>Reiseart</th>
|
||||||
<td>{ep:configuratorTypeLabels(type: 'travelType', values: inquiry.travelType)}</td>
|
<td>{ep:configuratorTypeLabels(type: 'travelTypeOptions', config: config, values: inquiry.travelType)}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Destination</th>
|
<th>Destination</th>
|
||||||
<td>{ep:configuratorTypeLabels(type: 'locationType', values: inquiry.locationType)}</td>
|
<td>{ep:configuratorTypeLabels(type: 'locationTypeOptions', config: config, values: inquiry.locationType)}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Unterkunft</th>
|
<th>Unterkunft</th>
|
||||||
<td>{ep:configuratorTypeLabels(type: 'accommodationType', values: inquiry.hotelType)}</td>
|
<td>{ep:configuratorTypeLabels(type: 'accommodationTypeOptions', config: config, values: inquiry.hotelType)}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Programm</th>
|
<th>Programm</th>
|
||||||
<td>{ep:configuratorTypeLabels(type: 'programmeType', values: inquiry.activityType)}</td>
|
<td>{ep:configuratorTypeLabels(type: 'programmeTypeOptions', config: config, values: inquiry.activityType)}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Ziel</th>
|
<th>Ziel</th>
|
||||||
<td>{ep:configuratorTypeLabels(type: 'distance', values: inquiry.distance)}</td>
|
<td>{ep:configuratorTypeLabels(type: 'distanceOptions', config: config, values: inquiry.distance)}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Anzahl Personen</th>
|
<th>Anzahl Personen</th>
|
||||||
<td>{ep:configuratorTypeLabels(type: 'pax', values: inquiry.pax)}</td>
|
<td>{ep:configuratorTypeLabels(type: 'paxOptions', config: config, values: inquiry.pax)}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Budget</th>
|
<th>Budget</th>
|
||||||
<td>{ep:configuratorTypeLabels(type: 'budget', values: inquiry.budget)}</td>
|
<td>{ep:configuratorTypeLabels(type: 'budgetOptions', config: config, values: inquiry.budget)}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Zeitraum</th>
|
<th>Zeitraum</th>
|
||||||
|
|||||||
Reference in New Issue
Block a user