@@ -35,21 +35,22 @@ public function configureOptions(OptionsResolver $resolver): void
3535 $ activeAt = $ options ['active_at ' ];
3636 $ notActiveAt = $ options ['not_active_at ' ];
3737 $ legalTender = $ options ['legal_tender ' ];
38+ $ includeUndated = $ options ['include_undated ' ];
3839
3940 if (null !== $ activeAt && null !== $ notActiveAt ) {
4041 throw new InvalidOptionsException ('The "active_at" and "not_active_at" options cannot be used together. ' );
4142 }
4243
4344 $ legalTenderCacheKey = match ($ legalTender ) {
44- null => '' ,
45+ null => 'X ' ,
4546 true => '1 ' ,
4647 false => '0 ' ,
4748 };
4849
4950 return ChoiceList::loader (
5051 $ this ,
5152 new IntlCallbackChoiceLoader (
52- static function () use ($ choiceTranslationLocale , $ activeAt , $ notActiveAt , $ legalTender ) {
53+ static function () use ($ choiceTranslationLocale , $ activeAt , $ notActiveAt , $ legalTender, $ includeUndated ) {
5354 if (null === $ activeAt && null === $ notActiveAt && null === $ legalTender ) {
5455 return array_flip (Currencies::getNames ($ choiceTranslationLocale ));
5556 }
@@ -63,7 +64,7 @@ static function () use ($choiceTranslationLocale, $activeAt, $notActiveAt, $lega
6364 };
6465
6566 foreach (Currencies::getCurrencyCodes () as $ code ) {
66- if (!Currencies::isValidInAnyCountry ($ code , $ legalTender , $ active , $ activeAt ?? $ notActiveAt )) {
67+ if (!Currencies::isValidInAnyCountry ($ code , $ legalTender , $ active , $ activeAt ?? $ notActiveAt, $ includeUndated )) {
6768 continue ;
6869 }
6970
@@ -73,13 +74,14 @@ static function () use ($choiceTranslationLocale, $activeAt, $notActiveAt, $lega
7374 return array_flip ($ filteredCurrencyNames );
7475 },
7576 ),
76- $ choiceTranslationLocale .($ activeAt ?? $ notActiveAt )?->format('Y-m-d\TH:i:s ' ).$ legalTenderCacheKey ,
77+ $ choiceTranslationLocale .($ activeAt ?? $ notActiveAt )?->format('Y-m-d\TH:i:s ' ).$ legalTenderCacheKey.( int ) $ includeUndated ,
7778 );
7879 },
7980 'choice_translation_domain ' => false ,
8081 'choice_translation_locale ' => null ,
8182 'active_at ' => new \DateTimeImmutable ('today ' , new \DateTimeZone ('Etc/UTC ' )),
8283 'not_active_at ' => null ,
84+ 'include_undated ' => true ,
8385 'legal_tender ' => true ,
8486 'invalid_message ' => 'Please select a valid currency. ' ,
8587 ]);
@@ -88,6 +90,7 @@ static function () use ($choiceTranslationLocale, $activeAt, $notActiveAt, $lega
8890 $ resolver ->setAllowedTypes ('active_at ' , [\DateTimeInterface::class, 'null ' ]);
8991 $ resolver ->setAllowedTypes ('not_active_at ' , [\DateTimeInterface::class, 'null ' ]);
9092 $ resolver ->setAllowedTypes ('legal_tender ' , ['bool ' , 'null ' ]);
93+ $ resolver ->setAllowedTypes ('include_undated ' , 'bool ' );
9194 }
9295
9396 public function getParent (): ?string
0 commit comments