Rename Action to UseCase
Rename to avoid confusion with Drupal's core Action type.
This commit is contained in:
parent
9a88301585
commit
2a0a2d47fa
|
@ -12,7 +12,7 @@ use Symfony\Component\Finder\Finder;
|
||||||
final class OpdaviesBlogServiceProvider implements ServiceProviderInterface {
|
final class OpdaviesBlogServiceProvider implements ServiceProviderInterface {
|
||||||
|
|
||||||
public function register(ContainerBuilder $container): void {
|
public function register(ContainerBuilder $container): void {
|
||||||
foreach (['Action', 'EventSubscriber', 'Repository', 'Service'] as $directory) {
|
foreach (['EventSubscriber', 'Repository', 'Service', 'UseCase'] as $directory) {
|
||||||
$files = Finder::create()
|
$files = Finder::create()
|
||||||
->in(__DIR__ . '/' . $directory)
|
->in(__DIR__ . '/' . $directory)
|
||||||
->files()
|
->files()
|
||||||
|
|
|
@ -6,8 +6,8 @@ namespace Drupal\opdavies_blog\Service\PostPusher;
|
||||||
|
|
||||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||||
use Drupal\opdavies_blog\Action\ConvertPostToTweet;
|
|
||||||
use Drupal\opdavies_blog\Entity\Node\Post;
|
use Drupal\opdavies_blog\Entity\Node\Post;
|
||||||
|
use Drupal\opdavies_blog\UseCase\ConvertPostToTweet;
|
||||||
use GuzzleHttp\ClientInterface;
|
use GuzzleHttp\ClientInterface;
|
||||||
use Webmozart\Assert\Assert;
|
use Webmozart\Assert\Assert;
|
||||||
|
|
||||||
|
@ -18,14 +18,14 @@ final class IftttPostPusher extends WebhookPostPusher {
|
||||||
private ConfigFactoryInterface $configFactory;
|
private ConfigFactoryInterface $configFactory;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ConvertPostToTweet $convertPostToTweetAction,
|
ConvertPostToTweet $convertPostToTweet,
|
||||||
ClientInterface $client,
|
ClientInterface $client,
|
||||||
ConfigFactoryInterface $configFactory
|
ConfigFactoryInterface $configFactory
|
||||||
) {
|
) {
|
||||||
$this->convertPostToTweetAction = $convertPostToTweetAction;
|
$this->convertPostToTweet = $convertPostToTweet;
|
||||||
$this->configFactory = $configFactory;
|
$this->configFactory = $configFactory;
|
||||||
|
|
||||||
parent::__construct($convertPostToTweetAction, $client);
|
parent::__construct($convertPostToTweet, $client);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function push(Post $post): void {
|
public function push(Post $post): void {
|
||||||
|
@ -37,7 +37,7 @@ final class IftttPostPusher extends WebhookPostPusher {
|
||||||
|
|
||||||
$this->client->post($url, [
|
$this->client->post($url, [
|
||||||
'form_params' => [
|
'form_params' => [
|
||||||
'value1' => $this->t('Blogged: @text', ['@text' => ($this->convertPostToTweetAction)($post)])
|
'value1' => $this->t('Blogged: @text', ['@text' => ($this->convertPostToTweet)($post)])
|
||||||
->render(),
|
->render(),
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -6,8 +6,8 @@ namespace Drupal\opdavies_blog\Service\PostPusher;
|
||||||
|
|
||||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||||
use Drupal\opdavies_blog\Action\ConvertPostToTweet;
|
|
||||||
use Drupal\opdavies_blog\Entity\Node\Post;
|
use Drupal\opdavies_blog\Entity\Node\Post;
|
||||||
|
use Drupal\opdavies_blog\UseCase\ConvertPostToTweet;
|
||||||
use GuzzleHttp\ClientInterface;
|
use GuzzleHttp\ClientInterface;
|
||||||
use Webmozart\Assert\Assert;
|
use Webmozart\Assert\Assert;
|
||||||
|
|
||||||
|
@ -18,14 +18,14 @@ final class IntegromatPostPusher extends WebhookPostPusher {
|
||||||
private ConfigFactoryInterface $configFactory;
|
private ConfigFactoryInterface $configFactory;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ConvertPostToTweet $convertPostToTweetAction,
|
ConvertPostToTweet $convertPostToTweet,
|
||||||
ClientInterface $client,
|
ClientInterface $client,
|
||||||
ConfigFactoryInterface $configFactory
|
ConfigFactoryInterface $configFactory
|
||||||
) {
|
) {
|
||||||
$this->convertPostToTweetAction = $convertPostToTweetAction;
|
$this->convertPostToTweet = $convertPostToTweet;
|
||||||
$this->configFactory = $configFactory;
|
$this->configFactory = $configFactory;
|
||||||
|
|
||||||
parent::__construct($convertPostToTweetAction, $client);
|
parent::__construct($convertPostToTweet, $client);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function push(Post $post): void {
|
public function push(Post $post): void {
|
||||||
|
@ -37,7 +37,7 @@ final class IntegromatPostPusher extends WebhookPostPusher {
|
||||||
|
|
||||||
$this->client->post($url, [
|
$this->client->post($url, [
|
||||||
'form_params' => [
|
'form_params' => [
|
||||||
'text' => $this->t('@text', ['@text' => ($this->convertPostToTweetAction)($post)])
|
'text' => $this->t('@text', ['@text' => ($this->convertPostToTweet)($post)])
|
||||||
->render(),
|
->render(),
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -4,20 +4,21 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Drupal\opdavies_blog\Service\PostPusher;
|
namespace Drupal\opdavies_blog\Service\PostPusher;
|
||||||
|
|
||||||
use Drupal\opdavies_blog\Action\ConvertPostToTweet;
|
use Drupal\opdavies_blog\UseCase\ConvertPostToTweet;
|
||||||
use GuzzleHttp\ClientInterface;
|
use GuzzleHttp\ClientInterface;
|
||||||
|
|
||||||
abstract class WebhookPostPusher implements PostPusher {
|
abstract class WebhookPostPusher implements PostPusher {
|
||||||
|
|
||||||
protected ConvertPostToTweet $convertPostToTweetAction;
|
protected ConvertPostToTweet $convertPostToTweet;
|
||||||
|
|
||||||
protected ClientInterface $client;
|
protected ClientInterface $client;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ConvertPostToTweet $convertPostToTweetAction,
|
ConvertPostToTweet $convertPostToTweet,
|
||||||
ClientInterface $client
|
ClientInterface $client
|
||||||
) {
|
) {
|
||||||
$this->convertPostToTweetAction = $convertPostToTweetAction;
|
|
||||||
|
$this->convertPostToTweet = $convertPostToTweet;
|
||||||
$this->client = $client;
|
$this->client = $client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Drupal\opdavies_blog\Action;
|
namespace Drupal\opdavies_blog\UseCase;
|
||||||
|
|
||||||
use Drupal\opdavies_blog\Entity\Node\Post;
|
use Drupal\opdavies_blog\Entity\Node\Post;
|
||||||
use Drupal\taxonomy\Entity\Term;
|
use Drupal\taxonomy\Entity\Term;
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Drupal\Tests\opdavies_blog\Kernel\Action;
|
namespace Drupal\Tests\opdavies_blog\Kernel\UseCase;
|
||||||
|
|
||||||
use Drupal\opdavies_blog\Action\ConvertPostToTweet;
|
use Drupal\opdavies_blog\UseCase\ConvertPostToTweet;
|
||||||
use Drupal\opdavies_blog_test\Factory\PostFactory;
|
use Drupal\opdavies_blog_test\Factory\PostFactory;
|
||||||
use Drupal\Tests\opdavies_blog\Kernel\PostTestBase;
|
use Drupal\Tests\opdavies_blog\Kernel\PostTestBase;
|
||||||
|
|
Loading…
Reference in a new issue