Merged in symfony_upgrade (pull request #17)

Symfony upgrade
This commit is contained in:
Alexey Eschenko 2017-11-05 02:45:04 +00:00
commit 730ac25744
43 changed files with 840 additions and 762 deletions

View file

@ -16,6 +16,7 @@ class AppKernel extends Kernel
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new Symfony\Bundle\WebServerBundle\WebServerBundle(),
new JMS\SerializerBundle\JMSSerializerBundle(),
new Csa\Bundle\GuzzleBundle\CsaGuzzleBundle(),
new Ob\HighchartsBundle\ObHighchartsBundle(),
@ -40,6 +41,6 @@ class AppKernel extends Kernel
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
$loader->load($this->getProjectDir().'/app/config/config_'.$this->getEnvironment().'.yml');
}
}

View file

@ -18,7 +18,7 @@ framework:
#serializer: { enable_annotations: true }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
resource: "%kernel.project_dir%/app/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
@ -27,7 +27,6 @@ framework:
engines: ['twig']
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
@ -67,7 +66,7 @@ doctrine:
DAY: Skobkin\Bundle\PointToolsBundle\DQL\Day
doctrine_migrations:
dir_name: "%kernel.root_dir%/DoctrineMigrations"
dir_name: "%kernel.project_dir%/app/DoctrineMigrations"
namespace: Application\Migrations
table_name: migration_versions
name: Application Migrations

View file

@ -3,7 +3,7 @@ imports:
framework:
router:
resource: "%kernel.root_dir%/config/routing_dev.yml"
resource: "%kernel.project_dir%/app/config/routing_dev.yml"
strict_requirements: true
profiler: { only_exceptions: false }
@ -18,12 +18,12 @@ monolog:
path: "%kernel.logs_dir%/%kernel.environment%.log"
max_files: 2
level: debug
channels: [!event]
channels: ['!event']
console:
type: console
verbosity_levels:
VERBOSITY_NORMAL: WARNING
channels: [!event, !doctrine]
channels: ['!event', '!doctrine']
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:

View file

@ -5,10 +5,10 @@ imports:
doctrine:
dbal:
# todo move to new environment variables: https://symfony.com/blog/new-in-symfony-3-2-runtime-environment-variables
dbname: "%test_database_name%"
port: "%test_database_port%"
user: "%test_database_user%"
password: "%test_database_password%"
dbname: "%env(SYMFONY__TEST_DATABASE_NAME)%"
port: "%env(SYMFONY__TEST_DATABASE_PORT)%"
user: "%env(SYMFONY__TEST_DATABASE_USER)%"
password: "%env(SYMFONY__TEST_DATABASE_PASSWORD)%"
framework:
test: ~

View file

@ -1,9 +1,200 @@
# Learn more about services, parameters and containers at
# http://symfony.com/doc/current/book/service_container.html
parameters:
# parameter_name: value
services:
# service_name:
# class: AppBundle\Directory\ClassName
# arguments: ["@another_service_name", "plain_value", "%parameter_name%"]
_defaults:
autowire: true
autoconfigure: true
public: false
Skobkin\Bundle\PointToolsBundle\:
resource: '../../src/Skobkin/Bundle/PointToolsBundle/*'
exclude: '../../src/Skobkin/Bundle/PointToolsBundle/{DataFixtures,DependencyInjection,DQL,DTO,Entity,Exception,Repository,Twig}'
# HTTP clients
# Default
GuzzleHttp\ClientInterface:
alias: app.http.point_client
# 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
# User
Skobkin\Bundle\PointToolsBundle\Service\Api\UserApi:
tags:
- { name: monolog.logger, channel: point_user_api }
# Post
Skobkin\Bundle\PointToolsBundle\Service\Api\PostApi:
tags:
- { name: monolog.logger, channel: point_post_api }
# Point subscription manager
Skobkin\Bundle\PointToolsBundle\Service\SubscriptionsManager:
# TODO deal with autowire for EventDispatcherInterface
tags:
- { name: monolog.logger, channel: subscribers_update }
# Controllers
Skobkin\Bundle\PointToolsBundle\Controller\:
resource: '../../src/Skobkin/Bundle/PointToolsBundle/Controller'
public: true
tags: ['controller.service_arguments']
Skobkin\Bundle\PointToolsBundle\Controller\MainController:
arguments:
$appUserId: '%point_id%'
$appUserLogin: '%point_login%'
Skobkin\Bundle\PointToolsBundle\Controller\Api\CrawlerController:
arguments:
$crawlerToken: '%crawler_token%'
Skobkin\Bundle\PointToolsBundle\Controller\Telegram\WebHookController:
arguments:
$telegramToken: '%telegram_token%'
$debug: '%kernel.debug%'
# Console commands
# @todo https://github.com/symfony/symfony/blob/3.4/UPGRADE-3.4.md#httpkernel
# Subsribers update
Skobkin\Bundle\PointToolsBundle\Command\UpdateSubscriptionsCommand:
arguments:
$apiDelay: '%point_api_delay%'
$appUserId: '%point_id%'
tags:
- { name: console.command }
- { name: monolog.logger, channel: subscribers_update }
# Privacy update
Skobkin\Bundle\PointToolsBundle\Command\UpdateUsersPrivacyCommand:
arguments:
$apiDelay: '%point_api_delay%'
$appUserId: '%point_id%'
tags:
- { name: console.command }
- { name: monolog.logger, channel: privacy_update }
# Restore users removed by error
Skobkin\Bundle\PointToolsBundle\Command\RestoreRemovedUsersCommand:
arguments:
$apiDelay: '%point_api_delay%'
tags:
- { name: console.command }
# Webhook management
Skobkin\Bundle\PointToolsBundle\Command\TelegramWebHookCommand:
arguments:
$telegramToken: '%telegram_token%'
$telegramWebhookMaxConnections: '%telegram_max_connections%'
tags: [{ name: console.command }]
# Send message
Skobkin\Bundle\PointToolsBundle\Command\TelegramSendMessageCommand:
arguments:
$logChatId: '%telegram_log_chat_id%'
tags: [{ name: console.command }]
# Entity repositories as services
# User
Skobkin\Bundle\PointToolsBundle\Repository\UserRepository:
factory: 'doctrine:getRepository'
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\User']
# Subscription
Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionRepository:
factory: 'doctrine:getRepository'
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\Subscription']
# Subscription record/event
Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionEventRepository:
factory: 'doctrine:getRepository'
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\SubscriptionEvent']
# Subscription record/event
Skobkin\Bundle\PointToolsBundle\Repository\UserRenameEventRepository:
factory: 'doctrine:getRepository'
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\UserRenameEvent']
# Post repository
Skobkin\Bundle\PointToolsBundle\Repository\Blogs\PostRepository:
factory: 'doctrine:getRepository'
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Post']
# Comment repository
Skobkin\Bundle\PointToolsBundle\Repository\Blogs\CommentRepository:
factory: 'doctrine:getRepository'
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Comment']
# Tag repository
Skobkin\Bundle\PointToolsBundle\Repository\Blogs\TagRepository:
factory: 'doctrine:getRepository'
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Tag']
# File repository
Skobkin\Bundle\PointToolsBundle\Repository\Blogs\FileRepository:
factory: 'doctrine:getRepository'
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\Blogs\File']
# Telegram Account repository
Skobkin\Bundle\PointToolsBundle\Repository\Telegram\AccountRepository:
factory: 'doctrine:getRepository'
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\Telegram\Account']
# Custom Markdown parser
app.point.markdown_parser:
class: Skobkin\Bundle\PointToolsBundle\Service\Markdown\PointParser
arguments: [[], '@router']
tags:
- { name: markdown.parser }
# Event listeners
# User name changed in Doctrine
Skobkin\Bundle\PointToolsBundle\EventListener\UsersUpdatedSubscriber:
tags:
- { name: doctrine.event_subscriber, connection: default }
# User renaming
Skobkin\Bundle\PointToolsBundle\EventListener\UsersRenamedListener:
tags:
- { name: kernel.event_listener, event: app.users.renamed }
# User subscribers updated
Skobkin\Bundle\PointToolsBundle\EventListener\UserSubscribersUpdatedListener:
tags:
- { name: kernel.event_listener, event: app.user.subscribers_updated }
# Twig extensions
Skobkin\Bundle\PointToolsBundle\Twig\PointUrlExtension:
arguments:
$pointDomain: '%point_domain%'
$pointScheme: '%point_scheme%'
$pointBaseUrl: '%point_base_url%'
# Telegram services
# Bot API client
unreal4u\TelegramAPI\TgLog:
arguments:
$client: '@app.http.telegram_client'
$botToken: '%telegram_token%'
# Logger API client
app.telegram.logger_client:
class: unreal4u\TelegramAPI\TgLog
arguments:
$botToken: '%telegram_token%'
$logger: null
$client: '@app.http.telegram_client'
# Monolog handler
unreal4u\MonologHandler:
arguments:
$chatId: '%telegram_log_chat_id%'
$level: 'error'
# Private message processor
Skobkin\Bundle\PointToolsBundle\Service\Telegram\PrivateMessageProcessor:
arguments:
$appUserId: '%point_id%'

View file

@ -1,10 +1,10 @@
# Point-Tools
# Subscriptions
# Primary subscribers
*/10 * * * * flock -n /tmp/point_tools_sub_update.lock timeout 300 /usr/bin/php /var/www/point-tools/current/app/console point:update:subscriptions --env=prod
# App users
0 0 * * * flock -n /tmp/point_tools_sub_update_all.lock timeout 3600 /usr/bin/php /var/www/point-tools/current/app/console point:update:subscriptions --all-users --env=prod
*/10 * * * * flock -n /tmp/point_tools_sub_update.lock timeout 300 /usr/bin/php /var/www/point.skobk.in/current/app/console point:update:subscriptions --env=prod
# All users
0 0 * * * flock -n /tmp/point_tools_sub_update_all.lock timeout 3600 /usr/bin/php /var/www/point.skobk.in/current/app/console point:update:subscriptions --all-users --env=prod
# Privacy
0 1 * * * flock -n /tmp/point_tools_privacy_update_all.lock timeout 3600 /usr/bin/php /var/www/point.skobk.in/current/app/console point:update:privacy --all-users --env=prod
# Other
# Restore users deleted by mistake
0 0 */7 * * flock -n /tmp/point_tools_restore_users.lock timeout 300 /usr/bin/php /var/www/point-tools/current/app/console point:users:restore --env=prod
0 0 */7 * * flock -n /tmp/point_tools_restore_users.lock timeout 300 /usr/bin/php /var/www/point.skobk.in/current/app/console point:users:restore --env=prod

View file

@ -8,29 +8,32 @@
"classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
},
"autoload-dev": {
"psr-4": { "Tests\\": "tests/" }
"psr-4": { "Tests\\": "tests/" },
"files": [ "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php" ]
},
"require": {
"php": ">=7.0.0",
"symfony/symfony": "3.2.*",
"php": ">=7.1.0",
"symfony/symfony": "3.4.x-dev",
"doctrine/orm": "^2.5",
"doctrine/annotations": "^1.3.0",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.2",
"doctrine/doctrine-migrations-bundle": "^1.0",
"twig/twig": "^2.0",
"twig/extensions": "~1.0",
"symfony/swiftmailer-bundle": "^2.3.10",
"symfony/monolog-bundle": "^3.0.2",
"sensio/distribution-bundle": "^5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"symfony/swiftmailer-bundle": "^2.6.4",
"symfony/monolog-bundle": "^3.1.0",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^5.0.0",
"incenteev/composer-parameter-handler": "^2.0",
"ob/highcharts-bundle": "^1.2",
"jms/serializer-bundle": "^1.1",
"knplabs/knp-markdown-bundle": "^1.4",
"knplabs/knp-paginator-bundle": "^2.5",
"unreal4u/telegram-api": "^2.2",
"csa/guzzle-bundle": "^2.1",
"unreal4u/monolog-telegram": "^0.2.0"
"csa/guzzle-bundle": "3.0.x-dev",
"unreal4u/monolog-telegram": "^0.2.0",
"symfony/web-server-bundle": "^3.3"
},
"require-dev": {
"sensio/generator-bundle": "^3.0",
@ -60,12 +63,13 @@
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-tests-dir": "tests",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "3.2-dev"
"dev-master": "3.4-dev"
}
}
}

416
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "88274224cc9dfe36d847acf69d5924d8",
"content-hash": "71a9b3759d77d9b4770ae1aedcda61c6",
"packages": [
{
"name": "composer/ca-bundle",
@ -67,24 +67,24 @@
},
{
"name": "csa/guzzle-bundle",
"version": "v2.2.1",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/csarrazi/CsaGuzzleBundle.git",
"reference": "bbe54641ad6171dc562034f2824f7c18cec80ca4"
"reference": "6b10e6f318ea6a20fa32cfcda471bd0bbebcdb96"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/csarrazi/CsaGuzzleBundle/zipball/bbe54641ad6171dc562034f2824f7c18cec80ca4",
"reference": "bbe54641ad6171dc562034f2824f7c18cec80ca4",
"url": "https://api.github.com/repos/csarrazi/CsaGuzzleBundle/zipball/6b10e6f318ea6a20fa32cfcda471bd0bbebcdb96",
"reference": "6b10e6f318ea6a20fa32cfcda471bd0bbebcdb96",
"shasum": ""
},
"require": {
"guzzlehttp/guzzle": "^6.1",
"php": ">=5.5.0",
"symfony/dependency-injection": "^2.7|^3.0",
"symfony/filesystem": "^2.7|^3.0",
"symfony/framework-bundle": "^2.7|^3.0",
"php": ">=5.6.0",
"symfony/dependency-injection": "^2.7|^3.0|^4.0",
"symfony/filesystem": "^2.7|^3.0|^4.0",
"symfony/framework-bundle": "^2.7|^3.0|^4.0",
"twig/twig": "^1.12|^2.0"
},
"require-dev": {
@ -92,8 +92,9 @@
"namshi/cuzzle": "^2.0",
"phpunit/phpunit": "^4.8",
"psr/cache": "^1.0",
"symfony/phpunit-bridge": "^2.7|^3.0",
"symfony/web-profiler-bundle": "^2.3|^3.0"
"symfony/phpunit-bridge": "^2.7|^3.0|^4.0",
"symfony/stopwatch": "^2.7|^3.0|^4.0",
"symfony/web-profiler-bundle": "^2.3|^3.0|^4.0"
},
"suggest": {
"doctrine/cache": "Allows caching of responses",
@ -124,7 +125,7 @@
}
],
"description": "A bundle integrating GuzzleHttp >= 4.0",
"time": "2017-03-27T07:49:26+00:00"
"time": "2017-10-29T11:18:46+00:00"
},
{
"name": "doctrine/annotations",
@ -652,31 +653,31 @@
},
{
"name": "doctrine/doctrine-migrations-bundle",
"version": "v1.2.1",
"version": "v1.3.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/DoctrineMigrationsBundle.git",
"reference": "6276139e0b913a4e5120fc36bb5b0eae8ac549bc"
"reference": "a9e506369f931351a2a6dd2aef588a822802b1b7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/DoctrineMigrationsBundle/zipball/6276139e0b913a4e5120fc36bb5b0eae8ac549bc",
"reference": "6276139e0b913a4e5120fc36bb5b0eae8ac549bc",
"url": "https://api.github.com/repos/doctrine/DoctrineMigrationsBundle/zipball/a9e506369f931351a2a6dd2aef588a822802b1b7",
"reference": "a9e506369f931351a2a6dd2aef588a822802b1b7",
"shasum": ""
},
"require": {
"doctrine/doctrine-bundle": "~1.0",
"doctrine/migrations": "^1.1",
"php": ">=5.4.0",
"symfony/framework-bundle": "~2.3|~3.0"
"symfony/framework-bundle": "~2.7|~3.3|~4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.8"
"phpunit/phpunit": "^4.8.36"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "1.2-dev"
"dev-master": "1.3-dev"
}
},
"autoload": {
@ -709,7 +710,7 @@
"migrations",
"schema"
],
"time": "2016-12-05T18:36:37+00:00"
"time": "2017-11-01T09:13:26+00:00"
},
{
"name": "doctrine/inflector",
@ -1036,6 +1037,60 @@
],
"time": "2017-10-23T18:21:04+00:00"
},
{
"name": "fig/link-util",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/link-util.git",
"reference": "1a07821801a148be4add11ab0603e4af55a72fac"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/link-util/zipball/1a07821801a148be4add11ab0603e4af55a72fac",
"reference": "1a07821801a148be4add11ab0603e4af55a72fac",
"shasum": ""
},
"require": {
"php": ">=5.5.0",
"psr/link": "~1.0@dev"
},
"require-dev": {
"phpunit/phpunit": "^5.1",
"squizlabs/php_codesniffer": "^2.3.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Fig\\Link\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common utility implementations for HTTP links",
"keywords": [
"http",
"http-link",
"link",
"psr",
"psr-13",
"rest"
],
"time": "2016-10-17T18:31:11+00:00"
},
{
"name": "guzzlehttp/guzzle",
"version": "6.3.0",
@ -2249,6 +2304,55 @@
],
"time": "2016-08-06T20:24:11+00:00"
},
{
"name": "psr/container",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Container\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common Container Interface (PHP FIG PSR-11)",
"homepage": "https://github.com/php-fig/container",
"keywords": [
"PSR-11",
"container",
"container-interface",
"container-interop",
"psr"
],
"time": "2017-02-14T16:28:37+00:00"
},
{
"name": "psr/http-message",
"version": "1.0.1",
@ -2299,6 +2403,55 @@
],
"time": "2016-08-06T14:39:51+00:00"
},
{
"name": "psr/link",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/link.git",
"reference": "eea8e8662d5cd3ae4517c9b864493f59fca95562"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/link/zipball/eea8e8662d5cd3ae4517c9b864493f59fca95562",
"reference": "eea8e8662d5cd3ae4517c9b864493f59fca95562",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Link\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interfaces for HTTP links",
"keywords": [
"http",
"http-link",
"link",
"psr",
"psr-13",
"rest"
],
"time": "2016-10-28T16:06:13+00:00"
},
{
"name": "psr/log",
"version": "1.0.2",
@ -2346,6 +2499,54 @@
],
"time": "2016-10-10T12:19:37+00:00"
},
{
"name": "psr/simple-cache",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/simple-cache.git",
"reference": "753fa598e8f3b9966c886fe13f370baa45ef0e24"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/753fa598e8f3b9966c886fe13f370baa45ef0e24",
"reference": "753fa598e8f3b9966c886fe13f370baa45ef0e24",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\SimpleCache\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interfaces for simple caching",
"keywords": [
"cache",
"caching",
"psr",
"psr-16",
"simple-cache"
],
"time": "2017-01-02T13:31:39+00:00"
},
{
"name": "sensio/distribution-bundle",
"version": "v5.0.21",
@ -2400,38 +2601,37 @@
},
{
"name": "sensio/framework-extra-bundle",
"version": "v3.0.28",
"version": "v5.0.1",
"source": {
"type": "git",
"url": "https://github.com/sensiolabs/SensioFrameworkExtraBundle.git",
"reference": "65eadf9e3fd5c47eee7986b306a5aed8affe6496"
"reference": "9e3fa14aa959f703961bc9e4ab00110d617bcfdd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sensiolabs/SensioFrameworkExtraBundle/zipball/65eadf9e3fd5c47eee7986b306a5aed8affe6496",
"reference": "65eadf9e3fd5c47eee7986b306a5aed8affe6496",
"url": "https://api.github.com/repos/sensiolabs/SensioFrameworkExtraBundle/zipball/9e3fa14aa959f703961bc9e4ab00110d617bcfdd",
"reference": "9e3fa14aa959f703961bc9e4ab00110d617bcfdd",
"shasum": ""
},
"require": {
"doctrine/common": "~2.2",
"symfony/dependency-injection": "~2.3|~3.0",
"symfony/framework-bundle": "~2.3|~3.0|~4.0"
"doctrine/common": "^2.2",
"symfony/config": "^3.3|^4.0",
"symfony/dependency-injection": "^3.3|^4.0",
"symfony/framework-bundle": "^3.3|^4.0",
"symfony/http-kernel": "^3.3|^4.0"
},
"require-dev": {
"doctrine/doctrine-bundle": "~1.5",
"doctrine/orm": "~2.4,>=2.4.5",
"symfony/asset": "~2.7|~3.0|~4.0",
"symfony/browser-kit": "~2.3|~3.0|~4.0",
"symfony/dom-crawler": "~2.3|~3.0|~4.0",
"symfony/expression-language": "~2.4|~3.0|~4.0",
"symfony/finder": "~2.3|~3.0|~4.0",
"symfony/phpunit-bridge": "~3.2|~4.0",
"symfony/psr-http-message-bridge": "^0.3|^1.0",
"symfony/security-bundle": "~2.4|~3.0|~4.0",
"symfony/templating": "~2.3|~3.0|~4.0",
"symfony/translation": "~2.3|~3.0|~4.0",
"symfony/twig-bundle": "~2.3|~3.0|~4.0",
"symfony/yaml": "~2.3|~3.0|~4.0",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
"symfony/browser-kit": "^3.3|^4.0",
"symfony/dom-crawler": "^3.3|^4.0",
"symfony/expression-language": "^3.3|^4.0",
"symfony/finder": "^3.3|^4.0",
"symfony/phpunit-bridge": "^3.3|^4.0",
"symfony/psr-http-message-bridge": "^0.3",
"symfony/security-bundle": "^3.3|^4.0",
"symfony/twig-bundle": "^3.3|^4.0",
"symfony/yaml": "^3.3|^4.0",
"twig/twig": "~1.12|~2.0",
"zendframework/zend-diactoros": "^1.3"
},
@ -2443,7 +2643,7 @@
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
"dev-master": "4.0.x-dev"
}
},
"autoload": {
@ -2466,7 +2666,7 @@
"annotations",
"controllers"
],
"time": "2017-10-12T17:37:20+00:00"
"time": "2017-10-12T17:37:44+00:00"
},
{
"name": "sensiolabs/security-checker",
@ -2627,6 +2827,62 @@
],
"time": "2017-09-26T03:17:02+00:00"
},
{
"name": "symfony/polyfill-apcu",
"version": "v1.6.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-apcu.git",
"reference": "04f62674339602def515bff4bc6901fc1d4951e8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-apcu/zipball/04f62674339602def515bff4bc6901fc1d4951e8",
"reference": "04f62674339602def515bff4bc6901fc1d4951e8",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.6-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Apcu\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting apcu_* functions to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"apcu",
"compatibility",
"polyfill",
"portable",
"shim"
],
"time": "2017-10-11T12:05:26+00:00"
},
{
"name": "symfony/polyfill-intl-icu",
"version": "v1.6.0",
@ -2972,38 +3228,46 @@
},
{
"name": "symfony/symfony",
"version": "v3.2.13",
"version": "3.4.x-dev",
"source": {
"type": "git",
"url": "https://github.com/symfony/symfony.git",
"reference": "e1aabd6f50fb4586b330f9ac54b4bcdf7352a0f8"
"reference": "e973c247c8acd032a5ee72418452c3a255d5e321"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/symfony/zipball/e1aabd6f50fb4586b330f9ac54b4bcdf7352a0f8",
"reference": "e1aabd6f50fb4586b330f9ac54b4bcdf7352a0f8",
"url": "https://api.github.com/repos/symfony/symfony/zipball/e973c247c8acd032a5ee72418452c3a255d5e321",
"reference": "e973c247c8acd032a5ee72418452c3a255d5e321",
"shasum": ""
},
"require": {
"doctrine/common": "~2.4",
"ext-xml": "*",
"php": ">=5.5.9",
"fig/link-util": "^1.0",
"php": "^5.5.9|>=7.0.8",
"psr/cache": "~1.0",
"psr/container": "^1.0",
"psr/link": "^1.0",
"psr/log": "~1.0",
"psr/simple-cache": "^1.0",
"symfony/polyfill-apcu": "~1.1",
"symfony/polyfill-intl-icu": "~1.0",
"symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php56": "~1.0",
"symfony/polyfill-php70": "~1.0",
"symfony/polyfill-php70": "~1.6",
"symfony/polyfill-util": "~1.0",
"twig/twig": "~1.34|~2.4"
"twig/twig": "^1.35|^2.4.4"
},
"conflict": {
"phpdocumentor/reflection-docblock": "<3.0||>=3.2.0",
"phpdocumentor/type-resolver": "<0.2.0",
"phpdocumentor/reflection-docblock": "<3.0||>=3.2.0,<3.2.2",
"phpdocumentor/type-resolver": "<0.2.1",
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0"
},
"provide": {
"psr/cache-implementation": "1.0"
"psr/cache-implementation": "1.0",
"psr/container-implementation": "1.0",
"psr/log-implementation": "1.0",
"psr/simple-cache-implementation": "1.0"
},
"replace": {
"symfony/asset": "self.version",
@ -3018,6 +3282,7 @@
"symfony/dependency-injection": "self.version",
"symfony/doctrine-bridge": "self.version",
"symfony/dom-crawler": "self.version",
"symfony/dotenv": "self.version",
"symfony/event-dispatcher": "self.version",
"symfony/expression-language": "self.version",
"symfony/filesystem": "self.version",
@ -3029,6 +3294,7 @@
"symfony/inflector": "self.version",
"symfony/intl": "self.version",
"symfony/ldap": "self.version",
"symfony/lock": "self.version",
"symfony/monolog-bridge": "self.version",
"symfony/options-resolver": "self.version",
"symfony/process": "self.version",
@ -3050,12 +3316,15 @@
"symfony/twig-bundle": "self.version",
"symfony/validator": "self.version",
"symfony/var-dumper": "self.version",
"symfony/web-link": "self.version",
"symfony/web-profiler-bundle": "self.version",
"symfony/web-server-bundle": "self.version",
"symfony/workflow": "self.version",
"symfony/yaml": "self.version"
},
"require-dev": {
"cache/integration-tests": "dev-master",
"doctrine/annotations": "~1.0",
"doctrine/cache": "~1.6",
"doctrine/data-fixtures": "1.0.*",
"doctrine/dbal": "~2.4",
@ -3064,17 +3333,15 @@
"egulias/email-validator": "~1.2,>=1.2.8|~2.0",
"monolog/monolog": "~1.11",
"ocramius/proxy-manager": "~0.4|~1.0|~2.0",
"phpdocumentor/reflection-docblock": "^3.0",
"phpdocumentor/reflection-docblock": "^3.0|^4.0",
"predis/predis": "~1.0",
"sensio/framework-extra-bundle": "^3.0.2",
"symfony/phpunit-bridge": "~3.2",
"symfony/polyfill-apcu": "~1.1",
"symfony/security-acl": "~2.8|~3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.2-dev"
"dev-master": "3.4-dev"
}
},
"autoload": {
@ -3112,7 +3379,7 @@
"keywords": [
"framework"
],
"time": "2017-08-01T09:40:44+00:00"
"time": "2017-11-03T14:14:19+00:00"
},
{
"name": "twig/extensions",
@ -3713,22 +3980,22 @@
},
{
"name": "phpdocumentor/reflection-docblock",
"version": "3.1.1",
"version": "4.1.1",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
"reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e"
"reference": "2d3d238c433cf69caeb4842e97a3223a116f94b2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/8331b5efe816ae05461b7ca1e721c01b46bafb3e",
"reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/2d3d238c433cf69caeb4842e97a3223a116f94b2",
"reference": "2d3d238c433cf69caeb4842e97a3223a116f94b2",
"shasum": ""
},
"require": {
"php": ">=5.5",
"php": "^7.0",
"phpdocumentor/reflection-common": "^1.0@dev",
"phpdocumentor/type-resolver": "^0.2.0",
"phpdocumentor/type-resolver": "^0.4.0",
"webmozart/assert": "^1.0"
},
"require-dev": {
@ -3754,24 +4021,24 @@
}
],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
"time": "2016-09-30T07:12:33+00:00"
"time": "2017-08-30T18:51:59+00:00"
},
{
"name": "phpdocumentor/type-resolver",
"version": "0.2.1",
"version": "0.4.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
"reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb"
"reference": "9c977708995954784726e25d0cd1dddf4e65b0f7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb",
"reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7",
"reference": "9c977708995954784726e25d0cd1dddf4e65b0f7",
"shasum": ""
},
"require": {
"php": ">=5.5",
"php": "^5.5 || ^7.0",
"phpdocumentor/reflection-common": "^1.0"
},
"require-dev": {
@ -3801,7 +4068,7 @@
"email": "me@mikevanriel.com"
}
],
"time": "2016-11-25T06:54:22+00:00"
"time": "2017-07-14T14:27:02+00:00"
},
{
"name": "phpspec/prophecy",
@ -4938,11 +5205,14 @@
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"stability-flags": {
"symfony/symfony": 20,
"csa/guzzle-bundle": 20
},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=7.0.0"
"php": ">=7.1.0"
},
"platform-dev": []
}

View file

@ -5,11 +5,12 @@
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="app/autoload.php"
bootstrap="vendor/autoload.php"
convertNoticesToExceptions="false"
>
<php>
<ini name="error_reporting" value="-1" />
<server name="KERNEL_DIR" value="app/" />
<server name="KERNEL_CLASS" value="AppKernel" />
</php>
<testsuites>

View file

@ -2,11 +2,10 @@
namespace Skobkin\Bundle\PointToolsBundle\Command;
use Doctrine\ORM\{EntityManager, EntityManagerInterface};
use Skobkin\Bundle\PointToolsBundle\Entity\User;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\{InputInterface, InputArgument, InputOption};
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
@ -19,8 +18,18 @@ use Symfony\Component\Filesystem\Filesystem;
* WHERE u.id <> (-1)
* ) TO '/tmp/point_users.csv' WITH HEADER DELIMITER '|' CSV;
*/
class ImportUsersCommand extends ContainerAwareCommand
class ImportUsersCommand extends Command
{
/** @var EntityManager */
private $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
parent::__construct();
}
protected function configure()
{
$this
@ -48,7 +57,6 @@ class ImportUsersCommand extends ContainerAwareCommand
protected function execute(InputInterface $input, OutputInterface $output)
{
$em = $this->getContainer()->get('doctrine.orm.entity_manager');
$fs = new Filesystem();
$fileName = $input->getArgument('file');
@ -80,9 +88,9 @@ class ImportUsersCommand extends ContainerAwareCommand
$user = new User($row[0], $createdAt, $row[1], $row[2]);
if (!$input->getOption('check-only')) {
$em->persist($user);
$em->flush($user);
$em->detach($user);
$this->em->persist($user);
$this->em->flush($user);
$this->em->detach($user);
}
if (OutputInterface::VERBOSITY_VERBOSE === $output->getVerbosity()) {

View file

@ -14,31 +14,22 @@ use Symfony\Component\Console\Output\OutputInterface;
class RestoreRemovedUsersCommand extends Command
{
/**
* @var LoggerInterface
*/
/** @var LoggerInterface */
private $logger;
/**
* @var EntityManagerInterface
*/
/** @var EntityManagerInterface */
private $em;
/**
* @var UserRepository
*/
/** @var UserRepository */
private $userRepo;
/**
* @var UserApi
*/
/** @var UserApi */
private $userApi;
/**
* @var int
*/
/** @var int */
private $delay;
public function __construct(LoggerInterface $logger, EntityManagerInterface $em, UserRepository $userRepo, UserApi $userApi, int $delay)
public function __construct(LoggerInterface $logger, EntityManagerInterface $em, UserRepository $userRepo, UserApi $userApi, int $apiDelay)
{
parent::__construct();
@ -46,7 +37,7 @@ class RestoreRemovedUsersCommand extends Command
$this->em = $em;
$this->userRepo = $userRepo;
$this->userApi = $userApi;
$this->delay = $delay;
$this->delay = $apiDelay;
}
/**

View file

@ -3,35 +3,24 @@
namespace Skobkin\Bundle\PointToolsBundle\Command;
use Skobkin\Bundle\PointToolsBundle\Service\Telegram\MessageSender;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\{InputArgument, InputInterface, InputOption};
use Symfony\Component\Console\Output\OutputInterface;
class TelegramSendMessageCommand extends ContainerAwareCommand
class TelegramSendMessageCommand extends Command
{
/**
* @var MessageSender
*/
/** @var MessageSender */
private $messenger;
/**
* @var int
*/
/** @var int */
private $logChatId;
public function setMessenger(MessageSender $messenger): void
public function __construct(MessageSender $messenger, int $logChatId)
{
$this->messenger = $messenger;
}
/**
* @param int $logChatId
*/
public function setLogChatId(int $logChatId): void
{
$this->logChatId = $logChatId;
parent::__construct();
}
/**

View file

@ -2,63 +2,42 @@
namespace Skobkin\Bundle\PointToolsBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Bundle\FrameworkBundle\Routing\Router;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\{InputArgument, InputInterface};
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use unreal4u\TelegramAPI\Telegram\Methods\DeleteWebhook;
use unreal4u\TelegramAPI\Telegram\Methods\SetWebhook;
use unreal4u\TelegramAPI\Telegram\Methods\{DeleteWebhook, SetWebhook};
use unreal4u\TelegramAPI\TgLog;
/**
* Sets or deletes Telegram bot Web-Hook
* @see https://core.telegram.org/bots/api#setwebhook
*/
class TelegramWebHookCommand extends ContainerAwareCommand
class TelegramWebHookCommand extends Command
{
private const MODE_SET = 'set';
private const MODE_DELETE = 'delete';
/**
* @var TgLog
*/
/** @var TgLog */
private $client;
/**
* @var Router
*/
/** @var UrlGeneratorInterface */
private $router;
/**
* @var string
*/
/** @var string */
private $token;
/**
* @var int
*/
/** @var int */
private $maxConnections;
public function setClient(TgLog $client): void
public function __construct(TgLog $client, UrlGeneratorInterface $router, string $telegramToken, int $telegramWebhookMaxConnections)
{
parent::__construct();
$this->client = $client;
}
public function setRouter(Router $router): void
{
$this->router = $router;
}
public function setToken(string $token): void
{
$this->token = $token;
}
public function setMaxConnections(int $maxConnections)
{
$this->maxConnections = $maxConnections;
$this->token = $telegramToken;
$this->maxConnections = $telegramWebhookMaxConnections;
}
/**

View file

@ -8,7 +8,7 @@ use Skobkin\Bundle\PointToolsBundle\Entity\{Subscription, User};
use Skobkin\Bundle\PointToolsBundle\Exception\Api\UserNotFoundException;
use Skobkin\Bundle\PointToolsBundle\Repository\UserRepository;
use Skobkin\Bundle\PointToolsBundle\Service\{SubscriptionsManager, Api\UserApi};
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\{InputInterface, InputOption};
use Symfony\Component\Console\Output\OutputInterface;
@ -16,51 +16,33 @@ use Symfony\Component\Console\Output\OutputInterface;
/**
* @todo https://symfony.com/doc/current/console/lockable_trait.html
*/
class UpdateSubscriptionsCommand extends ContainerAwareCommand
class UpdateSubscriptionsCommand extends Command
{
/**
* @var EntityManagerInterface
*/
/** @var EntityManagerInterface */
private $em;
/**
* @var LoggerInterface
*/
/** @var LoggerInterface */
private $logger;
/**
* @var UserRepository
*/
/** @var UserRepository */
private $userRepo;
/**
* @var InputInterface
*/
/** @var InputInterface */
private $input;
/**
* @var UserApi
*/
/** @var UserApi */
private $api;
/**
* @var int
*/
/** @var int */
private $apiDelay = 500000;
/**
* @var int
*/
/** @var int */
private $appUserId;
/**
* @var SubscriptionsManager
*/
/** @var SubscriptionsManager */
private $subscriptionManager;
/**
* @var ProgressBar
*/
/** @var ProgressBar */
private $progress;
public function __construct(

View file

@ -8,12 +8,12 @@ use Skobkin\Bundle\PointToolsBundle\Entity\{Subscription, User};
use Skobkin\Bundle\PointToolsBundle\Exception\Api\{ForbiddenException, UserNotFoundException};
use Skobkin\Bundle\PointToolsBundle\Repository\UserRepository;
use Skobkin\Bundle\PointToolsBundle\Service\Api\UserApi;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\{InputInterface, InputOption};
use Symfony\Component\Console\Output\OutputInterface;
class UpdateUsersPrivacyCommand extends ContainerAwareCommand
class UpdateUsersPrivacyCommand extends Command
{
/** @var EntityManagerInterface */
private $em;

View file

@ -2,10 +2,10 @@
namespace Skobkin\Bundle\PointToolsBundle\Controller\Api;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
class AbstractApiController extends Controller
class AbstractApiController extends AbstractController
{
protected function createSuccessResponse($data, int $code = 200): Response
{

View file

@ -2,33 +2,37 @@
namespace Skobkin\Bundle\PointToolsBundle\Controller\Api;
use Doctrine\ORM\EntityManagerInterface;
use JMS\Serializer\SerializerInterface;
use Skobkin\Bundle\PointToolsBundle\DTO\Api\PostsPage;
use Skobkin\Bundle\PointToolsBundle\Service\Factory\Blogs\PostFactory;
use Symfony\Component\HttpFoundation\{Request, Response};
class CrawlerController extends AbstractApiController
{
public function receiveAllPageAction(Request $request): Response
/** @var string */
private $crawlerToken;
public function __construct(string $crawlerToken)
{
$this->crawlerToken = $crawlerToken;
}
public function receiveAllPageAction(Request $request, SerializerInterface $serializer, PostFactory $postFactory, EntityManagerInterface $em): Response
{
$remoteToken = $request->request->get('token');
$localToken = $this->getParameter('crawler_token');
if (!$localToken || ($localToken !== $remoteToken)) {
if (!$this->crawlerToken || ($this->crawlerToken !== $remoteToken)) {
return $this->createErrorResponse('Token error. Please check it in crawler and API parameters.', Response::HTTP_FORBIDDEN);
}
$json = $request->request->get('json');
$serializer = $this->get('jms_serializer');
$page = $serializer->deserialize($json, PostsPage::class, 'json');
/** @var PostFactory $factory */
$factory = $this->get('app.point.post_factory');
$continue = $factory->createFromPageDTO($page);
$continue = $postFactory->createFromPageDTO($page);
$this->getDoctrine()->getManager()->flush();
$em->flush();
return $this->createSuccessResponse([
'continue' => $continue,

View file

@ -3,21 +3,21 @@
namespace Skobkin\Bundle\PointToolsBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Skobkin\Bundle\PointToolsBundle\Entity\SubscriptionEvent;
use Skobkin\Bundle\PointToolsBundle\Entity\User;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Skobkin\Bundle\PointToolsBundle\Entity\{SubscriptionEvent, User};
use Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionEventRepository;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
class ApiController extends Controller
class ApiController
{
/**
* Returns last user subscribers log
*
* @ParamConverter("user", class="SkobkinPointToolsBundle:User")
*/
public function lastUserSubscribersByIdAction(User $user): Response
public function lastUserSubscribersByIdAction(User $user, SubscriptionEventRepository $subscriptionEventRepository): Response
{
$qb = $this->getDoctrine()->getRepository('SkobkinPointToolsBundle:SubscriptionEvent')->createQueryBuilder('se');
$qb = $subscriptionEventRepository->createQueryBuilder('se');
$qb
->select(['se', 'sub'])
->innerJoin('se.subscriber', 'sub')
@ -38,6 +38,6 @@ class ApiController extends Controller
];
}
return $this->json($data);
return new JsonResponse($data);
}
}

View file

@ -2,23 +2,17 @@
namespace Skobkin\Bundle\PointToolsBundle\Controller;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Knp\Component\Pager\Paginator;
use Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionEventRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{Request, Response};
class EventsController extends Controller
class EventsController extends AbstractController
{
public function lastAction(Request $request): Response
public function lastAction(Request $request, SubscriptionEventRepository $eventRepository, Paginator $paginator): Response
{
/** @var EntityManager $em */
$em = $this->getDoctrine()->getManager();
$paginator = $this->get('knp_paginator');
$eventsPagination = $paginator->paginate(
$em->getRepository('SkobkinPointToolsBundle:SubscriptionEvent')->createLastSubscriptionEventsQuery(),
$eventRepository->createLastSubscriptionEventsQuery(),
$request->query->getInt('page', 1),
20
);

View file

@ -4,18 +4,33 @@ namespace Skobkin\Bundle\PointToolsBundle\Controller;
use Doctrine\ORM\EntityManager;
use Skobkin\Bundle\PointToolsBundle\Form\UserSearchType;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Skobkin\Bundle\PointToolsBundle\Repository\{SubscriptionEventRepository, SubscriptionRepository, UserRepository};
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\{JsonResponse, Request, Response};
class MainController extends Controller
class MainController extends AbstractController
{
const AJAX_AUTOCOMPLETE_SIZE = 10;
public function indexAction(Request $request): Response
/** @var int */
private $appUserId;
/** @var string */
private $appUserLogin;
public function __construct(int $appUserId, string $appUserLogin)
{
$this->appUserId = $appUserId;
$this->appUserLogin = $appUserLogin;
}
public function indexAction(
Request $request,
UserRepository $userRepository,
SubscriptionRepository $subscriptionRepository,
SubscriptionEventRepository $subscriptionEventRepository
): Response {
/** @var EntityManager $em */
$em = $this->getDoctrine()->getManager();
@ -32,7 +47,7 @@ class MainController extends Controller
if ($form->isSubmitted() && $form->isValid()) {
$login = $form->get('login')->getData();
if (null !== $user = $em->getRepository('SkobkinPointToolsBundle:User')->findOneBy(['login' => $login])) {
if (null !== $user = $userRepository->findOneBy(['login' => $login])) {
return $this->redirectToRoute('user_show', ['login' => $login]);
}
@ -42,10 +57,10 @@ class MainController extends Controller
return $this->render('SkobkinPointToolsBundle:Main:index.html.twig', [
'form' => $form->createView(),
'autocomplete_size' => self::AJAX_AUTOCOMPLETE_SIZE,
'users_count' => $em->getRepository('SkobkinPointToolsBundle:User')->getUsersCount(),
'subscribers_count' => $em->getRepository('SkobkinPointToolsBundle:Subscription')->getUserSubscribersCountById($this->getParameter('point_id')),
'events_count' => $em->getRepository('SkobkinPointToolsBundle:SubscriptionEvent')->getLastDayEventsCount(),
'service_login' => $this->getParameter('point_login'),
'users_count' => $userRepository->getUsersCount(),
'subscribers_count' => $subscriptionRepository->getUserSubscribersCountById($this->appUserId),
'events_count' => $subscriptionEventRepository->getLastDayEventsCount(),
'service_login' => $this->appUserLogin,
]);
}
@ -56,13 +71,13 @@ class MainController extends Controller
*
* @return JsonResponse
*/
public function searchUserAjaxAction(string $login): Response
public function searchUserAjaxAction(string $login, UserRepository $userRepository): Response
{
$em = $this->getDoctrine()->getManager();
$result = [];
foreach ($em->getRepository('SkobkinPointToolsBundle:User')->findUsersLikeLogin($login, self::AJAX_AUTOCOMPLETE_SIZE) as $user) {
foreach ($userRepository->findUsersLikeLogin($login, self::AJAX_AUTOCOMPLETE_SIZE) as $user) {
$result[] = [
'login' => $user->getLogin(),
'name' => $user->getName(),

View file

@ -3,21 +3,22 @@
namespace Skobkin\Bundle\PointToolsBundle\Controller;
use Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Post;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Skobkin\Bundle\PointToolsBundle\Repository\Blogs\PostRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\HttpFoundation\Response;
class PostController extends Controller
class PostController extends AbstractController
{
/**
* @ParamConverter("post", class="SkobkinPointToolsBundle:Blogs\Post")
*
* @return Response
*/
public function showAction(Post $post): Response
public function showAction(Post $post, PostRepository $postRepository): Response
{
return $this->render('SkobkinPointToolsBundle:Post:show.html.twig', [
'post' => $this->getDoctrine()->getRepository('SkobkinPointToolsBundle:Blogs\Post')->getPostWithComments($post->getId()),
'post' => $postRepository->getPostWithComments($post->getId()),
]);
}

View file

@ -2,21 +2,17 @@
namespace Skobkin\Bundle\PointToolsBundle\Controller;
use Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Post;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Knp\Component\Pager\Paginator;
use Skobkin\Bundle\PointToolsBundle\Repository\Blogs\PostRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
class PublicFeedController extends Controller
class PublicFeedController extends AbstractController
{
private const POSTS_PER_PAGE = 20;
public function indexAction(Request $request)
public function indexAction(Request $request, PostRepository $postRepository, Paginator $paginator)
{
// @todo autowire
$postRepository = $this->getDoctrine()->getRepository(Post::class);
$paginator = $this->get('knp_paginator');
$postsPagination = $paginator->paginate(
$postRepository->createPublicFeedPostsQuery(),
$request->query->getInt('page', 1),

View file

@ -2,25 +2,35 @@
namespace Skobkin\Bundle\PointToolsBundle\Controller\Telegram;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Skobkin\Bundle\PointToolsBundle\Service\Telegram\IncomingUpdateDispatcher;
use Symfony\Bridge\Monolog\Logger;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{JsonResponse, Request, Response};
use unreal4u\TelegramAPI\Telegram\Types\Update;
/**
* {@inheritdoc}
*/
class WebHookController extends Controller
class WebHookController extends AbstractController
{
public function receiveUpdateAction(Request $request, string $token): Response
/** @var string */
private $telegramToken;
/** @var bool */
private $debug;
public function __construct(string $telegramToken, bool $debug)
{
if ($token !== $savedToken = $this->getParameter('telegram_token')) {
$this->telegramToken = $telegramToken;
$this->debug = $debug;
}
public function receiveUpdateAction(Request $request, string $token, IncomingUpdateDispatcher $updateDispatcher, Logger $logger): Response
{
if ($token !== $savedToken = $this->telegramToken) {
throw $this->createNotFoundException();
}
$logger = $this->get('logger');
$content = json_decode($request->getContent(), true);
$update = new Update(
@ -29,9 +39,9 @@ class WebHookController extends Controller
);
try {
$this->get('app.telegram.update_dispatcher')->process($update);
$updateDispatcher->process($update);
} catch (\Exception $e) {
if ($this->getParameter('kernel.debug')) {
if ($this->debug) {
throw $e;
}

View file

@ -2,52 +2,61 @@
namespace Skobkin\Bundle\PointToolsBundle\Controller;
use Doctrine\ORM\EntityManager;
use Knp\Component\Pager\Paginator;
use Skobkin\Bundle\PointToolsBundle\DTO\{DailyEvents, TopUserDTO};
use Skobkin\Bundle\PointToolsBundle\Entity\User;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Skobkin\Bundle\PointToolsBundle\Repository\{SubscriptionEventRepository, UserRenameEventRepository, UserRepository};
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Ob\HighchartsBundle\Highcharts\Highchart;
use Symfony\Component\HttpFoundation\{Request, Response};
use Symfony\Component\Translation\TranslatorInterface;
class UserController extends Controller
class UserController extends AbstractController
{
/** @var TranslatorInterface */
private $translator;
public function __construct(TranslatorInterface $translator)
{
$this->translator = $translator;
}
/**
* @param string $login
*/
public function showAction(Request $request, string $login): Response
{
/** @var EntityManager $em */
$em = $this->getDoctrine()->getManager();
public function showAction(
Request $request,
string $login,
SubscriptionEventRepository $subscriptionEventRepository,
UserRepository $userRepository,
UserRenameEventRepository $renameEventRepository,
Paginator $paginator
): Response {
/** @var User $user */
$user = $em->getRepository('SkobkinPointToolsBundle:User')->findUserByLogin($login);
$user = $userRepository->findUserByLogin($login);
if (!$user) {
throw $this->createNotFoundException('User ' . $login . ' not found.');
}
$paginator = $this->get('knp_paginator');
$subscriberEventsPagination = $paginator->paginate(
$em->getRepository('SkobkinPointToolsBundle:SubscriptionEvent')->createUserLastSubscribersEventsQuery($user),
$subscriptionEventRepository->createUserLastSubscribersEventsQuery($user),
$request->query->getInt('page', 1),
10
);
return $this->render('SkobkinPointToolsBundle:User:show.html.twig', [
'user' => $user,
'subscribers' => $em->getRepository('SkobkinPointToolsBundle:User')->findUserSubscribersById($user->getId()),
'subscribers' => $userRepository->findUserSubscribersById($user->getId()),
'subscriptions_log' => $subscriberEventsPagination,
'rename_log' => $em->getRepository('SkobkinPointToolsBundle:UserRenameEvent')->findBy(['user' => $user], ['date' => 'DESC'], 10),
'rename_log' => $renameEventRepository->findBy(['user' => $user], ['date' => 'DESC'], 10),
]);
}
public function topAction(): Response
public function topAction(UserRepository $userRepository, SubscriptionEventRepository $subscriptionEventRepository): Response
{
$userRepo = $this->getDoctrine()->getManager()->getRepository('SkobkinPointToolsBundle:User');
$subscriptionsRecordsRepo = $this->getDoctrine()->getManager()->getRepository('SkobkinPointToolsBundle:SubscriptionEvent');
$topUsers = $userRepo->getTopUsers();
$eventsByDay = $subscriptionsRecordsRepo->getLastEventsByDay();
$topUsers = $userRepository->getTopUsers();
$eventsByDay = $subscriptionEventRepository->getLastEventsByDay();
return $this->render('@SkobkinPointTools/User/top.html.twig', [
'events_dynamic_chat' => $this->createEventsDynamicChart($eventsByDay),
@ -89,8 +98,6 @@ class UserController extends Controller
private function createChart(string $blockId, string $type, array $data, string $bottomLabel, string $amountLabel): Highchart
{
$translator = $this->get('translator');
$chartData = [
'keys' => [],
'values' => [],
@ -104,7 +111,7 @@ class UserController extends Controller
// Chart
$series = [[
'name' => $translator->trans($amountLabel),
'name' => $this->translator->trans($amountLabel),
'data' => $chartData['values'],
]];
@ -112,10 +119,10 @@ class UserController extends Controller
$ob = new Highchart();
$ob->chart->renderTo($blockId);
$ob->chart->type($type);
$ob->title->text($translator->trans($bottomLabel));
$ob->title->text($this->translator->trans($bottomLabel));
$ob->xAxis->title(['text' => null]);
$ob->xAxis->categories($chartData['keys']);
$ob->yAxis->title(['text' => $translator->trans($amountLabel)]);
$ob->yAxis->title(['text' => $this->translator->trans($amountLabel)]);
$ob->plotOptions->bar([
'dataLabels' => [
'enabled' => true

View file

@ -142,11 +142,12 @@ class Account
return $this->firstName;
}
public function setFirstName(string $firstName): Account
public function updateFromMessageData(string $firstName, ?string $lastName, ?string $username, int $chatId): void
{
$this->firstName = $firstName;
return $this;
$this->lastName = $lastName;
$this->username = $username;
$this->chatId = $chatId;
}
public function getLastName(): ?string
@ -154,32 +155,11 @@ class Account
return $this->lastName;
}
public function setLastName(?string $lastName = null): Account
{
$this->lastName = $lastName;
return $this;
}
public function getUsername(): string
{
return $this->username;
}
public function setUsername(string $username = null): Account
{
$this->username = $username;
return $this;
}
public function setChatId(int $chatId): self
{
$this->chatId = $chatId;
return $this;
}
public function getChatId(): int
{
return $this->chatId;

View file

@ -157,7 +157,7 @@ class User
/**
* @return Subscription[]|ArrayCollection
*/
public function getSubscribers(): ArrayCollection
public function getSubscribers(): iterable
{
return $this->subscribers;
}
@ -165,7 +165,7 @@ class User
/**
* @return Subscription[]|ArrayCollection
*/
public function getSubscriptions(): ArrayCollection
public function getSubscriptions(): iterable
{
return $this->subscriptions;
}
@ -180,7 +180,7 @@ class User
/**
* @return SubscriptionEvent[]|ArrayCollection
*/
public function getNewSubscriberEvents(): ArrayCollection
public function getNewSubscriberEvents(): iterable
{
return $this->newSubscriberEvents;
}

View file

@ -9,7 +9,7 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Index(name="idx_rename_log_date", columns={"date"}),
* @ORM\Index(name="idx_rename_log_old_login", columns={"old_login"})
* })
* @ORM\Entity(readOnly=true)
* @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Repository\UserRenameEventRepository", readOnly=true)
*/
class UserRenameEvent
{

View file

@ -0,0 +1,14 @@
<?php
namespace Skobkin\Bundle\PointToolsBundle\Repository;
use Doctrine\ORM\EntityRepository;
use Skobkin\Bundle\PointToolsBundle\Entity\UserRenameEvent;
class UserRenameEventRepository extends EntityRepository
{
public function add(UserRenameEvent $event)
{
$this->getEntityManager()->persist($event);
}
}

View file

@ -1,275 +1 @@
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
autowiring_types: GuzzleHttp\ClientInterface
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
autowire: true
# User
app.point.api_user:
class: Skobkin\Bundle\PointToolsBundle\Service\Api\UserApi
parent: app.point.abstract_api
autowire: true
tags:
- { name: monolog.logger, channel: point_user_api }
# Post
app.point.api_post:
class: Skobkin\Bundle\PointToolsBundle\Service\Api\PostApi
parent: app.point.abstract_api
autowire: true
tags:
- { name: monolog.logger, channel: point_post_api }
# Point subscription manager
app.point.subscriptions_manager:
class: Skobkin\Bundle\PointToolsBundle\Service\SubscriptionsManager
# TODO deal with autowire for EventDispatcherInterface
arguments:
- '@event_dispatcher'
- '@logger'
- '@app.point.subscription_repository'
- '@app.point.subscription_record_repository'
tags:
- { name: monolog.logger, channel: subscribers_update }
# Console commands
# Subsribers update
app.point.update_subscribers_command:
class: Skobkin\Bundle\PointToolsBundle\Command\UpdateSubscriptionsCommand
arguments:
- '@doctrine.orm.entity_manager'
- '@logger'
- '@app.point.user_repository'
- '@app.point.api_user'
- '@app.point.subscriptions_manager'
- '%point_api_delay%'
- '%point_id%'
tags:
- { name: console.command }
- { name: monolog.logger, channel: subscribers_update }
# Privacy update
app.point.update_privacy_command:
class: Skobkin\Bundle\PointToolsBundle\Command\UpdateUsersPrivacyCommand
#autowire: []
arguments:
- '@doctrine.orm.entity_manager'
- '@logger'
- '@app.point.user_repository'
- '@app.point.api_user'
- '%point_api_delay%'
- '%point_id%'
tags:
- { name: console.command }
- { name: monolog.logger, channel: privacy_update }
# Restore users removed by error
app.point.restore_users:
class: Skobkin\Bundle\PointToolsBundle\Command\RestoreRemovedUsersCommand
arguments:
- '@logger'
- '@doctrine.orm.entity_manager'
- '@app.point.user_repository'
- '@app.point.api_user'
- '%point_api_delay%'
tags:
- { name: console.command }
# Webhook management
app.telegram.webhook_command:
class: Skobkin\Bundle\PointToolsBundle\Command\TelegramWebHookCommand
#autowire: []
calls:
- [setClient, ['@app.telegram.bot_client']]
- [setRouter, ['@router']]
- [setToken, ['%telegram_token%']]
tags: [{ name: console.command }]
# Send message
app.telegram.send_message:
class: Skobkin\Bundle\PointToolsBundle\Command\TelegramSendMessageCommand
#autowire: []
calls:
- [setMessenger, ['@app.telegram.message_sender']]
- [setLogChatId, ['%telegram_log_chat_id%']]
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
# Abstract factory
app.point.abstract_factory:
abstract: true
autowire: true
# User
app.point.user_factory:
class: Skobkin\Bundle\PointToolsBundle\Service\Factory\UserFactory
parent: app.point.abstract_factory
autowire: true
# Comment
app.point.comment_factory:
class: Skobkin\Bundle\PointToolsBundle\Service\Factory\Blogs\CommentFactory
parent: app.point.abstract_factory
autowire: true
# Tag
app.point.tag_factory:
class: Skobkin\Bundle\PointToolsBundle\Service\Factory\Blogs\TagFactory
parent: app.point.abstract_factory
autowire: true
# File
app.point.file_factory:
class: Skobkin\Bundle\PointToolsBundle\Service\Factory\Blogs\FileFactory
parent: app.point.abstract_factory
autowire: true
# Post
app.point.post_factory:
class: Skobkin\Bundle\PointToolsBundle\Service\Factory\Blogs\PostFactory
parent: app.point.abstract_factory
autowire: true
# Telegram account
app.telegram.telegram_account_factory:
class: Skobkin\Bundle\PointToolsBundle\Service\Factory\Telegram\AccountFactory
parent: app.point.abstract_factory
autowire: true
# Custom Markdown parser
app.point.markdown_parser:
class: Skobkin\Bundle\PointToolsBundle\Service\Markdown\PointParser
arguments: [[], '@router']
tags:
- { name: markdown.parser }
# Event listeners
# User name changed in Doctrine
app.event_listener.users_updated:
class: Skobkin\Bundle\PointToolsBundle\EventListener\UsersUpdatedSubscriber
arguments: ['@event_dispatcher']
tags:
- { name: doctrine.event_subscriber, connection: default }
# User renaming
app.event_listener.users_renamed_notifier:
class: Skobkin\Bundle\PointToolsBundle\EventListener\UsersRenamedListener
autowire: true
tags:
- { name: kernel.event_listener, event: app.users.renamed }
# User subscribers updated
app.event_listener.user_subscribers_updated:
class: Skobkin\Bundle\PointToolsBundle\EventListener\UserSubscribersUpdatedListener
autowire: true
tags:
- { name: kernel.event_listener, event: app.user.subscribers_updated }
# Twig extensions
app.twig.point_users_extension:
class: Skobkin\Bundle\PointToolsBundle\Twig\PointUrlExtension
public: false
arguments:
- '%point_domain%'
- '%point_scheme%'
- '%point_base_url%'
tags:
- { name: twig.extension }
# Telegram services
# Bot API client
app.telegram.bot_client:
class: unreal4u\TelegramAPI\TgLog
autowiring_types: unreal4u\TelegramAPI\TgLog
arguments: ['%telegram_token%', '@logger', '@app.http.telegram_client']
# Logger API client
app.telegram.logger_client:
class: unreal4u\TelegramAPI\TgLog
arguments: ['%telegram_token%', null, '@app.http.telegram_client']
# Monolog handler
app.log.telegram_handler:
class: unreal4u\MonologHandler
arguments:
- '@app.telegram.logger_client'
- '%telegram_log_chat_id%'
- 'error'
# User notifier
app.telegram.notifier:
class: Skobkin\Bundle\PointToolsBundle\Service\Telegram\Notifier
autowire: true
# Message sender
app.telegram.message_sender:
class: Skobkin\Bundle\PointToolsBundle\Service\Telegram\MessageSender
autowire: true
# Common incoming message processor
app.telegram.update_dispatcher:
class: Skobkin\Bundle\PointToolsBundle\Service\Telegram\IncomingUpdateDispatcher
autowire: true
# InlineQuery processor
app.telegram.inline_query_processor:
class: Skobkin\Bundle\PointToolsBundle\Service\Telegram\InlineQueryProcessor
lazy: true
autowire: true
# Private message processor
app.telegram.private_message_processor:
class: Skobkin\Bundle\PointToolsBundle\Service\Telegram\PrivateMessageProcessor
lazy: true
autowire: true
calls:
- [setPointUserId, ['%point_id%']]

View file

@ -4,7 +4,9 @@ namespace Skobkin\Bundle\PointToolsBundle\Service\Api;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\TransferException;
use JMS\Serializer\{DeserializationContext, Serializer};
use JMS\Serializer\{
DeserializationContext, SerializerInterface
};
use Psr\Http\Message\{ResponseInterface, StreamInterface};
use Psr\Log\LoggerInterface;
use Skobkin\Bundle\PointToolsBundle\Exception\Api\{ForbiddenException, NetworkException, NotFoundException, ServerProblemException, UnauthorizedException};
@ -18,7 +20,7 @@ class AbstractApi
protected $client;
/**
* @var Serializer
* @var SerializerInterface
*/
protected $serializer;
@ -38,7 +40,7 @@ class AbstractApi
protected $csRfToken;
public function __construct(ClientInterface $httpClient, Serializer $serializer, LoggerInterface $logger)
public function __construct(ClientInterface $httpClient, SerializerInterface $serializer, LoggerInterface $logger)
{
$this->client = $httpClient;
$this->serializer = $serializer;

View file

@ -3,7 +3,7 @@
namespace Skobkin\Bundle\PointToolsBundle\Service\Api;
use GuzzleHttp\ClientInterface;
use JMS\Serializer\Serializer;
use JMS\Serializer\SerializerInterface;
use Psr\Log\LoggerInterface;
use Skobkin\Bundle\PointToolsBundle\Service\Factory\Blogs\PostFactory;
@ -18,7 +18,7 @@ class PostApi extends AbstractApi
private $postFactory;
public function __construct(ClientInterface $httpClient, Serializer $serializer, LoggerInterface $logger, PostFactory $postFactory)
public function __construct(ClientInterface $httpClient, SerializerInterface $serializer, LoggerInterface $logger, PostFactory $postFactory)
{
parent::__construct($httpClient, $serializer, $logger);

View file

@ -3,7 +3,9 @@
namespace Skobkin\Bundle\PointToolsBundle\Service\Api;
use GuzzleHttp\ClientInterface;
use JMS\Serializer\{DeserializationContext, Serializer};
use JMS\Serializer\{
DeserializationContext, SerializerInterface
};
use Psr\Log\LoggerInterface;
use Skobkin\Bundle\PointToolsBundle\DTO\Api\{Auth, User as UserDTO};
use Skobkin\Bundle\PointToolsBundle\Entity\User;
@ -22,7 +24,7 @@ class UserApi extends AbstractApi
*/
private $userFactory;
public function __construct(ClientInterface $httpClient, Serializer $serializer, LoggerInterface $logger, UserFactory $userFactory)
public function __construct(ClientInterface $httpClient, SerializerInterface $serializer, LoggerInterface $logger, UserFactory $userFactory)
{
parent::__construct($httpClient, $serializer, $logger);

View file

@ -3,26 +3,18 @@
namespace Skobkin\Bundle\PointToolsBundle\Service\Factory\Blogs;
use Psr\Log\LoggerInterface;
use Skobkin\Bundle\PointToolsBundle\Repository\Blogs\CommentRepository;
use Skobkin\Bundle\PointToolsBundle\Repository\Blogs\PostRepository;
use Skobkin\Bundle\PointToolsBundle\Service\Factory\AbstractFactory;
use Skobkin\Bundle\PointToolsBundle\Service\Factory\UserFactory;
use Skobkin\Bundle\PointToolsBundle\Repository\Blogs\{CommentRepository, PostRepository};
use Skobkin\Bundle\PointToolsBundle\Service\Factory\{AbstractFactory, UserFactory};
class CommentFactory extends AbstractFactory
{
/**
* @var CommentRepository
*/
/** @var CommentRepository */
private $commentRepository;
/**
* @var PostRepository
*/
/** @var PostRepository */
private $postRepository;
/**
* @var UserFactory
*/
/** @var UserFactory */
private $userFactory;

View file

@ -10,9 +10,7 @@ use Skobkin\Bundle\PointToolsBundle\Service\Factory\AbstractFactory;
class FileFactory extends AbstractFactory
{
/**
* @var FileRepository
*/
/** @var FileRepository */
private $fileRepository;

View file

@ -4,48 +4,30 @@ namespace Skobkin\Bundle\PointToolsBundle\Service\Factory\Blogs;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Skobkin\Bundle\PointToolsBundle\DTO\Api\MetaPost;
use Skobkin\Bundle\PointToolsBundle\DTO\Api\Post as PostDTO;
use Skobkin\Bundle\PointToolsBundle\DTO\Api\PostsPage;
use Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Post;
use Skobkin\Bundle\PointToolsBundle\Entity\Blogs\PostTag;
use Skobkin\Bundle\PointToolsBundle\Entity\User;
use Skobkin\Bundle\PointToolsBundle\Exception\Factory\Blog\InvalidDataException;
use Skobkin\Bundle\PointToolsBundle\DTO\Api\{MetaPost, Post as PostDTO, PostsPage};
use Skobkin\Bundle\PointToolsBundle\Entity\{Blogs\Post, Blogs\PostTag, User};
use Skobkin\Bundle\PointToolsBundle\Exception\{Api\InvalidResponseException, Factory\Blog\InvalidDataException};
use Skobkin\Bundle\PointToolsBundle\Repository\Blogs\PostRepository;
use Skobkin\Bundle\PointToolsBundle\Exception\Api\InvalidResponseException;
use Skobkin\Bundle\PointToolsBundle\Service\Factory\AbstractFactory;
use Skobkin\Bundle\PointToolsBundle\Service\Factory\UserFactory;
use Skobkin\Bundle\PointToolsBundle\Service\Factory\{AbstractFactory, UserFactory};
class PostFactory extends AbstractFactory
{
/**
* @var EntityManagerInterface
*/
/** @var EntityManagerInterface */
private $em;
/**
* @var PostRepository
*/
/** @var PostRepository */
private $postRepository;
/**
* @var UserFactory
*/
/** @var UserFactory */
private $userFactory;
/**
* @var FileFactory
*/
/** @var FileFactory */
private $fileFactory;
/**
* @var CommentFactory
*/
/** @var CommentFactory */
private $commentFactory;
/**
* @var TagFactory
*/
/** @var TagFactory */
private $tagFactory;

View file

@ -9,9 +9,7 @@ use Skobkin\Bundle\PointToolsBundle\Service\Factory\AbstractFactory;
class TagFactory extends AbstractFactory
{
/**
* @var TagRepository
*/
/** @var TagRepository */
private $tagRepository;

View file

@ -10,9 +10,7 @@ use unreal4u\TelegramAPI\Telegram\Types\Message;
class AccountFactory extends AbstractFactory
{
/**
* @var AccountRepository
*/
/** @var AccountRepository */
private $accountRepo;
@ -30,12 +28,12 @@ class AccountFactory extends AbstractFactory
}
// Setting/updating account data
$account
->setFirstName($message->from->first_name)
->setLastName($message->from->last_name)
->setUsername($message->from->username)
->setChatId($message->chat->id)
;
$account->updateFromMessageData(
$message->from->first_name,
$message->from->last_name,
$message->from->username,
$message->chat->id
);
return $account;
}

View file

@ -3,34 +3,23 @@
namespace Skobkin\Bundle\PointToolsBundle\Service;
use Psr\Log\LoggerInterface;
use Skobkin\Bundle\PointToolsBundle\Entity\Subscription;
use Skobkin\Bundle\PointToolsBundle\Entity\SubscriptionEvent;
use Skobkin\Bundle\PointToolsBundle\Entity\User;
use Skobkin\Bundle\PointToolsBundle\Entity\{Subscription, SubscriptionEvent, User};
use Skobkin\Bundle\PointToolsBundle\Event\UserSubscribersUpdatedEvent;
use Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionEventRepository;
use Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionRepository;
use Skobkin\Bundle\PointToolsBundle\Repository\{SubscriptionEventRepository, SubscriptionRepository};
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class SubscriptionsManager
{
/**
* @var SubscriptionRepository
*/
/** @var SubscriptionRepository */
private $subscriptionRepo;
/**
* @var SubscriptionEventRepository
*/
/** @var SubscriptionEventRepository */
private $subscriptionRecordRepo;
/**
* @var EventDispatcherInterface
*/
/** @var EventDispatcherInterface */
private $eventDispatcher;
/**
* @var LoggerInterface
*/
/** @var LoggerInterface */
private $logger;

View file

@ -12,14 +12,10 @@ class IncomingUpdateDispatcher
const CHAT_TYPE_PRIVATE = 'private';
const CHAT_TYPE_GROUP = 'group';
/**
* @var InlineQueryProcessor
*/
/** @var InlineQueryProcessor */
private $inlineQueryProcessor;
/**
* @var PrivateMessageProcessor
*/
/** @var PrivateMessageProcessor */
private $privateMessageProcessor;

View file

@ -10,14 +10,10 @@ use unreal4u\TelegramAPI\TgLog;
class InlineQueryProcessor
{
/**
* @var UserRepository
*/
/** @var UserRepository */
private $userRepo;
/**
* @var TgLog
*/
/** @var TgLog */
private $client;

View file

@ -17,14 +17,10 @@ class MessageSender
public const PARSE_MARKDOWN = 'Markdown';
public const PARSE_HTML5 = 'HTML';
/**
* @var TgLog
*/
/** @var TgLog */
private $client;
/**
* @var \Twig_Environment
*/
/** @var \Twig_Environment */
private $twig;
/**

View file

@ -10,14 +10,10 @@ use Skobkin\Bundle\PointToolsBundle\Repository\Telegram\AccountRepository;
*/
class Notifier
{
/**
* @var AccountRepository
*/
/** @var AccountRepository */
private $accountsRepo;
/**
* @var MessageSender
*/
/** @var MessageSender */
private $messenger;

View file

@ -3,67 +3,41 @@
namespace Skobkin\Bundle\PointToolsBundle\Service\Telegram;
use Doctrine\ORM\EntityManagerInterface;
use Skobkin\Bundle\PointToolsBundle\Entity\Telegram\Account;
use Skobkin\Bundle\PointToolsBundle\Entity\User;
use Skobkin\Bundle\PointToolsBundle\Entity\{Telegram\Account, User};
use Skobkin\Bundle\PointToolsBundle\Exception\Telegram\CommandProcessingException;
use Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionEventRepository;
use Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionRepository;
use Skobkin\Bundle\PointToolsBundle\Repository\Telegram\AccountRepository;
use Skobkin\Bundle\PointToolsBundle\Repository\UserRepository;
use Skobkin\Bundle\PointToolsBundle\Repository\{SubscriptionEventRepository, SubscriptionRepository, Telegram\AccountRepository, UserRepository};
use Skobkin\Bundle\PointToolsBundle\Service\Factory\Telegram\AccountFactory;
use Skobkin\Bundle\PointToolsBundle\Service\Api\UserApi;
use unreal4u\TelegramAPI\Telegram\Types\Message;
use unreal4u\TelegramAPI\Telegram\Types\ReplyKeyboardMarkup;
use unreal4u\TelegramAPI\Telegram\Types\ReplyKeyboardRemove;
use unreal4u\TelegramAPI\Telegram\Types\{Message, ReplyKeyboardMarkup, ReplyKeyboardRemove};
/**
* Processes all private messages
*/
/** Processes all private messages */
class PrivateMessageProcessor
{
/**
* @var MessageSender
*/
/** @var MessageSender */
private $messenger;
/**
* @var UserApi
*/
/** @var UserApi */
private $userApi;
/**
* @var AccountFactory
*/
/** @var AccountFactory */
private $accountFactory;
/**
* @var EntityManagerInterface
*/
/** @var EntityManagerInterface */
private $em;
/**
* @var UserRepository
*/
/** @var UserRepository */
private $userRepo;
/**
* @var AccountRepository
*/
/** @var AccountRepository */
private $accountRepo;
/**
* @var SubscriptionRepository
*/
/** @var SubscriptionRepository */
private $subscriptionRepo;
/**
* @var SubscriptionEventRepository
*/
/** @var SubscriptionEventRepository */
private $subscriptionEventRepo;
/**
* @var int
*/
/** @var int */
private $pointUserId;
@ -75,7 +49,8 @@ class PrivateMessageProcessor
SubscriptionEventRepository $subscriptionRecordRepository,
MessageSender $messageSender,
UserApi $userApi,
AccountFactory $accountFactory
AccountFactory $accountFactory,
int $appUserId
) {
$this->em = $em;
$this->userRepo = $userRepository;
@ -85,11 +60,7 @@ class PrivateMessageProcessor
$this->messenger = $messageSender;
$this->userApi = $userApi;
$this->accountFactory = $accountFactory;
}
public function setPointUserId(int $pointUserId)
{
$this->pointUserId = $pointUserId;
$this->pointUserId = $appUserId;
}
public function process(Message $message): void