Telegram InlineQueryProcessor service is now receives UserRepository directly instead of EntityManager.

This commit is contained in:
Alexey Skobkin 2017-01-11 19:39:24 +03:00
parent 170adca0f1
commit 928311dad1
2 changed files with 4 additions and 13 deletions

View File

@ -209,7 +209,7 @@ services:
app.telegram.inline_query_processor:
class: Skobkin\Bundle\PointToolsBundle\Service\Telegram\InlineQueryProcessor
lazy: true
arguments: ['@doctrine.orm.entity_manager', '@app.telegram.api_client']
arguments: ['@app.point.user_repository', '@app.telegram.api_client']
# Private message processor
app.telegram.private_message_processor:

View File

@ -2,8 +2,6 @@
namespace Skobkin\Bundle\PointToolsBundle\Service\Telegram;
use Doctrine\ORM\EntityManagerInterface;
use Skobkin\Bundle\PointToolsBundle\Repository\UserRepository;
use unreal4u\TelegramAPI\Telegram\Methods\AnswerInlineQuery;
use unreal4u\TelegramAPI\Telegram\Types\Inline\Query;
@ -12,11 +10,6 @@ use unreal4u\TelegramAPI\TgLog;
class InlineQueryProcessor
{
/**
* @var EntityManagerInterface
*/
private $em;
/**
* @var UserRepository
*/
@ -28,12 +21,10 @@ class InlineQueryProcessor
private $client;
public function __construct(EntityManagerInterface $em, TgLog $client)
public function __construct(UserRepository $userRepository, TgLog $client)
{
$this->em = $em;
$this->userRepo = $userRepository;
$this->client = $client;
$this->userRepo = $em->getRepository('SkobkinPointToolsBundle:User');
}
public function process(Query $inlineQuery)
@ -45,7 +36,7 @@ class InlineQueryProcessor
$answerInlineQuery = new AnswerInlineQuery();
$answerInlineQuery->inline_query_id = $inlineQuery->id;
foreach ($this->em->getRepository('SkobkinPointToolsBundle:User')->findUsersLikeLogin($inlineQuery->query) as $user) {
foreach ($this->userRepo->findUsersLikeLogin($inlineQuery->query) as $user) {
$article = new Query\Result\Article();
$article->title = $user->getLogin();