Implement filterable offer list

This commit is contained in:
Björn Fromme
2019-07-16 17:35:35 +02:00
parent b3234be447
commit ad64228692
22 changed files with 861 additions and 176 deletions
@@ -0,0 +1,67 @@
<?php
namespace EP\EpEvents\Service;
use EP\EpEvents\Domain\Model\Offer;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
class FilterOptionsCollector
{
/**
* @param array $offers
* @return array
*/
public static function process(array $offers)
{
$settings = [
'travelTypes' => [],
'locationTypes' => [],
'locationDistances' => [],
'hotelTypes' => [],
'activityTypes' => [],
];
foreach ($offers as $offer) {
/** @var Offer $offer */
if (!array_key_exists($offer['configuratorType'], $settings['travelTypes'])) {
$settings['travelTypes'][$offer['configuratorType']] = [
'type' => $offer['configuratorType'],
'label' => LocalizationUtility::translate(sprintf('tx_epevents_domain_model_traveltype.configurator_label.%d', $offer['configuratorType']), 'ep_events'),
];
}
if (!array_key_exists($offer['locationType'], $settings['locationTypes'])) {
$settings['locationTypes'][$offer['locationType']] = [
'type' => $offer['locationType'],
'label' => LocalizationUtility::translate(sprintf('tx_epevents_domain_model_location.configurator_label.%d', $offer['locationType']), 'ep_events'),
];
}
if (!array_key_exists($offer['locationDistance'], $settings['locationDistances'])) {
$settings['locationDistances'][$offer['locationDistance']] = [
'type' => $offer['locationDistance'],
'label' => LocalizationUtility::translate(sprintf('tx_epevents_domain_model_distance.configurator_label.%d', $offer['locationDistance']), 'ep_events'),
];
}
if (!array_key_exists($offer['hotelType'], $settings['hotelTypes'])) {
$settings['hotelTypes'][$offer['hotelType']] = [
'type' => $offer['hotelType'],
'label' => LocalizationUtility::translate(sprintf('tx_epevents_domain_model_hotel.configurator_label.%d', $offer['hotelType']), 'ep_events'),
];
}
foreach ($offer['activityTypes'] as $activityType) {
if (!array_key_exists($activityType, $settings['activityTypes'])) {
$settings['activityTypes'][$activityType] = [
'type' => $activityType,
'label' => LocalizationUtility::translate(sprintf('tx_epevents_domain_model_activity.configurator_label.%d', $activityType), 'ep_events'),
];
}
}
}
sort($settings['travelTypes']);
sort($settings['locationTypes']);
sort($settings['locationDistances']);
sort($settings['hotelTypes']);
sort($settings['activityTypes']);
return $settings;
}
}
@@ -0,0 +1,28 @@
<?php
namespace EP\EpEvents\Service;
class SectionCssClassService
{
/**
* @var array
*/
protected static $cssClasses = [
1 => 'incentives',
2 => 'teambuilding',
3 => 'meetings',
4 => 'events',
];
/**
* @param int $sectionValue
* @return string
*/
public static function getClass($sectionValue = null)
{
if (array_key_exists($sectionValue, static::$cssClasses)) {
return 'section-' . static::$cssClasses[$sectionValue];
}
return 'section-default';
}
}
@@ -0,0 +1,14 @@
<?php
namespace EP\EpEvents\Service;
class SoftHyphenService
{
/**
* @param $string
* @return string
*/
public static function replace($string)
{
return str_replace('--', '&shy;', $string);
}
}