Remove references to the toTweet() method
This commit is contained in:
parent
7542a2a542
commit
909374edcb
3 changed files with 18 additions and 5 deletions
web/modules/custom/blog/src/Service/PostPusher
|
@ -6,6 +6,7 @@ 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 GuzzleHttp\ClientInterface;
|
use GuzzleHttp\ClientInterface;
|
||||||
use Webmozart\Assert\Assert;
|
use Webmozart\Assert\Assert;
|
||||||
|
@ -17,12 +18,14 @@ final class IftttPostPusher extends WebhookPostPusher {
|
||||||
private ConfigFactoryInterface $configFactory;
|
private ConfigFactoryInterface $configFactory;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
ConvertPostToTweet $convertPostToTweetAction,
|
||||||
ClientInterface $client,
|
ClientInterface $client,
|
||||||
ConfigFactoryInterface $configFactory
|
ConfigFactoryInterface $configFactory
|
||||||
) {
|
) {
|
||||||
|
$this->convertPostToTweetAction = $convertPostToTweetAction;
|
||||||
$this->configFactory = $configFactory;
|
$this->configFactory = $configFactory;
|
||||||
|
|
||||||
parent::__construct($client);
|
parent::__construct($convertPostToTweetAction, $client);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function push(Post $post): void {
|
public function push(Post $post): void {
|
||||||
|
@ -34,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' => $post->toTweet()])
|
'value1' => $this->t('Blogged: @text', ['@text' => ($this->convertPostToTweetAction)($post)])
|
||||||
->render(),
|
->render(),
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -6,6 +6,7 @@ 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 GuzzleHttp\ClientInterface;
|
use GuzzleHttp\ClientInterface;
|
||||||
use Webmozart\Assert\Assert;
|
use Webmozart\Assert\Assert;
|
||||||
|
@ -17,12 +18,14 @@ final class IntegromatPostPusher extends WebhookPostPusher {
|
||||||
private ConfigFactoryInterface $configFactory;
|
private ConfigFactoryInterface $configFactory;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
ConvertPostToTweet $convertPostToTweetAction,
|
||||||
ClientInterface $client,
|
ClientInterface $client,
|
||||||
ConfigFactoryInterface $configFactory
|
ConfigFactoryInterface $configFactory
|
||||||
) {
|
) {
|
||||||
|
$this->convertPostToTweetAction = $convertPostToTweetAction;
|
||||||
$this->configFactory = $configFactory;
|
$this->configFactory = $configFactory;
|
||||||
|
|
||||||
parent::__construct($client);
|
parent::__construct($convertPostToTweetAction, $client);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function push(Post $post): void {
|
public function push(Post $post): void {
|
||||||
|
@ -34,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' => $post->toTweet()])
|
'text' => $this->t('@text', ['@text' => ($this->convertPostToTweetAction)($post)])
|
||||||
->render(),
|
->render(),
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -4,13 +4,20 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Drupal\opdavies_blog\Service\PostPusher;
|
namespace Drupal\opdavies_blog\Service\PostPusher;
|
||||||
|
|
||||||
|
use Drupal\opdavies_blog\Action\ConvertPostToTweet;
|
||||||
use GuzzleHttp\ClientInterface;
|
use GuzzleHttp\ClientInterface;
|
||||||
|
|
||||||
abstract class WebhookPostPusher implements PostPusher {
|
abstract class WebhookPostPusher implements PostPusher {
|
||||||
|
|
||||||
|
protected ConvertPostToTweet $convertPostToTweetAction;
|
||||||
|
|
||||||
protected ClientInterface $client;
|
protected ClientInterface $client;
|
||||||
|
|
||||||
public function __construct(ClientInterface $client) {
|
public function __construct(
|
||||||
|
ConvertPostToTweet $convertPostToTweetAction,
|
||||||
|
ClientInterface $client
|
||||||
|
) {
|
||||||
|
$this->convertPostToTweetAction = $convertPostToTweetAction;
|
||||||
$this->client = $client;
|
$this->client = $client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue