Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EasyWebhook] Clean up #502

Merged
merged 1 commit into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions packages/EasyWebhook/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
"eonx-com/easy-event-dispatcher": "^3.1",
"eonx-com/easy-lock": "^3.1",
"eonx-com/easy-random": "^3.1",
"eonx-com/easy-pagination": "^3.1",
"eonx-com/easy-utils": "^3.1",
"nesbot/carbon": "^2.22",
"nette/utils": "^3.1",
"symfony/http-client": "^4.4 || ^5.1.5"
},
"require-dev": {
"doctrine/dbal": "^2.6",
"eonx-com/easy-pagination": "^3.1",
"illuminate/database": "^5.5 || ^6.20.14",
"ramsey/uuid": "^3.9",
"phpunit/phpunit": "^8.4 || ^9.5",
Expand All @@ -36,8 +36,5 @@
"branch-alias": {
"dev-master": "3.1-dev"
}
},
"suggest": {
"eonx-com/easy-pagination": "Used to pagined due webhooks for sendAfter feature"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use EonX\EasyLock\Interfaces\LockServiceInterface;
use EonX\EasyWebhook\Async\NullAsyncDispatcher;
use EonX\EasyWebhook\Bridge\BridgeConstantsInterface;
use EonX\EasyWebhook\Bridge\Doctrine\DbalStatementsProvider;
use EonX\EasyWebhook\Bridge\Laravel\Commands\SendDueWebhooksCommand;
use EonX\EasyWebhook\Bridge\Laravel\Jobs\AsyncDispatcher;
use EonX\EasyWebhook\Formatters\JsonFormatter;
Expand Down Expand Up @@ -67,6 +68,7 @@ public function register(): void
$this->registerEventHeaderServices();
$this->registerIdHeaderServices();
$this->registerSignatureServices();
$this->registerStatementsProvider();
}

private function registerAsyncServices(): void
Expand Down Expand Up @@ -250,4 +252,9 @@ private function registerSignatureServices(): void

$this->app->tag(SignatureHeaderMiddleware::class, [BridgeConstantsInterface::TAG_MIDDLEWARE]);
}

private function registerStatementsProvider(): void
{
$this->app->singleton(DbalStatementsProvider::class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use EonX\EasyWebhook\Async\NullAsyncDispatcher;
use EonX\EasyWebhook\Bridge\BridgeConstantsInterface;
use EonX\EasyWebhook\Bridge\Doctrine\DbalStatementsProvider;
use EonX\EasyWebhook\Bridge\Symfony\Command\SendDueWebhooksCommand;
use EonX\EasyWebhook\Formatters\JsonFormatter;
use EonX\EasyWebhook\HttpClientFactory;
Expand Down Expand Up @@ -62,4 +63,9 @@
// Stores (Default)
$services->set(StoreInterface::class, NullStore::class);
$services->set(ResultStoreInterface::class, NullResultStore::class);

// StatementsProvider (Helper)
$services
->set(DbalStatementsProvider::class)
->public();
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,8 @@ public function __construct(RandomGeneratorInterface $random, Connection $conn,

protected function existsInDb(string $id): bool
{
$sql = \sprintf('SELECT id FROM %s WHERE id = :id', $this->getTableForQuery());
$sql = \sprintf('SELECT id FROM %s WHERE id = :id', $this->table);

return \is_array($this->conn->fetchAssociative($sql, \compact('id')));
}

protected function getTableForQuery(): string
{
return \sprintf('`%s`', $this->table);
}
}
4 changes: 2 additions & 2 deletions packages/EasyWebhook/src/Stores/DoctrineDbalStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ final class DoctrineDbalStore extends AbstractDoctrineDbalStore implements Store
{
public function __construct(RandomGeneratorInterface $random, Connection $conn, ?string $table = null)
{
parent::__construct($random, $conn, $table ?? 'easy_webhooks');
parent::__construct($random, $conn, $table ?? self::DEFAULT_TABLE);
}

public function find(string $id): ?WebhookInterface
{
$sql = \sprintf('SELECT * FROM %s WHERE id = :id', $this->getTableForQuery());
$sql = \sprintf('SELECT * FROM %s WHERE id = :id', $this->table);

$data = $this->conn->fetchAssociative($sql, [
'id' => $id,
Expand Down