From a68da87692fa875d461dc47323abfa68174c0a66 Mon Sep 17 00:00:00 2001 From: Jesse Rushlow Date: Tue, 16 Apr 2024 19:00:12 -0400 Subject: [PATCH 1/4] wip - use new bundle strategy --- .../verify_email_services.xml | 0 src/DependencyInjection/Configuration.php | 38 ---------------- .../SymfonyCastsVerifyEmailExtension.php | 43 ------------------- src/SymfonyCastsVerifyEmailBundle.php | 33 ++++++++++---- 4 files changed, 24 insertions(+), 90 deletions(-) rename {src/Resources/config => config}/verify_email_services.xml (100%) delete mode 100644 src/DependencyInjection/Configuration.php delete mode 100644 src/DependencyInjection/SymfonyCastsVerifyEmailExtension.php diff --git a/src/Resources/config/verify_email_services.xml b/config/verify_email_services.xml similarity index 100% rename from src/Resources/config/verify_email_services.xml rename to config/verify_email_services.xml diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php deleted file mode 100644 index b272335..0000000 --- a/src/DependencyInjection/Configuration.php +++ /dev/null @@ -1,38 +0,0 @@ - - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace SymfonyCasts\Bundle\VerifyEmail\DependencyInjection; - -use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; -use Symfony\Component\Config\Definition\Builder\TreeBuilder; -use Symfony\Component\Config\Definition\ConfigurationInterface; - -/** - * @author Jesse Rushlow - * @author Ryan Weaver - */ -class Configuration implements ConfigurationInterface -{ - public function getConfigTreeBuilder(): TreeBuilder - { - $treeBuilder = new TreeBuilder('symfonycasts_verify_email'); - /** @var ArrayNodeDefinition $rootNode */ - $rootNode = $treeBuilder->getRootNode(); - - $rootNode /** @phpstan-ignore-line method.notFound (The last end() call) */ - ->children() - ->integerNode('lifetime') - ->defaultValue(3600) - ->info('The length of time in seconds that a signed URI is valid for after it is created.') - ->end() - ->end(); - - return $treeBuilder; - } -} diff --git a/src/DependencyInjection/SymfonyCastsVerifyEmailExtension.php b/src/DependencyInjection/SymfonyCastsVerifyEmailExtension.php deleted file mode 100644 index 21392ad..0000000 --- a/src/DependencyInjection/SymfonyCastsVerifyEmailExtension.php +++ /dev/null @@ -1,43 +0,0 @@ - - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace SymfonyCasts\Bundle\VerifyEmail\DependencyInjection; - -use Symfony\Component\Config\FileLocator; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Extension\Extension; -use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; - -/** - * @author Jesse Rushlow - * @author Ryan Weaver - */ -final class SymfonyCastsVerifyEmailExtension extends Extension -{ - public function load(array $configs, ContainerBuilder $container): void - { - $loader = new XmlFileLoader($container, new FileLocator(\dirname(__DIR__).'/Resources/config')); - $loader->load('verify_email_services.xml'); - - $configuration = $this->getConfiguration($configs, $container); - if (!$configuration) { - throw new \Exception('Configuration is not expected to be null'); - } - - $config = $this->processConfiguration($configuration, $configs); - - $helperDefinition = $container->getDefinition('symfonycasts.verify_email.helper'); - $helperDefinition->replaceArgument(3, $config['lifetime']); - } - - public function getAlias(): string - { - return 'symfonycasts_verify_email'; - } -} diff --git a/src/SymfonyCastsVerifyEmailBundle.php b/src/SymfonyCastsVerifyEmailBundle.php index 8f6d640..2c05ced 100644 --- a/src/SymfonyCastsVerifyEmailBundle.php +++ b/src/SymfonyCastsVerifyEmailBundle.php @@ -9,22 +9,37 @@ namespace SymfonyCasts\Bundle\VerifyEmail; -use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; -use Symfony\Component\HttpKernel\Bundle\Bundle; -use SymfonyCasts\Bundle\VerifyEmail\DependencyInjection\SymfonyCastsVerifyEmailExtension; +use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use Symfony\Component\HttpKernel\Bundle\AbstractBundle; /** * @author Jesse Rushlow * @author Ryan Weaver */ -class SymfonyCastsVerifyEmailBundle extends Bundle +class SymfonyCastsVerifyEmailBundle extends AbstractBundle { - public function getContainerExtension(): ?ExtensionInterface + protected string $extensionAlias = 'symfonycasts_verify_email'; + + public function configure(DefinitionConfigurator $definition): void + { + $definition->rootNode() + ->children() + ->integerNode('lifetime') + ->defaultValue(3600) + ->info('The length of time in seconds that a signed URI is valid for after it is created.') + ->end() + ; + } + + public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void { - if (!$this->extension) { - $this->extension = new SymfonyCastsVerifyEmailExtension(); - } + $container->import('../config/verify_email_services.xml'); - return $this->extension; + $container->services() + ->get('symfonycasts.verify_email.helper') + ->arg(3, $config['lifetime']) + ; } } From c842206a34dc8e94cd0d72a56e6fd5653e8f8e0b Mon Sep 17 00:00:00 2001 From: Jesse Rushlow Date: Fri, 26 Apr 2024 05:28:55 -0400 Subject: [PATCH 2/4] move translations to tld --- config/verify_email_services.xml | 2 +- .../VerifyEmailBundle+intl-icu.nl.xlf | 0 .../translations => translations}/VerifyEmailBundle.ar.xlf | 0 .../translations => translations}/VerifyEmailBundle.ca.xlf | 0 .../translations => translations}/VerifyEmailBundle.cs.xlf | 0 .../translations => translations}/VerifyEmailBundle.da.xlf | 0 .../translations => translations}/VerifyEmailBundle.de.xlf | 0 .../translations => translations}/VerifyEmailBundle.el.xlf | 0 .../translations => translations}/VerifyEmailBundle.en.xlf | 0 .../translations => translations}/VerifyEmailBundle.es.xlf | 0 .../translations => translations}/VerifyEmailBundle.fa.xlf | 0 .../translations => translations}/VerifyEmailBundle.fi.xlf | 0 .../translations => translations}/VerifyEmailBundle.fr.xlf | 0 .../translations => translations}/VerifyEmailBundle.hu.xlf | 0 .../translations => translations}/VerifyEmailBundle.id.xlf | 0 .../translations => translations}/VerifyEmailBundle.it.xlf | 0 .../translations => translations}/VerifyEmailBundle.ja.xlf | 0 .../translations => translations}/VerifyEmailBundle.mk.xlf | 0 .../translations => translations}/VerifyEmailBundle.mn.xlf | 0 .../translations => translations}/VerifyEmailBundle.pl.xlf | 0 .../translations => translations}/VerifyEmailBundle.pt.xlf | 0 .../translations => translations}/VerifyEmailBundle.ro.xlf | 0 .../translations => translations}/VerifyEmailBundle.ru.xlf | 0 .../translations => translations}/VerifyEmailBundle.sk.xlf | 0 .../translations => translations}/VerifyEmailBundle.sr.xlf | 0 .../translations => translations}/VerifyEmailBundle.tr.xlf | 0 .../translations => translations}/VerifyEmailBundle.uk.xlf | 0 27 files changed, 1 insertion(+), 1 deletion(-) rename {src/Resources/translations => translations}/VerifyEmailBundle+intl-icu.nl.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.ar.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.ca.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.cs.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.da.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.de.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.el.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.en.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.es.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.fa.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.fi.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.fr.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.hu.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.id.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.it.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.ja.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.mk.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.mn.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.pl.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.pt.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.ro.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.ru.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.sk.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.sr.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.tr.xlf (100%) rename {src/Resources/translations => translations}/VerifyEmailBundle.uk.xlf (100%) diff --git a/config/verify_email_services.xml b/config/verify_email_services.xml index 80cb3c0..fd8b477 100644 --- a/config/verify_email_services.xml +++ b/config/verify_email_services.xml @@ -2,7 +2,7 @@ diff --git a/src/Resources/translations/VerifyEmailBundle+intl-icu.nl.xlf b/translations/VerifyEmailBundle+intl-icu.nl.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle+intl-icu.nl.xlf rename to translations/VerifyEmailBundle+intl-icu.nl.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.ar.xlf b/translations/VerifyEmailBundle.ar.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.ar.xlf rename to translations/VerifyEmailBundle.ar.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.ca.xlf b/translations/VerifyEmailBundle.ca.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.ca.xlf rename to translations/VerifyEmailBundle.ca.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.cs.xlf b/translations/VerifyEmailBundle.cs.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.cs.xlf rename to translations/VerifyEmailBundle.cs.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.da.xlf b/translations/VerifyEmailBundle.da.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.da.xlf rename to translations/VerifyEmailBundle.da.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.de.xlf b/translations/VerifyEmailBundle.de.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.de.xlf rename to translations/VerifyEmailBundle.de.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.el.xlf b/translations/VerifyEmailBundle.el.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.el.xlf rename to translations/VerifyEmailBundle.el.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.en.xlf b/translations/VerifyEmailBundle.en.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.en.xlf rename to translations/VerifyEmailBundle.en.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.es.xlf b/translations/VerifyEmailBundle.es.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.es.xlf rename to translations/VerifyEmailBundle.es.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.fa.xlf b/translations/VerifyEmailBundle.fa.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.fa.xlf rename to translations/VerifyEmailBundle.fa.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.fi.xlf b/translations/VerifyEmailBundle.fi.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.fi.xlf rename to translations/VerifyEmailBundle.fi.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.fr.xlf b/translations/VerifyEmailBundle.fr.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.fr.xlf rename to translations/VerifyEmailBundle.fr.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.hu.xlf b/translations/VerifyEmailBundle.hu.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.hu.xlf rename to translations/VerifyEmailBundle.hu.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.id.xlf b/translations/VerifyEmailBundle.id.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.id.xlf rename to translations/VerifyEmailBundle.id.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.it.xlf b/translations/VerifyEmailBundle.it.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.it.xlf rename to translations/VerifyEmailBundle.it.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.ja.xlf b/translations/VerifyEmailBundle.ja.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.ja.xlf rename to translations/VerifyEmailBundle.ja.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.mk.xlf b/translations/VerifyEmailBundle.mk.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.mk.xlf rename to translations/VerifyEmailBundle.mk.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.mn.xlf b/translations/VerifyEmailBundle.mn.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.mn.xlf rename to translations/VerifyEmailBundle.mn.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.pl.xlf b/translations/VerifyEmailBundle.pl.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.pl.xlf rename to translations/VerifyEmailBundle.pl.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.pt.xlf b/translations/VerifyEmailBundle.pt.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.pt.xlf rename to translations/VerifyEmailBundle.pt.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.ro.xlf b/translations/VerifyEmailBundle.ro.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.ro.xlf rename to translations/VerifyEmailBundle.ro.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.ru.xlf b/translations/VerifyEmailBundle.ru.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.ru.xlf rename to translations/VerifyEmailBundle.ru.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.sk.xlf b/translations/VerifyEmailBundle.sk.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.sk.xlf rename to translations/VerifyEmailBundle.sk.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.sr.xlf b/translations/VerifyEmailBundle.sr.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.sr.xlf rename to translations/VerifyEmailBundle.sr.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.tr.xlf b/translations/VerifyEmailBundle.tr.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.tr.xlf rename to translations/VerifyEmailBundle.tr.xlf diff --git a/src/Resources/translations/VerifyEmailBundle.uk.xlf b/translations/VerifyEmailBundle.uk.xlf similarity index 100% rename from src/Resources/translations/VerifyEmailBundle.uk.xlf rename to translations/VerifyEmailBundle.uk.xlf From 458c5ea32a38320c2612619a0242d8340d95231f Mon Sep 17 00:00:00 2001 From: Jesse Rushlow Date: Fri, 26 Apr 2024 05:29:35 -0400 Subject: [PATCH 3/4] spacing... its important --- src/SymfonyCastsVerifyEmailBundle.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SymfonyCastsVerifyEmailBundle.php b/src/SymfonyCastsVerifyEmailBundle.php index 2c05ced..fb4037d 100644 --- a/src/SymfonyCastsVerifyEmailBundle.php +++ b/src/SymfonyCastsVerifyEmailBundle.php @@ -28,7 +28,7 @@ public function configure(DefinitionConfigurator $definition): void ->children() ->integerNode('lifetime') ->defaultValue(3600) - ->info('The length of time in seconds that a signed URI is valid for after it is created.') + ->info('The length of time in seconds that a signed URI is valid for after it is created.') ->end() ; } From 089cec8d33e108a45bcccd9ad1ffd30fffc4c241 Mon Sep 17 00:00:00 2001 From: Jesse Rushlow Date: Fri, 26 Apr 2024 05:40:52 -0400 Subject: [PATCH 4/4] fix phpstan errors --- src/SymfonyCastsVerifyEmailBundle.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SymfonyCastsVerifyEmailBundle.php b/src/SymfonyCastsVerifyEmailBundle.php index fb4037d..7909789 100644 --- a/src/SymfonyCastsVerifyEmailBundle.php +++ b/src/SymfonyCastsVerifyEmailBundle.php @@ -24,7 +24,7 @@ class SymfonyCastsVerifyEmailBundle extends AbstractBundle public function configure(DefinitionConfigurator $definition): void { - $definition->rootNode() + $definition->rootNode() /** @phpstan-ignore method.notFound */ ->children() ->integerNode('lifetime') ->defaultValue(3600) @@ -33,6 +33,7 @@ public function configure(DefinitionConfigurator $definition): void ; } + /** @param array $config */ public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void { $container->import('../config/verify_email_services.xml');