Move all files to old/drupal/
This commit is contained in:
parent
8203e983d5
commit
7d76bf2968
468 changed files with 0 additions and 0 deletions
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\opdavies_blog\Service\PostPusher;
|
||||
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||
use Drupal\opdavies_blog\Entity\Node\Post;
|
||||
use Drupal\opdavies_blog\UseCase\ConvertPostToTweet;
|
||||
use GuzzleHttp\ClientInterface;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
final class IftttPostPusher extends WebhookPostPusher {
|
||||
|
||||
use StringTranslationTrait;
|
||||
|
||||
private ConfigFactoryInterface $configFactory;
|
||||
|
||||
public function __construct(
|
||||
ConvertPostToTweet $convertPostToTweet,
|
||||
ClientInterface $client,
|
||||
ConfigFactoryInterface $configFactory
|
||||
) {
|
||||
$this->convertPostToTweet = $convertPostToTweet;
|
||||
$this->configFactory = $configFactory;
|
||||
|
||||
parent::__construct($convertPostToTweet, $client);
|
||||
}
|
||||
|
||||
public function push(Post $post): void {
|
||||
$url = $this->configFactory
|
||||
->get('opdavies_blog.settings')
|
||||
->get('post_tweet_webhook_url');
|
||||
|
||||
Assert::notNull($url, 'Cannot push the post if there is no URL.');
|
||||
|
||||
$this->client->post($url, [
|
||||
'form_params' => [
|
||||
'value1' => $this->t('Blogged: @text', ['@text' => ($this->convertPostToTweet)($post)])
|
||||
->render(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\opdavies_blog\Service\PostPusher;
|
||||
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||
use Drupal\opdavies_blog\Entity\Node\Post;
|
||||
use Drupal\opdavies_blog\UseCase\ConvertPostToTweet;
|
||||
use GuzzleHttp\ClientInterface;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
final class IntegromatPostPusher extends WebhookPostPusher {
|
||||
|
||||
use StringTranslationTrait;
|
||||
|
||||
private ConfigFactoryInterface $configFactory;
|
||||
|
||||
public function __construct(
|
||||
ConvertPostToTweet $convertPostToTweet,
|
||||
ClientInterface $client,
|
||||
ConfigFactoryInterface $configFactory
|
||||
) {
|
||||
$this->convertPostToTweet = $convertPostToTweet;
|
||||
$this->configFactory = $configFactory;
|
||||
|
||||
parent::__construct($convertPostToTweet, $client);
|
||||
}
|
||||
|
||||
public function push(Post $post): void {
|
||||
$url = $this->configFactory
|
||||
->get('opdavies_blog.settings')
|
||||
->get('integromat_webhook_url');
|
||||
|
||||
Assert::notNull($url, 'Cannot push the post if there is no URL.');
|
||||
|
||||
$this->client->post($url, [
|
||||
'form_params' => [
|
||||
'text' => $this->t('@text', ['@text' => ($this->convertPostToTweet)($post)])
|
||||
->render(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\opdavies_blog\Service\PostPusher;
|
||||
|
||||
use Drupal\opdavies_blog\Entity\Node\Post;
|
||||
|
||||
final class NullPostPusher implements PostPusher {
|
||||
|
||||
public function push(Post $post): void {}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\opdavies_blog\Service\PostPusher;
|
||||
|
||||
use Drupal\opdavies_blog\Entity\Node\Post;
|
||||
|
||||
interface PostPusher {
|
||||
|
||||
public function push(Post $post): void;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\opdavies_blog\Service\PostPusher;
|
||||
|
||||
use Drupal\opdavies_blog\UseCase\ConvertPostToTweet;
|
||||
use GuzzleHttp\ClientInterface;
|
||||
|
||||
abstract class WebhookPostPusher implements PostPusher {
|
||||
|
||||
protected ConvertPostToTweet $convertPostToTweet;
|
||||
|
||||
protected ClientInterface $client;
|
||||
|
||||
public function __construct(
|
||||
ConvertPostToTweet $convertPostToTweet,
|
||||
ClientInterface $client
|
||||
) {
|
||||
|
||||
$this->convertPostToTweet = $convertPostToTweet;
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue