228 lines
8.4 KiB
YAML
228 lines
8.4 KiB
YAML
services:
|
|
# HTTP client for Telegram
|
|
app.http.telegram_client:
|
|
class: GuzzleHttp\Client
|
|
arguments: [{ timeout: 3.0 }]
|
|
tags:
|
|
- { name: csa_guzzle.client }
|
|
|
|
# HTTP client for Point API
|
|
app.http.point_client:
|
|
class: GuzzleHttp\Client
|
|
arguments: [ { base_uri: '%point_base_url%', timeout: 5.0 } ]
|
|
tags:
|
|
- { name: csa_guzzle.client }
|
|
|
|
|
|
# Point API clients
|
|
# Abstract API client with common dependency
|
|
app.point.abstract_api:
|
|
abstract: true
|
|
arguments:
|
|
- '@app.http.point_client'
|
|
- '@logger'
|
|
|
|
app.point.api_user:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\UserApi
|
|
parent: app.point.abstract_api
|
|
arguments:
|
|
- '@doctrine.orm.entity_manager'
|
|
- '@jms_serializer'
|
|
|
|
app.point.api_post:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\PostApi
|
|
parent: app.point.abstract_api
|
|
arguments:
|
|
- '@app.point.post_factory'
|
|
|
|
|
|
# Point subscription manager
|
|
app.point.subscriptions_manager:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\SubscriptionsManager
|
|
arguments:
|
|
- '@event_dispatcher'
|
|
- '@logger'
|
|
- '@app.point.subscription_repository'
|
|
- '@app.point.subscription_record_repository'
|
|
|
|
|
|
# Console commands
|
|
app.point.update_subscribers_command:
|
|
class: Skobkin\Bundle\PointToolsBundle\Command\UpdateSubscriptionsCommand
|
|
calls:
|
|
- [setLogger, ['@logger']]
|
|
- [setEntityManager, ['@doctrine.orm.entity_manager']]
|
|
- [setUserRepository, ['@app.point.user_repository']]
|
|
- [setApiClient, ['@app.point.api_user']]
|
|
- [setApiDelay, ['%point_api_delay%']]
|
|
- [setSubscriptionManager, ['@app.point.subscriptions_manager']]
|
|
tags:
|
|
- { name: console.command }
|
|
|
|
|
|
# Entity repositories as services
|
|
# User
|
|
app.point.user_repository:
|
|
class: Skobkin\Bundle\PointToolsBundle\Repository\UserRepository
|
|
factory: 'doctrine:getRepository'
|
|
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\User']
|
|
# Subscription
|
|
app.point.subscription_repository:
|
|
class: Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionRepository
|
|
factory: 'doctrine:getRepository'
|
|
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\Subscription']
|
|
# Subscription record/event
|
|
app.point.subscription_record_repository:
|
|
class: Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionEventRepository
|
|
factory: 'doctrine:getRepository'
|
|
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\SubscriptionEvent']
|
|
# Post repository
|
|
app.point.post_repository:
|
|
class: Skobkin\Bundle\PointToolsBundle\Repository\Blogs\PostRepository
|
|
factory: 'doctrine:getRepository'
|
|
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Post']
|
|
# Comment repository
|
|
app.point.comment_repository:
|
|
class: Skobkin\Bundle\PointToolsBundle\Repository\Blogs\CommentRepository
|
|
factory: 'doctrine:getRepository'
|
|
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Comment']
|
|
# Tag repository
|
|
app.point.tag_repository:
|
|
class: Skobkin\Bundle\PointToolsBundle\Repository\Blogs\TagRepository
|
|
factory: 'doctrine:getRepository'
|
|
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Tag']
|
|
# File repository
|
|
app.point.file_repository:
|
|
class: Skobkin\Bundle\PointToolsBundle\Repository\Blogs\FileRepository
|
|
factory: 'doctrine:getRepository'
|
|
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\Blogs\File']
|
|
# Telegram Account repository
|
|
app.point.telegram_account_repository:
|
|
class: Skobkin\Bundle\PointToolsBundle\Repository\Telegram\AccountRepository
|
|
factory: 'doctrine:getRepository'
|
|
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\Telegram\Account']
|
|
|
|
|
|
# Factories
|
|
# User factory
|
|
app.point.user_factory:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Factory\UserFactory
|
|
arguments: [ '@app.point.user_repository' ]
|
|
|
|
# Comment factory
|
|
app.point.comment_factory:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Factory\Blogs\CommentFactory
|
|
arguments:
|
|
- '@app.point.comment_repository'
|
|
- '@app.point.post_repository'
|
|
- '@app.point.user_factory'
|
|
|
|
# Tag factory
|
|
app.point.tag_factory:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Factory\Blogs\TagFactory
|
|
arguments: [ '@logger', '@app.point.tag_repository' ]
|
|
|
|
# File factory
|
|
app.point.file_factory:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Factory\Blogs\FileFactory
|
|
arguments: [ '@logger', '@app.point.file_repository' ]
|
|
|
|
# Post factory
|
|
app.point.post_factory:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Factory\Blogs\PostFactory
|
|
arguments:
|
|
- '@logger'
|
|
- '@doctrine.orm.entity_manager'
|
|
- '@app.point.post_repository'
|
|
- '@app.point.user_factory'
|
|
- '@app.point.file_factory'
|
|
- '@app.point.comment_factory'
|
|
- '@app.point.tag_factory'
|
|
|
|
# Telegram accounts factory
|
|
app.telegram.telegram_account_factory:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Factory\Telegram\AccountFactory
|
|
arguments: ['@app.point.telegram_account_repository']
|
|
|
|
|
|
# Custom Markdown parser
|
|
app.point.markdown_parser:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Markdown\PointParser
|
|
arguments: [[], '@router']
|
|
tags:
|
|
- { name: markdown.parser }
|
|
|
|
|
|
# Event listener
|
|
app.event_listener.users_updated:
|
|
class: Skobkin\Bundle\PointToolsBundle\EventListener\UsersUpdatedSubscriber
|
|
arguments: ['@event_dispatcher']
|
|
tags:
|
|
- { name: doctrine.event_subscriber, connection: default }
|
|
|
|
app.event_listener.users_renamed_notifier:
|
|
class: Skobkin\Bundle\PointToolsBundle\EventListener\UsersRenamedListener
|
|
arguments: ['@app.telegram.notifier']
|
|
tags:
|
|
- { name: kernel.event_listener, event: app.users.renamed }
|
|
|
|
app.event_listener.user_subscribers_updated:
|
|
class: Skobkin\Bundle\PointToolsBundle\EventListener\UserSubscribersUpdatedListener
|
|
arguments: ['@app.telegram.notifier']
|
|
tags:
|
|
- { name: kernel.event_listener, event: app.user.subscribers_updated }
|
|
|
|
|
|
# Twig extensions
|
|
app.twig.point_users_extension:
|
|
class: Skobkin\Bundle\PointToolsBundle\Twig\PointUserExtension
|
|
public: false
|
|
arguments: ['@app.point.api_user']
|
|
tags:
|
|
- { name: twig.extension }
|
|
|
|
|
|
# Telegram services
|
|
# API client
|
|
app.telegram.api_client:
|
|
class: unreal4u\TelegramAPI\TgLog
|
|
arguments: ['%telegram_token%', '@logger', '@app.http.telegram_client']
|
|
|
|
# Message sender
|
|
app.telegram.message_sender:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Telegram\MessageSender
|
|
arguments: ['@app.telegram.api_client', '@twig']
|
|
|
|
# User notifier
|
|
app.telegram.notifier:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Telegram\Notifier
|
|
arguments: ['@app.point.telegram_account_repository', '@app.telegram.message_sender']
|
|
|
|
# Common incoming message processor
|
|
app.telegram.update_dispatcher:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Telegram\IncomingUpdateDispatcher
|
|
arguments:
|
|
- '@app.telegram.private_message_processor'
|
|
- '@app.telegram.inline_query_processor'
|
|
|
|
# InlineQuery processor
|
|
app.telegram.inline_query_processor:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Telegram\InlineQueryProcessor
|
|
lazy: true
|
|
arguments: ['@app.point.user_repository', '@app.telegram.api_client']
|
|
|
|
# Private message processor
|
|
app.telegram.private_message_processor:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Telegram\PrivateMessageProcessor
|
|
lazy: true
|
|
arguments:
|
|
- '@doctrine.orm.entity_manager'
|
|
- '@app.point.user_repository'
|
|
- '@app.point.telegram_account_repository'
|
|
- '@app.point.subscription_repository'
|
|
- '@app.point.subscription_record_repository'
|
|
- '@app.telegram.message_sender'
|
|
- '@app.point.api_user'
|
|
- '@app.telegram.telegram_account_factory'
|
|
- '%point_id%'
|