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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,6 +151,15 @@ class Inquiry extends AbstractValueObject
|
||||
if ($offer->getLocation()->getConfiguratorDistance()) {
|
||||
$inquiry->setDistance($offer->getLocation()->getConfiguratorDistance());
|
||||
}
|
||||
if ($offer->getConfiguratorBudget()) {
|
||||
$inquiry->setBudget($offer->getConfiguratorBudget());
|
||||
}
|
||||
if ($offer->getConfiguratorPax()) {
|
||||
$inquiry->setPax($offer->getConfiguratorPax());
|
||||
}
|
||||
if ($offer->getConfiguratorPeriod()) {
|
||||
$inquiry->setPeriod($offer->getConfiguratorPeriod());
|
||||
}
|
||||
$activities = [];
|
||||
/** @var \EP\EpEvents\Domain\Model\Activity $activity */
|
||||
foreach ($offer->getActivities() as $activity)
|
||||
|
||||
@@ -157,6 +157,27 @@ class Offer extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
|
||||
*/
|
||||
protected $configuratorType = 0;
|
||||
|
||||
/**
|
||||
* configuratorBudget
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $configuratorBudget = 0;
|
||||
|
||||
/**
|
||||
* configuratorPax
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $configuratorPax = 0;
|
||||
|
||||
/**
|
||||
* configuratorPeriod
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $configuratorPeriod = 0;
|
||||
|
||||
/**
|
||||
* contact
|
||||
*
|
||||
@@ -626,6 +647,54 @@ class Offer extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
|
||||
$this->configuratorType = $configuratorType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getConfiguratorBudget()
|
||||
{
|
||||
return $this->configuratorBudget;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $configuratorBudget
|
||||
*/
|
||||
public function setConfiguratorBudget($configuratorBudget)
|
||||
{
|
||||
$this->configuratorBudget = $configuratorBudget;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getConfiguratorPax()
|
||||
{
|
||||
return $this->configuratorPax;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $configuratorPax
|
||||
*/
|
||||
public function setConfiguratorPax($configuratorPax)
|
||||
{
|
||||
$this->configuratorPax = $configuratorPax;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getConfiguratorPeriod()
|
||||
{
|
||||
return $this->configuratorPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $configuratorPeriod
|
||||
*/
|
||||
public function setConfiguratorPeriod($configuratorPeriod)
|
||||
{
|
||||
$this->configuratorPeriod = $configuratorPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user