diff --git a/config/services.yaml b/config/services.yaml index ec18293..b9720af 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -8,63 +8,69 @@ parameters: services: # default configuration for services in *this* file _defaults: - autowire: true # Automatically injects dependencies in your services. + autowire: true # Automatically injects dependencies in your services. autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. # makes classes in src/ available to be used as services # this creates a service per class whose id is the fully-qualified class name App\: - resource: '../src/' + resource: "../src/" exclude: - - '../src/DependencyInjection/' - - '../src/Entity/' - - '../src/Kernel.php' - + - "../src/DependencyInjection/" + - "../src/Entity/" + - "../src/Kernel.php" + App\ActionHandler\DailyDataActionHandler: - arguments: - $actions: [ - '@App\Action\Account\FetchUserSession', - '@App\Action\Account\FetchTradingAccounts', - '@App\Action\Gain\FetchDailyData', - ] + arguments: + $actions: + [ + '@App\Action\Account\FetchUserSession', + '@App\Action\Account\FetchTradingAccounts', + '@App\Action\Gain\FetchDailyData', + ] App\ActionHandler\DailyGainsActionHandler: - arguments: - $actions: [ - '@App\Action\Account\FetchUserSession', - '@App\Action\Account\FetchTradingAccounts', - '@App\Action\Gain\FetchDailyGain', - ] + arguments: + $actions: + [ + '@App\Action\Account\FetchUserSession', + '@App\Action\Account\FetchTradingAccounts', + '@App\Action\Gain\FetchDailyGain', + ] App\ActionHandler\AccountActionHandler: arguments: - $actions: [ - '@App\Action\Account\FetchUserSession', - '@App\Action\Account\FetchAccounts', - ] - + $actions: + [ + '@App\Action\Account\FetchUserSession', + '@App\Action\Account\FetchAccounts', + ] + App\ActionHandler\WidgetActionHandler: arguments: - $actions: [ - '@App\Action\Account\FetchUserSession', - '@App\Action\Account\FetchTradingAccounts', - '@App\Action\Presentation\ChartWidget', - ] - + $actions: + [ + '@App\Action\Account\FetchUserSession', + '@App\Action\Account\FetchTradingAccounts', + '@App\Action\Presentation\ChartWidget', + ] + App\ActionHandler\HistoryActionHandler: arguments: - $actions: [ - '@App\Action\Account\FetchUserSession', - '@App\Action\Account\FetchTradingAccounts', - '@App\Action\Order\History', - ] + $actions: + [ + '@App\Action\Account\FetchUserSession', + '@App\Action\Account\FetchTradingAccounts', + '@App\Action\Order\History', + ] App\Command\ExportCommand: arguments: - $exportActions: [ - '@App\Action\FileSystem\CreateCsvFileAction', - '@App\Action\Download\FileDownloadAction' - ] + $postHooks: + [ + '@App\Action\FileSystem\CreateCsvFileAction', + '@App\Action\Download\FileDownloadAction', + ] App\ActionHandler\ActionHandlerInterface $accountActionHandler: '@App\ActionHandler\AccountActionHandler' App\ActionHandler\ActionHandlerInterface $dailyDataActionHandler: '@App\ActionHandler\DailyDataActionHandler' @@ -76,4 +82,4 @@ services: App\Presentation\Output\TableInterface $dailyDataTable: '@App\Presentation\Output\DailyDataTable' App\Presentation\Output\TableInterface $dailyGainTable: '@App\Presentation\Output\DailyGainsTable' App\Presentation\Output\TableInterface $historyTable: '@App\Presentation\Output\HistoryTable' - App\Presentation\Output\TableInterface $widgetTable: '@App\Presentation\Output\WidgetTable' \ No newline at end of file + App\Presentation\Output\TableInterface $widgetTable: '@App\Presentation\Output\WidgetTable' diff --git a/src/Command/ExportCommand.php b/src/Command/ExportCommand.php index 2b2d36b..f01615a 100644 --- a/src/Command/ExportCommand.php +++ b/src/Command/ExportCommand.php @@ -7,7 +7,7 @@ use App\Action\ActionInterface; use App\ActionHandler\ActionHandler; use App\Dto\Aggregator\AggregateRoot; -use App\Manager\ActionHandlerManager; +use App\Strategy\ActionHandlerStrategy; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\QuestionHelper; @@ -28,8 +28,8 @@ class ExportCommand extends Command * @param array $exportActions */ public function __construct( - private readonly ActionHandlerManager $actionHandlerManager, - private readonly array $exportActions + private readonly ActionHandlerStrategy $actionHandlerStrategy, + private readonly array $postHooks ) { parent::__construct(); } @@ -47,9 +47,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $aggregator = new AggregateRoot(); /** @var ActionHandler $actionHandler */ - $actionHandler = ($this->actionHandlerManager)($handler); + $actionHandler = ($this->actionHandlerStrategy)($handler); - foreach ($this->exportActions as $action) { + foreach ($this->postHooks as $action) { $actionHandler->postHook($action); } diff --git a/src/Manager/ActionHandlerManager.php b/src/Strategy/ActionHandlerStrategy.php similarity index 93% rename from src/Manager/ActionHandlerManager.php rename to src/Strategy/ActionHandlerStrategy.php index e56163f..1d5b27c 100644 --- a/src/Manager/ActionHandlerManager.php +++ b/src/Strategy/ActionHandlerStrategy.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace App\Manager; +namespace App\Strategy; use App\ActionHandler\ActionHandlerInterface; use App\Exception\ClassNotFoundException; -class ActionHandlerManager +class ActionHandlerStrategy { public function __construct( private readonly ActionHandlerInterface $dailyDataActionHandler,