diff --git a/old/src/PointToolsBundle/Service/Factory/Telegram/AccountFactory.php b/old/src/PointToolsBundle/Service/Factory/Telegram/AccountFactory.php deleted file mode 100644 index 82a9f08..0000000 --- a/old/src/PointToolsBundle/Service/Factory/Telegram/AccountFactory.php +++ /dev/null @@ -1,40 +0,0 @@ -accountRepo = $accountRepository; - } - - public function findOrCreateFromMessage(Message $message): Account - { - if (null === $account = $this->accountRepo->findOneBy(['id' => $message->from->id])) { - $account = new Account($message->from->id); - $this->accountRepo->add($account); - } - - // Setting/updating account data - $account->updateFromMessageData( - $message->from->first_name, - $message->from->last_name, - $message->from->username, - $message->chat->id - ); - - return $account; - } -} \ No newline at end of file diff --git a/src/Factory/Telegram/AccountFactory.php b/src/Factory/Telegram/AccountFactory.php new file mode 100644 index 0000000..e81cde4 --- /dev/null +++ b/src/Factory/Telegram/AccountFactory.php @@ -0,0 +1,38 @@ +accountRepository->findOneBy(['id' => $message->from->id])) { + $account = new Account($message->from->id); + $this->accountRepository->save($account); + } + + // Setting/updating account data + $account->updateFromMessageData( + $message->from->first_name, + $message->from->last_name, + $message->from->username, + $message->chat->id + ); + + return $account; + } +}