-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
718 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,11 @@ VEILLEUR_REPOSITORY_LANGUAGE='["php", "javascript", "java", "rust"]' | |
# For a PostgreSQL database, use: "postgresql://db_user:[email protected]:5432/db_name?serverVersion=11&charset=utf8" | ||
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml | ||
DATABASE_URL='' | ||
TWITTER_CONSUMER_KEY= | ||
TWITTER_CONSUMER_SECRET= | ||
TWITTER_ACCESS_TOKEN_KEY= | ||
TWITTER_ACCESS_TOKEN_SECRET= | ||
|
||
###< doctrine/doctrine-bundle ### | ||
|
||
###> symfony/messenger ### | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,7 @@ | |
font-size: 11px | ||
color: #24292e | ||
list-style-type: none | ||
|
||
.tweet-list | ||
li | ||
list-style-type: none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Veilleur\Application\Handler; | ||
|
||
use Symfony\Component\Messenger\Handler\MessageSubscriberInterface; | ||
use Veilleur\Domain\Command\Twitter\Account\Add as AddAccount; | ||
use Veilleur\Domain\Handler\Twitter\DoAddAccount as AddAccountInterface; | ||
use Veilleur\Domain\Repository\Twitter\Accounts as AccountsRepository; | ||
|
||
class DoDoAddAccount implements AddAccountInterface, MessageSubscriberInterface | ||
{ | ||
/** | ||
* @var AccountsRepository | ||
*/ | ||
private AccountsRepository $accounts; | ||
|
||
public function __construct(AccountsRepository $accounts) | ||
{ | ||
$this->accounts = $accounts; | ||
} | ||
|
||
public function __invoke(AddAccount $accountCommand) | ||
{ | ||
|
||
$account = $this->accounts->findOneByUsername($accountCommand->getUsername()); | ||
if ($account instanceof \Veilleur\Domain\Model\Twitter\Account) { | ||
return; | ||
} | ||
$account = new \Veilleur\Domain\Model\Twitter\Account($accountCommand->getUsername()); | ||
$this->accounts->persist($account); | ||
|
||
} | ||
|
||
public static function getHandledMessages(): iterable | ||
{ | ||
yield AddAccount::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Veilleur\Application\Handler; | ||
|
||
use Symfony\Component\Messenger\Handler\MessageSubscriberInterface; | ||
use Veilleur\Domain\Command\Twitter\Account\Delete; | ||
use Veilleur\Domain\Handler\Twitter\DoRemoveAccount as DoRemoveAccountInterface; | ||
use Veilleur\Domain\Repository\Twitter\Accounts; | ||
|
||
class DoRemoveAccount implements DoRemoveAccountInterface, MessageSubscriberInterface | ||
{ | ||
/** | ||
* @var Accounts | ||
*/ | ||
private Accounts $accounts; | ||
|
||
public function __construct(Accounts $accounts) | ||
{ | ||
$this->accounts = $accounts; | ||
} | ||
|
||
public function __invoke(Delete $delete) | ||
{ | ||
|
||
$account = $this->accounts->findOneByUsername($delete->getUsername()); | ||
$this->accounts->remove($account); | ||
|
||
} | ||
|
||
public static function getHandledMessages(): iterable | ||
{ | ||
yield Delete::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Veilleur\Application\Repository; | ||
|
||
use Doctrine\Persistence\{ObjectManager, ObjectRepository}; | ||
use Doctrine\Persistence\ManagerRegistry; | ||
use Veilleur\Domain\Model\Twitter\Account; | ||
use Veilleur\Domain\Repository\Twitter\Accounts as AccountsInterface; | ||
|
||
final class Accounts implements AccountsInterface | ||
{ | ||
private ObjectManager $em; | ||
private ObjectRepository $innerRepository; | ||
|
||
public function __construct(ManagerRegistry $registry) | ||
{ | ||
$this->em = $registry->getManager(); | ||
$this->innerRepository = $registry->getRepository(Account::class); | ||
} | ||
|
||
public function findAll(): iterable | ||
{ | ||
return $this->innerRepository->findAll(); | ||
} | ||
|
||
public function findOneByUsername(string $username): ?Account | ||
{ | ||
return $this->innerRepository->find($username); | ||
} | ||
|
||
public function persist(Account $account): void | ||
{ | ||
$this->em->persist($account); | ||
} | ||
|
||
public function remove(?Account $account) | ||
{ | ||
$this->em->remove($account); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Veilleur\Domain\Command\Twitter\Account; | ||
|
||
class Add | ||
{ | ||
private string $username; | ||
|
||
public function __construct(string $username) | ||
{ | ||
$this->username = $username; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getUsername(): string | ||
{ | ||
return $this->username; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Veilleur\Domain\Command\Twitter\Account; | ||
|
||
class Delete | ||
{ | ||
private string $username; | ||
|
||
public function __construct(string $username) | ||
{ | ||
$this->username = $username; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getUsername(): string | ||
{ | ||
return $this->username; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Veilleur\Domain\Handler\Twitter; | ||
|
||
use Veilleur\Domain\Command\Twitter\Account\Add as AddAccount; | ||
|
||
interface DoAddAccount | ||
{ | ||
public function __invoke(AddAccount $accountCommand); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Veilleur\Domain\Handler\Twitter; | ||
|
||
use Veilleur\Domain\Command\Twitter\Account\Delete; | ||
|
||
interface DoRemoveAccount | ||
{ | ||
|
||
public function __invoke(Delete $delete); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Veilleur\Domain\Model\Twitter; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
/** | ||
* @ORM\Entity() | ||
*/ | ||
class Account | ||
{ | ||
/** | ||
* @ORM\Id() | ||
* @ORM\GeneratedValue(strategy="NONE") | ||
* @ORM\Column(type="string") | ||
*/ | ||
public $username; | ||
|
||
public function __construct(string $username) | ||
{ | ||
$this->username = $username; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getUsername() | ||
{ | ||
return $this->username; | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Veilleur\Domain\Repository\Twitter; | ||
|
||
use Veilleur\Domain\Model\Twitter\Account; | ||
|
||
interface Accounts | ||
{ | ||
public function findOneByUsername(string $username): ?Account; | ||
|
||
public function findAll(): iterable; | ||
|
||
public function persist(Account $account): void; | ||
|
||
public function remove(?Account $account); | ||
} |
Oops, something went wrong.