From 6cd0a40dcd0ade745a3d1b731533e752d92e9e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Hrdina?= Date: Thu, 29 Dec 2022 15:15:19 +0000 Subject: [PATCH] feat: fix auto_responder action --- lib/Core/Factory/AutoResponderDataFactory.php | 14 ++++++++++++- lib/Resources/config/actions.yml | 21 ++++++++----------- lib/Resources/config/factories.yml | 9 +------- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/lib/Core/Factory/AutoResponderDataFactory.php b/lib/Core/Factory/AutoResponderDataFactory.php index 48894ae5..b915de54 100644 --- a/lib/Core/Factory/AutoResponderDataFactory.php +++ b/lib/Core/Factory/AutoResponderDataFactory.php @@ -4,6 +4,12 @@ namespace Netgen\InformationCollection\Core\Factory; +use eZ\Publish\Core\Helper\FieldHelper; +use eZ\Publish\Core\Helper\TranslationHelper; +use eZ\Publish\Core\MVC\ConfigResolverInterface; +use Netgen\InformationCollection\Core\Action\AutoResponderAction; +use Netgen\InformationCollection\Core\Action\EmailAction; +use Twig\Environment; use function array_key_exists; use eZ\Publish\API\Repository\Values\Content\Field; use Netgen\InformationCollection\API\Constants; @@ -16,6 +22,12 @@ class AutoResponderDataFactory extends EmailDataFactory { + public function __construct(ConfigResolverInterface $configResolver, TranslationHelper $translationHelper, FieldHelper $fieldHelper, Environment $twig) + { + parent::__construct($configResolver, $translationHelper, $fieldHelper, $twig); + $this->config = $this->configResolver->getParameter('action_config', 'netgen_information_collection')[AutoResponderAction::$defaultName]; + } + /** * Factory method. * @@ -85,7 +97,7 @@ protected function resolveRecipient(TemplateContent $data) } if (array_key_exists($field, $fields)) { - return [$fields[$field]->email]; + return [$fields[$field]->value->email]; } throw new MissingValueException($field); diff --git a/lib/Resources/config/actions.yml b/lib/Resources/config/actions.yml index fbe7478b..fdb1d3c2 100644 --- a/lib/Resources/config/actions.yml +++ b/lib/Resources/config/actions.yml @@ -3,19 +3,17 @@ services: class: Netgen\InformationCollection\Core\Action\ActionRegistry arguments: - !tagged_iterator netgen_information_collection.action - - "@netgen_information_collection.action.config_utility" + - '@Netgen\InformationCollection\Core\Action\ConfigurationUtility' - "@logger" - "@event_dispatcher" calls: - [setDebug, ['%kernel.debug%']] - netgen_information_collection.action.config_utility: - class: Netgen\InformationCollection\Core\Action\ConfigurationUtility + Netgen\InformationCollection\Core\Action\ConfigurationUtility: arguments: - "@ezpublish.config.resolver" - netgen_information_collection.action.db: - class: Netgen\InformationCollection\Core\Action\DatabaseAction + Netgen\InformationCollection\Core\Action\DatabaseAction: arguments: - '@netgen_information_collection.api.service' tags: @@ -28,10 +26,9 @@ services: tags: - { name: netgen_information_collection.action } -# netgen_information_collection.action.auto_responder: -# class: Netgen\InformationCollection\Core\Action\AutoResponderAction -# arguments: -# - '@netgen_information_collection.factory.auto_responder_data' -# - '@netgen_information_collection.mailer' -# tags: -# - { name: netgen_information_collection.action, alias: auto_responder } + Netgen\InformationCollection\Core\Action\AutoResponderAction: + arguments: + - '@Netgen\InformationCollection\API\MailerInterface' + - '@Netgen\InformationCollection\Core\EmailDataProvider\AutoResponderProvider' + tags: + - { name: netgen_information_collection.action } diff --git a/lib/Resources/config/factories.yml b/lib/Resources/config/factories.yml index 4ec5b786..72fa41ee 100644 --- a/lib/Resources/config/factories.yml +++ b/lib/Resources/config/factories.yml @@ -1,7 +1,4 @@ services: - netgen_information_collection.factory.email_data: - alias: Netgen\InformationCollection\Core\Factory\EmailDataFactory - Netgen\InformationCollection\Core\Factory\EmailDataFactory: arguments: - '@ezpublish.config.resolver' @@ -9,13 +6,9 @@ services: - '@ezpublish.field_helper' - '@twig' - - netgen_information_collection.factory.auto_responder_data: - alias: Netgen\InformationCollection\Core\Factory\AutoResponderDataFactory - Netgen\InformationCollection\Core\Factory\AutoResponderDataFactory: arguments: - - "$action_config.auto_responder;netgen_information_collection$" + - '@ezpublish.config.resolver' - '@ezpublish.translation_helper' - '@ezpublish.field_helper' - '@twig'