diff --git a/web/modules/custom/blog/src/OpdaviesBlogServiceProvider.php b/web/modules/custom/blog/src/OpdaviesBlogServiceProvider.php index 533d1cf..6fa40ec 100644 --- a/web/modules/custom/blog/src/OpdaviesBlogServiceProvider.php +++ b/web/modules/custom/blog/src/OpdaviesBlogServiceProvider.php @@ -12,7 +12,7 @@ use Symfony\Component\Finder\Finder; final class OpdaviesBlogServiceProvider implements ServiceProviderInterface { public function register(ContainerBuilder $container): void { - foreach (['Action', 'EventSubscriber', 'Repository', 'Service'] as $directory) { + foreach (['EventSubscriber', 'Repository', 'Service', 'UseCase'] as $directory) { $files = Finder::create() ->in(__DIR__ . '/' . $directory) ->files() diff --git a/web/modules/custom/blog/src/Service/PostPusher/IftttPostPusher.php b/web/modules/custom/blog/src/Service/PostPusher/IftttPostPusher.php index e997903..184a610 100644 --- a/web/modules/custom/blog/src/Service/PostPusher/IftttPostPusher.php +++ b/web/modules/custom/blog/src/Service/PostPusher/IftttPostPusher.php @@ -6,8 +6,8 @@ namespace Drupal\opdavies_blog\Service\PostPusher; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; -use Drupal\opdavies_blog\Action\ConvertPostToTweet; use Drupal\opdavies_blog\Entity\Node\Post; +use Drupal\opdavies_blog\UseCase\ConvertPostToTweet; use GuzzleHttp\ClientInterface; use Webmozart\Assert\Assert; @@ -18,14 +18,14 @@ final class IftttPostPusher extends WebhookPostPusher { private ConfigFactoryInterface $configFactory; public function __construct( - ConvertPostToTweet $convertPostToTweetAction, + ConvertPostToTweet $convertPostToTweet, ClientInterface $client, ConfigFactoryInterface $configFactory ) { - $this->convertPostToTweetAction = $convertPostToTweetAction; + $this->convertPostToTweet = $convertPostToTweet; $this->configFactory = $configFactory; - parent::__construct($convertPostToTweetAction, $client); + parent::__construct($convertPostToTweet, $client); } public function push(Post $post): void { @@ -37,7 +37,7 @@ final class IftttPostPusher extends WebhookPostPusher { $this->client->post($url, [ 'form_params' => [ - 'value1' => $this->t('Blogged: @text', ['@text' => ($this->convertPostToTweetAction)($post)]) + 'value1' => $this->t('Blogged: @text', ['@text' => ($this->convertPostToTweet)($post)]) ->render(), ], ]); diff --git a/web/modules/custom/blog/src/Service/PostPusher/IntegromatPostPusher.php b/web/modules/custom/blog/src/Service/PostPusher/IntegromatPostPusher.php index ed2c593..0b79808 100644 --- a/web/modules/custom/blog/src/Service/PostPusher/IntegromatPostPusher.php +++ b/web/modules/custom/blog/src/Service/PostPusher/IntegromatPostPusher.php @@ -6,8 +6,8 @@ namespace Drupal\opdavies_blog\Service\PostPusher; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; -use Drupal\opdavies_blog\Action\ConvertPostToTweet; use Drupal\opdavies_blog\Entity\Node\Post; +use Drupal\opdavies_blog\UseCase\ConvertPostToTweet; use GuzzleHttp\ClientInterface; use Webmozart\Assert\Assert; @@ -18,14 +18,14 @@ final class IntegromatPostPusher extends WebhookPostPusher { private ConfigFactoryInterface $configFactory; public function __construct( - ConvertPostToTweet $convertPostToTweetAction, + ConvertPostToTweet $convertPostToTweet, ClientInterface $client, ConfigFactoryInterface $configFactory ) { - $this->convertPostToTweetAction = $convertPostToTweetAction; + $this->convertPostToTweet = $convertPostToTweet; $this->configFactory = $configFactory; - parent::__construct($convertPostToTweetAction, $client); + parent::__construct($convertPostToTweet, $client); } public function push(Post $post): void { @@ -37,7 +37,7 @@ final class IntegromatPostPusher extends WebhookPostPusher { $this->client->post($url, [ 'form_params' => [ - 'text' => $this->t('@text', ['@text' => ($this->convertPostToTweetAction)($post)]) + 'text' => $this->t('@text', ['@text' => ($this->convertPostToTweet)($post)]) ->render(), ], ]); diff --git a/web/modules/custom/blog/src/Service/PostPusher/WebhookPostPusher.php b/web/modules/custom/blog/src/Service/PostPusher/WebhookPostPusher.php index e9fd8f5..6cd41c6 100644 --- a/web/modules/custom/blog/src/Service/PostPusher/WebhookPostPusher.php +++ b/web/modules/custom/blog/src/Service/PostPusher/WebhookPostPusher.php @@ -4,20 +4,21 @@ declare(strict_types=1); namespace Drupal\opdavies_blog\Service\PostPusher; -use Drupal\opdavies_blog\Action\ConvertPostToTweet; +use Drupal\opdavies_blog\UseCase\ConvertPostToTweet; use GuzzleHttp\ClientInterface; abstract class WebhookPostPusher implements PostPusher { - protected ConvertPostToTweet $convertPostToTweetAction; + protected ConvertPostToTweet $convertPostToTweet; protected ClientInterface $client; public function __construct( - ConvertPostToTweet $convertPostToTweetAction, + ConvertPostToTweet $convertPostToTweet, ClientInterface $client ) { - $this->convertPostToTweetAction = $convertPostToTweetAction; + + $this->convertPostToTweet = $convertPostToTweet; $this->client = $client; } diff --git a/web/modules/custom/blog/src/Action/ConvertPostToTweet.php b/web/modules/custom/blog/src/UseCase/ConvertPostToTweet.php similarity index 96% rename from web/modules/custom/blog/src/Action/ConvertPostToTweet.php rename to web/modules/custom/blog/src/UseCase/ConvertPostToTweet.php index 353be93..79eaa50 100644 --- a/web/modules/custom/blog/src/Action/ConvertPostToTweet.php +++ b/web/modules/custom/blog/src/UseCase/ConvertPostToTweet.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Drupal\opdavies_blog\Action; +namespace Drupal\opdavies_blog\UseCase; use Drupal\opdavies_blog\Entity\Node\Post; use Drupal\taxonomy\Entity\Term; diff --git a/web/modules/custom/blog/tests/src/Kernel/Action/ConvertPostToTweetTest.php b/web/modules/custom/blog/tests/src/Kernel/UseCase/ConvertPostToTweetTest.php similarity index 93% rename from web/modules/custom/blog/tests/src/Kernel/Action/ConvertPostToTweetTest.php rename to web/modules/custom/blog/tests/src/Kernel/UseCase/ConvertPostToTweetTest.php index ec96be9..a267ea2 100644 --- a/web/modules/custom/blog/tests/src/Kernel/Action/ConvertPostToTweetTest.php +++ b/web/modules/custom/blog/tests/src/Kernel/UseCase/ConvertPostToTweetTest.php @@ -1,8 +1,8 @@