Refactor configurator defaults config, add more defaults
This commit is contained in:
@@ -30,6 +30,7 @@ namespace EP\EpEvents\Controller;
|
||||
use EP\EpEvents\Domain\Model\Inquiry;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
||||
use TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility;
|
||||
|
||||
class FormController extends ActionController
|
||||
{
|
||||
@@ -62,6 +63,7 @@ class FormController extends ActionController
|
||||
} else {
|
||||
$inquiry = $this->getInquiryFromContext();
|
||||
}
|
||||
$this->view->assign('configuratorConfig', $this->getConfiguratorConfig());
|
||||
$this->view->assign('inquiry', $inquiry);
|
||||
}
|
||||
|
||||
@@ -76,9 +78,11 @@ class FormController extends ActionController
|
||||
$offer = $content['offer'];
|
||||
$inquiry = Inquiry::fromOffer($offer, $defaults);
|
||||
} elseif (isset($content['travelType'])) {
|
||||
$config = $this->getConfiguratorConfig();
|
||||
/** @var \EP\EpEvents\Domain\Model\Traveltype $travelType */
|
||||
$travelType = $content['travelType'];
|
||||
$inquiryName = $this->settings['configurator']['options']['travelType'][$travelType->getConfiguratorType()];
|
||||
$configuratorType = $travelType->getConfiguratorType();
|
||||
$inquiryName = $config['travelTypeOptions'][$configuratorType];
|
||||
$inquiry = Inquiry::fromTraveltype($travelType, $inquiryName, $defaults);
|
||||
} elseif (isset($content['activityType'])) {
|
||||
$inquiry = new Inquiry($defaults);
|
||||
@@ -108,4 +112,42 @@ class FormController extends ActionController
|
||||
->build()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user