Telegram Notifier service is now receives AccountRepository directly instead of EntityManager.
This commit is contained in:
parent
592d9592c6
commit
170adca0f1
|
@ -196,7 +196,7 @@ services:
|
||||||
# User notifier
|
# User notifier
|
||||||
app.telegram.notifier:
|
app.telegram.notifier:
|
||||||
class: Skobkin\Bundle\PointToolsBundle\Service\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
|
# Common incoming message processor
|
||||||
app.telegram.update_dispatcher:
|
app.telegram.update_dispatcher:
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
namespace Skobkin\Bundle\PointToolsBundle\Service\Telegram;
|
namespace Skobkin\Bundle\PointToolsBundle\Service\Telegram;
|
||||||
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Skobkin\Bundle\PointToolsBundle\Entity\Telegram\Account;
|
||||||
use Doctrine\ORM\EntityRepository;
|
|
||||||
use Skobkin\Bundle\PointToolsBundle\Entity\User;
|
use Skobkin\Bundle\PointToolsBundle\Entity\User;
|
||||||
use Skobkin\Bundle\PointToolsBundle\Entity\UserRenameEvent;
|
use Skobkin\Bundle\PointToolsBundle\Entity\UserRenameEvent;
|
||||||
|
use Skobkin\Bundle\PointToolsBundle\Repository\Telegram\AccountRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifies Telegram users about some events
|
* Notifies Telegram users about some events
|
||||||
|
@ -13,12 +13,7 @@ use Skobkin\Bundle\PointToolsBundle\Entity\UserRenameEvent;
|
||||||
class Notifier
|
class Notifier
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var EntityManagerInterface
|
* @var AccountRepository
|
||||||
*/
|
|
||||||
private $em;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var EntityRepository
|
|
||||||
*/
|
*/
|
||||||
private $accountsRepo;
|
private $accountsRepo;
|
||||||
|
|
||||||
|
@ -28,18 +23,10 @@ class Notifier
|
||||||
private $messenger;
|
private $messenger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
public function __construct(AccountRepository $accountRepository, MessageSender $messenger)
|
||||||
* Notifier constructor.
|
|
||||||
*
|
|
||||||
* @param EntityManagerInterface $em
|
|
||||||
* @param MessageSender $messenger
|
|
||||||
*/
|
|
||||||
public function __construct(EntityManagerInterface $em, MessageSender $messenger)
|
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->accountsRepo = $accountRepository;
|
||||||
$this->messenger = $messenger;
|
$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
|
* Send notification about changes in user's subscribers list
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @param array $subscribed
|
* @param User[] $subscribed
|
||||||
* @param array $unsubscribed
|
* @param User[] $unsubscribed
|
||||||
*/
|
*/
|
||||||
public function sendUserSubscribersUpdatedNotification(User $user, array $subscribed, array $unsubscribed)
|
public function sendUserSubscribersUpdatedNotification(User $user, array $subscribed, array $unsubscribed)
|
||||||
{
|
{
|
||||||
|
/** @var Account $account */
|
||||||
$account = $this->accountsRepo->findOneBy(
|
$account = $this->accountsRepo->findOneBy(
|
||||||
[
|
[
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
|
|
Loading…
Reference in a new issue