From 170adca0f14b4aec9a2fbb4f8dbbde965746335e Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Wed, 11 Jan 2017 19:36:58 +0300 Subject: [PATCH] Telegram Notifier service is now receives AccountRepository directly instead of EntityManager. --- .../Resources/config/services.yml | 2 +- .../Service/Telegram/Notifier.php | 28 ++++++------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/Skobkin/Bundle/PointToolsBundle/Resources/config/services.yml b/src/Skobkin/Bundle/PointToolsBundle/Resources/config/services.yml index 6f62571..782525d 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Resources/config/services.yml +++ b/src/Skobkin/Bundle/PointToolsBundle/Resources/config/services.yml @@ -196,7 +196,7 @@ services: # User notifier app.telegram.notifier: class: Skobkin\Bundle\PointToolsBundle\Service\Telegram\Notifier - arguments: ['@doctrine.orm.entity_manager', '@app.telegram.message_sender'] + arguments: ['@app.point.telegram_account_repository', '@app.telegram.message_sender'] # Common incoming message processor app.telegram.update_dispatcher: diff --git a/src/Skobkin/Bundle/PointToolsBundle/Service/Telegram/Notifier.php b/src/Skobkin/Bundle/PointToolsBundle/Service/Telegram/Notifier.php index fa345fa..139b1ae 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Service/Telegram/Notifier.php +++ b/src/Skobkin/Bundle/PointToolsBundle/Service/Telegram/Notifier.php @@ -2,10 +2,10 @@ namespace Skobkin\Bundle\PointToolsBundle\Service\Telegram; -use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\EntityRepository; +use Skobkin\Bundle\PointToolsBundle\Entity\Telegram\Account; use Skobkin\Bundle\PointToolsBundle\Entity\User; use Skobkin\Bundle\PointToolsBundle\Entity\UserRenameEvent; +use Skobkin\Bundle\PointToolsBundle\Repository\Telegram\AccountRepository; /** * Notifies Telegram users about some events @@ -13,12 +13,7 @@ use Skobkin\Bundle\PointToolsBundle\Entity\UserRenameEvent; class Notifier { /** - * @var EntityManagerInterface - */ - private $em; - - /** - * @var EntityRepository + * @var AccountRepository */ private $accountsRepo; @@ -28,18 +23,10 @@ class Notifier private $messenger; - /** - * Notifier constructor. - * - * @param EntityManagerInterface $em - * @param MessageSender $messenger - */ - public function __construct(EntityManagerInterface $em, MessageSender $messenger) + public function __construct(AccountRepository $accountRepository, MessageSender $messenger) { - $this->em = $em; + $this->accountsRepo = $accountRepository; $this->messenger = $messenger; - - $this->accountsRepo = $em->getRepository('SkobkinPointToolsBundle:Telegram\Account'); } /** @@ -56,11 +43,12 @@ class Notifier * Send notification about changes in user's subscribers list * * @param User $user - * @param array $subscribed - * @param array $unsubscribed + * @param User[] $subscribed + * @param User[] $unsubscribed */ public function sendUserSubscribersUpdatedNotification(User $user, array $subscribed, array $unsubscribed) { + /** @var Account $account */ $account = $this->accountsRepo->findOneBy( [ 'user' => $user,