diff --git a/Model/Config/Source/Season.php b/Model/Config/Source/Season.php new file mode 100644 index 0000000..f492007 --- /dev/null +++ b/Model/Config/Source/Season.php @@ -0,0 +1,43 @@ + 'halloween', 'label' => __('Halloween')], + ['value' => 'noel', 'label' => __('Noel')], + ['value' => 'printemps', 'label' => __('Printemps')], + ['value' => 'ete', 'label' => __('Été')], + ['value' => 'automne', 'label' => __('Automne')], + ['value' => 'fete_nationale', 'label' => __('Fête Nationale')], + ['value' => 'nouvel_an', 'label' => __('Nouvel An')], + ['value' => 'paques', 'label' => __('Pâques')], + ['value' => 'saint_valentin', 'label' => __('Saint-Valentin')], + ['value' => 'fete_travail', 'label' => __('Fête du Travail')], + ['value' => 'fete_musique', 'label' => __('Fête de la Musique')], + ['value' => 'hiver', 'label' => __('Hiver')], + ['value' => 'carnaval', 'label' => __('Carnaval')], + ['value' => 'saint_patrick', 'label' => __('Saint Patrick')], + ['value' => 'hanoucca', 'label' => __('Hanoucca')], + ['value' => 'ramadan', 'label' => __('Ramadan')], + ['value' => 'diwali', 'label' => __('Diwali')], + ['value' => 'chinese_new_year', 'label' => __('Nouvel An Chinois')], + ['value' => 'fete_meres', 'label' => __('Fête des Mères')], + ['value' => 'fete_peres', 'label' => __('Fête des Pères')], + ['value' => 'action_de_grace', 'label' => __('Action de Grâce')], + ['value' => 'fete_saucisse', 'label' => __('Fête à la Saucisse')], + ['value' => 'apero_time', 'label' => __('l\'heure de l\'apéro')] + ]; + } + +} diff --git a/ViewModel/Snowflake.php b/ViewModel/Snowflake.php index b643a21..d46ddea 100644 --- a/ViewModel/Snowflake.php +++ b/ViewModel/Snowflake.php @@ -10,24 +10,67 @@ use Magento\Framework\View\Element\Block\ArgumentInterface; use Opengento\Snowflake\Model\Config\OpenWeather as OpenWeatherConfig; use Opengento\Snowflake\Model\Config\Snowflake as SnowflakeConfig; +use Magento\Framework\Serialize\SerializerInterface; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Store\Model\ScopeInterface; final class Snowflake implements ArgumentInterface { - private SnowflakeConfig $snowflakeConfig; + public function __construct( + private SerializerInterface $serializer, + private SnowflakeConfig $snowflakeConfig, + private OpenWeatherConfig $openWeatherConfig, + private ScopeConfigInterface $scopeConfig + ) {} - private OpenWeatherConfig $openWeatherConfig; + public function getSeasonalIcons(): array + { + return [ + 'halloween' => ['🎃', '👻', '🦇'], + 'noel' => ['❄️', '🎅', '🎄'], + 'printemps' => ['🌷', '🐣', '☀️'], + 'ete' => ['🌞', '🏖️', '🍉'], + 'automne' => ['🍂', '🍁', '🎃'], + 'fete_nationale' => ['🎆', '🇫🇷', '🥳'], + 'nouvel_an' => ['🎇', '🎉', '🥂'], + 'paques' => ['🐰', '🥚', '🐣'], + 'saint_valentin' => ['💖', '🌹', '💕'], + 'fete_travail' => ['⚒️', '🌻', '🛠️'], + 'fete_musique' => ['🎵', '🎸', '🎤'], + 'hiver' => ['❄️', '☃️', '🌨️'], + 'printemps' => ['🌸', '🌷', '🦋'], + 'ete' => ['🌞', '🍦', '🏄'], + 'automne' => ['🍁', '🍂', '🍄'], + 'halloween' => ['🎃', '🕸️', '👻'], + 'noel' => ['🎄', '🎅', '🤶'], + 'carnaval' => ['🎭', '🎊', '🤹'], + 'saint_patrick' => ['☘️', '🍺', '🇮🇪'], + 'hanoucca' => ['🕎', '✨', '🥯'], + 'ramadan' => ['🌙', '🕌', '🕋'], + 'diwali' => ['🪔', '🎆', '🌟'], + 'chinese_new_year' => ['🐉', '🏮', '🧧'], + 'fete_meres' => ['💐', '👩‍👧‍👦', '🌹'], + 'fete_peres' => ['👔', '🍻', '🎣'], + 'halloween' => ['🎃', '🦇', '🕸️'], + 'action_de_grace' => ['🦃', '🥧', '🍂'], + 'noel' => ['🎄', '🎁', '❄️'], + 'nouvel_an_chinois' => ['🐲', '🧨', '🧧'], + 'fete_saucisse' => ['🌭', '🍻', '🎉', '🕺', '🎶'], + 'apero_time' => ['🍺', '🍹', '🍾'] + ]; + } - public function __construct( - SnowflakeConfig $snowflakeConfig, - OpenWeatherConfig $openWeatherConfig - ) { - $this->snowflakeConfig = $snowflakeConfig; - $this->openWeatherConfig = $openWeatherConfig; + public function getSelectedSeason(): string + { + return $this->scopeConfig->getValue('snowflake/general/season', ScopeInterface::SCOPE_STORE); } - public function getSnowflakeChar(): string + public function getIconsForSelectedSeason(): string { - return $this->snowflakeConfig->getSnowflakeChar(); + $selectedSeason = $this->getSelectedSeason(); + $seasonalIcons = $this->getSeasonalIcons(); + $icons = $seasonalIcons[$selectedSeason] ?? []; + return $this->serializer->serialize($icons); } public function getSnowflakeVSpeed(): float diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 0fbdb50..a0c2767 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -19,10 +19,10 @@ snowflake/general/enable Magento\Config\Model\Config\Source\Enabledisable - - - more emoji.]]> - Opengento\Snowflake\Model\Config\Backend\EmojiConverter + + + Opengento\Snowflake\Model\Config\Source\Season + 1 diff --git a/view/frontend/templates/snowflake.phtml b/view/frontend/templates/snowflake.phtml index 805882f..c49736b 100644 --- a/view/frontend/templates/snowflake.phtml +++ b/view/frontend/templates/snowflake.phtml @@ -5,72 +5,67 @@ */ declare(strict_types=1); +use Hyva\Theme\Model\ViewModelRegistry; use Magento\Framework\View\Element\Template; use Opengento\Snowflake\ViewModel\Snowflake; /** @var Template $block */ -/** @var Snowflake $viewModel */ -$viewModel = $block->getData('viewModel'); +/** @var Snowflake $snowflake */ +$snowflake = $block->getData('viewModel'); ?>