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\DoctrineBundle\DoctrineBundle(),
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(), new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new Symfony\Bundle\WebServerBundle\WebServerBundle(),
new JMS\SerializerBundle\JMSSerializerBundle(), new JMS\SerializerBundle\JMSSerializerBundle(),
new Csa\Bundle\GuzzleBundle\CsaGuzzleBundle(), new Csa\Bundle\GuzzleBundle\CsaGuzzleBundle(),
new Ob\HighchartsBundle\ObHighchartsBundle(), new Ob\HighchartsBundle\ObHighchartsBundle(),
@ -40,6 +41,6 @@ class AppKernel extends Kernel
public function registerContainerConfiguration(LoaderInterface $loader) 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 } #serializer: { enable_annotations: true }
secret: "%secret%" secret: "%secret%"
router: router:
resource: "%kernel.root_dir%/config/routing.yml" resource: "%kernel.project_dir%/app/config/routing.yml"
strict_requirements: ~ strict_requirements: ~
form: ~ form: ~
csrf_protection: ~ csrf_protection: ~
@ -27,7 +27,6 @@ framework:
engines: ['twig'] engines: ['twig']
default_locale: "%locale%" default_locale: "%locale%"
trusted_hosts: ~ trusted_hosts: ~
trusted_proxies: ~
session: session:
# handler_id set to null will use default session handler from php.ini # handler_id set to null will use default session handler from php.ini
handler_id: ~ handler_id: ~
@ -67,7 +66,7 @@ doctrine:
DAY: Skobkin\Bundle\PointToolsBundle\DQL\Day DAY: Skobkin\Bundle\PointToolsBundle\DQL\Day
doctrine_migrations: doctrine_migrations:
dir_name: "%kernel.root_dir%/DoctrineMigrations" dir_name: "%kernel.project_dir%/app/DoctrineMigrations"
namespace: Application\Migrations namespace: Application\Migrations
table_name: migration_versions table_name: migration_versions
name: Application Migrations name: Application Migrations

View file

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

View file

@ -5,10 +5,10 @@ imports:
doctrine: doctrine:
dbal: dbal:
# todo move to new environment variables: https://symfony.com/blog/new-in-symfony-3-2-runtime-environment-variables # todo move to new environment variables: https://symfony.com/blog/new-in-symfony-3-2-runtime-environment-variables
dbname: "%test_database_name%" dbname: "%env(SYMFONY__TEST_DATABASE_NAME)%"
port: "%test_database_port%" port: "%env(SYMFONY__TEST_DATABASE_PORT)%"
user: "%test_database_user%" user: "%env(SYMFONY__TEST_DATABASE_USER)%"
password: "%test_database_password%" password: "%env(SYMFONY__TEST_DATABASE_PASSWORD)%"
framework: framework:
test: ~ 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: parameters:
# parameter_name: value
services: services:
# service_name: _defaults:
# class: AppBundle\Directory\ClassName autowire: true
# arguments: ["@another_service_name", "plain_value", "%parameter_name%"] 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 # 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 */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
# App users # All 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 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 # Other
# Restore users deleted by mistake # 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" ] "classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
}, },
"autoload-dev": { "autoload-dev": {
"psr-4": { "Tests\\": "tests/" } "psr-4": { "Tests\\": "tests/" },
"files": [ "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php" ]
}, },
"require": { "require": {
"php": ">=7.0.0", "php": ">=7.1.0",
"symfony/symfony": "3.2.*", "symfony/symfony": "3.4.x-dev",
"doctrine/orm": "^2.5", "doctrine/orm": "^2.5",
"doctrine/annotations": "^1.3.0", "doctrine/annotations": "^1.3.0",
"doctrine/doctrine-bundle": "^1.6", "doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.2", "doctrine/doctrine-cache-bundle": "^1.2",
"doctrine/doctrine-migrations-bundle": "^1.0", "doctrine/doctrine-migrations-bundle": "^1.0",
"twig/twig": "^2.0",
"twig/extensions": "~1.0", "twig/extensions": "~1.0",
"symfony/swiftmailer-bundle": "^2.3.10", "symfony/swiftmailer-bundle": "^2.6.4",
"symfony/monolog-bundle": "^3.0.2", "symfony/monolog-bundle": "^3.1.0",
"sensio/distribution-bundle": "^5.0", "sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^3.0.2", "sensio/framework-extra-bundle": "^5.0.0",
"incenteev/composer-parameter-handler": "^2.0", "incenteev/composer-parameter-handler": "^2.0",
"ob/highcharts-bundle": "^1.2", "ob/highcharts-bundle": "^1.2",
"jms/serializer-bundle": "^1.1", "jms/serializer-bundle": "^1.1",
"knplabs/knp-markdown-bundle": "^1.4", "knplabs/knp-markdown-bundle": "^1.4",
"knplabs/knp-paginator-bundle": "^2.5", "knplabs/knp-paginator-bundle": "^2.5",
"unreal4u/telegram-api": "^2.2", "unreal4u/telegram-api": "^2.2",
"csa/guzzle-bundle": "^2.1", "csa/guzzle-bundle": "3.0.x-dev",
"unreal4u/monolog-telegram": "^0.2.0" "unreal4u/monolog-telegram": "^0.2.0",
"symfony/web-server-bundle": "^3.3"
}, },
"require-dev": { "require-dev": {
"sensio/generator-bundle": "^3.0", "sensio/generator-bundle": "^3.0",
@ -60,12 +63,13 @@
"extra": { "extra": {
"symfony-app-dir": "app", "symfony-app-dir": "app",
"symfony-web-dir": "web", "symfony-web-dir": "web",
"symfony-tests-dir": "tests",
"symfony-assets-install": "relative", "symfony-assets-install": "relative",
"incenteev-parameters": { "incenteev-parameters": {
"file": "app/config/parameters.yml" "file": "app/config/parameters.yml"
}, },
"branch-alias": { "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", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "88274224cc9dfe36d847acf69d5924d8", "content-hash": "71a9b3759d77d9b4770ae1aedcda61c6",
"packages": [ "packages": [
{ {
"name": "composer/ca-bundle", "name": "composer/ca-bundle",
@ -67,24 +67,24 @@
}, },
{ {
"name": "csa/guzzle-bundle", "name": "csa/guzzle-bundle",
"version": "v2.2.1", "version": "dev-master",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/csarrazi/CsaGuzzleBundle.git", "url": "https://github.com/csarrazi/CsaGuzzleBundle.git",
"reference": "bbe54641ad6171dc562034f2824f7c18cec80ca4" "reference": "6b10e6f318ea6a20fa32cfcda471bd0bbebcdb96"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/csarrazi/CsaGuzzleBundle/zipball/bbe54641ad6171dc562034f2824f7c18cec80ca4", "url": "https://api.github.com/repos/csarrazi/CsaGuzzleBundle/zipball/6b10e6f318ea6a20fa32cfcda471bd0bbebcdb96",
"reference": "bbe54641ad6171dc562034f2824f7c18cec80ca4", "reference": "6b10e6f318ea6a20fa32cfcda471bd0bbebcdb96",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"guzzlehttp/guzzle": "^6.1", "guzzlehttp/guzzle": "^6.1",
"php": ">=5.5.0", "php": ">=5.6.0",
"symfony/dependency-injection": "^2.7|^3.0", "symfony/dependency-injection": "^2.7|^3.0|^4.0",
"symfony/filesystem": "^2.7|^3.0", "symfony/filesystem": "^2.7|^3.0|^4.0",
"symfony/framework-bundle": "^2.7|^3.0", "symfony/framework-bundle": "^2.7|^3.0|^4.0",
"twig/twig": "^1.12|^2.0" "twig/twig": "^1.12|^2.0"
}, },
"require-dev": { "require-dev": {
@ -92,8 +92,9 @@
"namshi/cuzzle": "^2.0", "namshi/cuzzle": "^2.0",
"phpunit/phpunit": "^4.8", "phpunit/phpunit": "^4.8",
"psr/cache": "^1.0", "psr/cache": "^1.0",
"symfony/phpunit-bridge": "^2.7|^3.0", "symfony/phpunit-bridge": "^2.7|^3.0|^4.0",
"symfony/web-profiler-bundle": "^2.3|^3.0" "symfony/stopwatch": "^2.7|^3.0|^4.0",
"symfony/web-profiler-bundle": "^2.3|^3.0|^4.0"
}, },
"suggest": { "suggest": {
"doctrine/cache": "Allows caching of responses", "doctrine/cache": "Allows caching of responses",
@ -124,7 +125,7 @@
} }
], ],
"description": "A bundle integrating GuzzleHttp >= 4.0", "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", "name": "doctrine/annotations",
@ -652,31 +653,31 @@
}, },
{ {
"name": "doctrine/doctrine-migrations-bundle", "name": "doctrine/doctrine-migrations-bundle",
"version": "v1.2.1", "version": "v1.3.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/DoctrineMigrationsBundle.git", "url": "https://github.com/doctrine/DoctrineMigrationsBundle.git",
"reference": "6276139e0b913a4e5120fc36bb5b0eae8ac549bc" "reference": "a9e506369f931351a2a6dd2aef588a822802b1b7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/DoctrineMigrationsBundle/zipball/6276139e0b913a4e5120fc36bb5b0eae8ac549bc", "url": "https://api.github.com/repos/doctrine/DoctrineMigrationsBundle/zipball/a9e506369f931351a2a6dd2aef588a822802b1b7",
"reference": "6276139e0b913a4e5120fc36bb5b0eae8ac549bc", "reference": "a9e506369f931351a2a6dd2aef588a822802b1b7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"doctrine/doctrine-bundle": "~1.0", "doctrine/doctrine-bundle": "~1.0",
"doctrine/migrations": "^1.1", "doctrine/migrations": "^1.1",
"php": ">=5.4.0", "php": ">=5.4.0",
"symfony/framework-bundle": "~2.3|~3.0" "symfony/framework-bundle": "~2.7|~3.3|~4.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~4.8" "phpunit/phpunit": "^4.8.36"
}, },
"type": "symfony-bundle", "type": "symfony-bundle",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.2-dev" "dev-master": "1.3-dev"
} }
}, },
"autoload": { "autoload": {
@ -709,7 +710,7 @@
"migrations", "migrations",
"schema" "schema"
], ],
"time": "2016-12-05T18:36:37+00:00" "time": "2017-11-01T09:13:26+00:00"
}, },
{ {
"name": "doctrine/inflector", "name": "doctrine/inflector",
@ -1036,6 +1037,60 @@
], ],
"time": "2017-10-23T18:21:04+00:00" "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", "name": "guzzlehttp/guzzle",
"version": "6.3.0", "version": "6.3.0",
@ -2249,6 +2304,55 @@
], ],
"time": "2016-08-06T20:24:11+00:00" "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", "name": "psr/http-message",
"version": "1.0.1", "version": "1.0.1",
@ -2299,6 +2403,55 @@
], ],
"time": "2016-08-06T14:39:51+00:00" "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", "name": "psr/log",
"version": "1.0.2", "version": "1.0.2",
@ -2346,6 +2499,54 @@
], ],
"time": "2016-10-10T12:19:37+00:00" "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", "name": "sensio/distribution-bundle",
"version": "v5.0.21", "version": "v5.0.21",
@ -2400,38 +2601,37 @@
}, },
{ {
"name": "sensio/framework-extra-bundle", "name": "sensio/framework-extra-bundle",
"version": "v3.0.28", "version": "v5.0.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sensiolabs/SensioFrameworkExtraBundle.git", "url": "https://github.com/sensiolabs/SensioFrameworkExtraBundle.git",
"reference": "65eadf9e3fd5c47eee7986b306a5aed8affe6496" "reference": "9e3fa14aa959f703961bc9e4ab00110d617bcfdd"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sensiolabs/SensioFrameworkExtraBundle/zipball/65eadf9e3fd5c47eee7986b306a5aed8affe6496", "url": "https://api.github.com/repos/sensiolabs/SensioFrameworkExtraBundle/zipball/9e3fa14aa959f703961bc9e4ab00110d617bcfdd",
"reference": "65eadf9e3fd5c47eee7986b306a5aed8affe6496", "reference": "9e3fa14aa959f703961bc9e4ab00110d617bcfdd",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"doctrine/common": "~2.2", "doctrine/common": "^2.2",
"symfony/dependency-injection": "~2.3|~3.0", "symfony/config": "^3.3|^4.0",
"symfony/framework-bundle": "~2.3|~3.0|~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": { "require-dev": {
"doctrine/doctrine-bundle": "~1.5", "doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "~2.4,>=2.4.5", "doctrine/orm": "^2.5",
"symfony/asset": "~2.7|~3.0|~4.0", "symfony/browser-kit": "^3.3|^4.0",
"symfony/browser-kit": "~2.3|~3.0|~4.0", "symfony/dom-crawler": "^3.3|^4.0",
"symfony/dom-crawler": "~2.3|~3.0|~4.0", "symfony/expression-language": "^3.3|^4.0",
"symfony/expression-language": "~2.4|~3.0|~4.0", "symfony/finder": "^3.3|^4.0",
"symfony/finder": "~2.3|~3.0|~4.0", "symfony/phpunit-bridge": "^3.3|^4.0",
"symfony/phpunit-bridge": "~3.2|~4.0", "symfony/psr-http-message-bridge": "^0.3",
"symfony/psr-http-message-bridge": "^0.3|^1.0", "symfony/security-bundle": "^3.3|^4.0",
"symfony/security-bundle": "~2.4|~3.0|~4.0", "symfony/twig-bundle": "^3.3|^4.0",
"symfony/templating": "~2.3|~3.0|~4.0", "symfony/yaml": "^3.3|^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",
"twig/twig": "~1.12|~2.0", "twig/twig": "~1.12|~2.0",
"zendframework/zend-diactoros": "^1.3" "zendframework/zend-diactoros": "^1.3"
}, },
@ -2443,7 +2643,7 @@
"type": "symfony-bundle", "type": "symfony-bundle",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "3.0.x-dev" "dev-master": "4.0.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -2466,7 +2666,7 @@
"annotations", "annotations",
"controllers" "controllers"
], ],
"time": "2017-10-12T17:37:20+00:00" "time": "2017-10-12T17:37:44+00:00"
}, },
{ {
"name": "sensiolabs/security-checker", "name": "sensiolabs/security-checker",
@ -2627,6 +2827,62 @@
], ],
"time": "2017-09-26T03:17:02+00:00" "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", "name": "symfony/polyfill-intl-icu",
"version": "v1.6.0", "version": "v1.6.0",
@ -2972,38 +3228,46 @@
}, },
{ {
"name": "symfony/symfony", "name": "symfony/symfony",
"version": "v3.2.13", "version": "3.4.x-dev",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/symfony.git", "url": "https://github.com/symfony/symfony.git",
"reference": "e1aabd6f50fb4586b330f9ac54b4bcdf7352a0f8" "reference": "e973c247c8acd032a5ee72418452c3a255d5e321"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/symfony/zipball/e1aabd6f50fb4586b330f9ac54b4bcdf7352a0f8", "url": "https://api.github.com/repos/symfony/symfony/zipball/e973c247c8acd032a5ee72418452c3a255d5e321",
"reference": "e1aabd6f50fb4586b330f9ac54b4bcdf7352a0f8", "reference": "e973c247c8acd032a5ee72418452c3a255d5e321",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"doctrine/common": "~2.4", "doctrine/common": "~2.4",
"ext-xml": "*", "ext-xml": "*",
"php": ">=5.5.9", "fig/link-util": "^1.0",
"php": "^5.5.9|>=7.0.8",
"psr/cache": "~1.0", "psr/cache": "~1.0",
"psr/container": "^1.0",
"psr/link": "^1.0",
"psr/log": "~1.0", "psr/log": "~1.0",
"psr/simple-cache": "^1.0",
"symfony/polyfill-apcu": "~1.1",
"symfony/polyfill-intl-icu": "~1.0", "symfony/polyfill-intl-icu": "~1.0",
"symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php56": "~1.0", "symfony/polyfill-php56": "~1.0",
"symfony/polyfill-php70": "~1.0", "symfony/polyfill-php70": "~1.6",
"symfony/polyfill-util": "~1.0", "symfony/polyfill-util": "~1.0",
"twig/twig": "~1.34|~2.4" "twig/twig": "^1.35|^2.4.4"
}, },
"conflict": { "conflict": {
"phpdocumentor/reflection-docblock": "<3.0||>=3.2.0", "phpdocumentor/reflection-docblock": "<3.0||>=3.2.0,<3.2.2",
"phpdocumentor/type-resolver": "<0.2.0", "phpdocumentor/type-resolver": "<0.2.1",
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0" "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0"
}, },
"provide": { "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": { "replace": {
"symfony/asset": "self.version", "symfony/asset": "self.version",
@ -3018,6 +3282,7 @@
"symfony/dependency-injection": "self.version", "symfony/dependency-injection": "self.version",
"symfony/doctrine-bridge": "self.version", "symfony/doctrine-bridge": "self.version",
"symfony/dom-crawler": "self.version", "symfony/dom-crawler": "self.version",
"symfony/dotenv": "self.version",
"symfony/event-dispatcher": "self.version", "symfony/event-dispatcher": "self.version",
"symfony/expression-language": "self.version", "symfony/expression-language": "self.version",
"symfony/filesystem": "self.version", "symfony/filesystem": "self.version",
@ -3029,6 +3294,7 @@
"symfony/inflector": "self.version", "symfony/inflector": "self.version",
"symfony/intl": "self.version", "symfony/intl": "self.version",
"symfony/ldap": "self.version", "symfony/ldap": "self.version",
"symfony/lock": "self.version",
"symfony/monolog-bridge": "self.version", "symfony/monolog-bridge": "self.version",
"symfony/options-resolver": "self.version", "symfony/options-resolver": "self.version",
"symfony/process": "self.version", "symfony/process": "self.version",
@ -3050,12 +3316,15 @@
"symfony/twig-bundle": "self.version", "symfony/twig-bundle": "self.version",
"symfony/validator": "self.version", "symfony/validator": "self.version",
"symfony/var-dumper": "self.version", "symfony/var-dumper": "self.version",
"symfony/web-link": "self.version",
"symfony/web-profiler-bundle": "self.version", "symfony/web-profiler-bundle": "self.version",
"symfony/web-server-bundle": "self.version",
"symfony/workflow": "self.version", "symfony/workflow": "self.version",
"symfony/yaml": "self.version" "symfony/yaml": "self.version"
}, },
"require-dev": { "require-dev": {
"cache/integration-tests": "dev-master", "cache/integration-tests": "dev-master",
"doctrine/annotations": "~1.0",
"doctrine/cache": "~1.6", "doctrine/cache": "~1.6",
"doctrine/data-fixtures": "1.0.*", "doctrine/data-fixtures": "1.0.*",
"doctrine/dbal": "~2.4", "doctrine/dbal": "~2.4",
@ -3064,17 +3333,15 @@
"egulias/email-validator": "~1.2,>=1.2.8|~2.0", "egulias/email-validator": "~1.2,>=1.2.8|~2.0",
"monolog/monolog": "~1.11", "monolog/monolog": "~1.11",
"ocramius/proxy-manager": "~0.4|~1.0|~2.0", "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", "predis/predis": "~1.0",
"sensio/framework-extra-bundle": "^3.0.2",
"symfony/phpunit-bridge": "~3.2", "symfony/phpunit-bridge": "~3.2",
"symfony/polyfill-apcu": "~1.1",
"symfony/security-acl": "~2.8|~3.0" "symfony/security-acl": "~2.8|~3.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "3.2-dev" "dev-master": "3.4-dev"
} }
}, },
"autoload": { "autoload": {
@ -3112,7 +3379,7 @@
"keywords": [ "keywords": [
"framework" "framework"
], ],
"time": "2017-08-01T09:40:44+00:00" "time": "2017-11-03T14:14:19+00:00"
}, },
{ {
"name": "twig/extensions", "name": "twig/extensions",
@ -3713,22 +3980,22 @@
}, },
{ {
"name": "phpdocumentor/reflection-docblock", "name": "phpdocumentor/reflection-docblock",
"version": "3.1.1", "version": "4.1.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
"reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e" "reference": "2d3d238c433cf69caeb4842e97a3223a116f94b2"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/8331b5efe816ae05461b7ca1e721c01b46bafb3e", "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/2d3d238c433cf69caeb4842e97a3223a116f94b2",
"reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e", "reference": "2d3d238c433cf69caeb4842e97a3223a116f94b2",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.5", "php": "^7.0",
"phpdocumentor/reflection-common": "^1.0@dev", "phpdocumentor/reflection-common": "^1.0@dev",
"phpdocumentor/type-resolver": "^0.2.0", "phpdocumentor/type-resolver": "^0.4.0",
"webmozart/assert": "^1.0" "webmozart/assert": "^1.0"
}, },
"require-dev": { "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.", "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", "name": "phpdocumentor/type-resolver",
"version": "0.2.1", "version": "0.4.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git", "url": "https://github.com/phpDocumentor/TypeResolver.git",
"reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb" "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7",
"reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.5", "php": "^5.5 || ^7.0",
"phpdocumentor/reflection-common": "^1.0" "phpdocumentor/reflection-common": "^1.0"
}, },
"require-dev": { "require-dev": {
@ -3801,7 +4068,7 @@
"email": "me@mikevanriel.com" "email": "me@mikevanriel.com"
} }
], ],
"time": "2016-11-25T06:54:22+00:00" "time": "2017-07-14T14:27:02+00:00"
}, },
{ {
"name": "phpspec/prophecy", "name": "phpspec/prophecy",
@ -4938,11 +5205,14 @@
], ],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": [], "stability-flags": {
"symfony/symfony": 20,
"csa/guzzle-bundle": 20
},
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {
"php": ">=7.0.0" "php": ">=7.1.0"
}, },
"platform-dev": [] "platform-dev": []
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -2,33 +2,37 @@
namespace Skobkin\Bundle\PointToolsBundle\Controller\Api; 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\DTO\Api\PostsPage;
use Skobkin\Bundle\PointToolsBundle\Service\Factory\Blogs\PostFactory; use Skobkin\Bundle\PointToolsBundle\Service\Factory\Blogs\PostFactory;
use Symfony\Component\HttpFoundation\{Request, Response}; use Symfony\Component\HttpFoundation\{Request, Response};
class CrawlerController extends AbstractApiController 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'); $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); return $this->createErrorResponse('Token error. Please check it in crawler and API parameters.', Response::HTTP_FORBIDDEN);
} }
$json = $request->request->get('json'); $json = $request->request->get('json');
$serializer = $this->get('jms_serializer');
$page = $serializer->deserialize($json, PostsPage::class, 'json'); $page = $serializer->deserialize($json, PostsPage::class, 'json');
/** @var PostFactory $factory */ $continue = $postFactory->createFromPageDTO($page);
$factory = $this->get('app.point.post_factory');
$continue = $factory->createFromPageDTO($page); $em->flush();
$this->getDoctrine()->getManager()->flush();
return $this->createSuccessResponse([ return $this->createSuccessResponse([
'continue' => $continue, 'continue' => $continue,

View file

@ -3,21 +3,21 @@
namespace Skobkin\Bundle\PointToolsBundle\Controller; namespace Skobkin\Bundle\PointToolsBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Skobkin\Bundle\PointToolsBundle\Entity\SubscriptionEvent; use Skobkin\Bundle\PointToolsBundle\Entity\{SubscriptionEvent, User};
use Skobkin\Bundle\PointToolsBundle\Entity\User; use Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionEventRepository;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
class ApiController extends Controller class ApiController
{ {
/** /**
* Returns last user subscribers log * Returns last user subscribers log
* *
* @ParamConverter("user", class="SkobkinPointToolsBundle:User") * @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 $qb
->select(['se', 'sub']) ->select(['se', 'sub'])
->innerJoin('se.subscriber', '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; namespace Skobkin\Bundle\PointToolsBundle\Controller;
use Doctrine\ORM\EntityManager; use Knp\Component\Pager\Paginator;
use Doctrine\ORM\QueryBuilder; use Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionEventRepository;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\{Request, Response};
use Symfony\Component\HttpFoundation\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( $eventsPagination = $paginator->paginate(
$em->getRepository('SkobkinPointToolsBundle:SubscriptionEvent')->createLastSubscriptionEventsQuery(), $eventRepository->createLastSubscriptionEventsQuery(),
$request->query->getInt('page', 1), $request->query->getInt('page', 1),
20 20
); );

View file

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

View file

@ -3,21 +3,22 @@
namespace Skobkin\Bundle\PointToolsBundle\Controller; namespace Skobkin\Bundle\PointToolsBundle\Controller;
use Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Post; 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 Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
class PostController extends Controller class PostController extends AbstractController
{ {
/** /**
* @ParamConverter("post", class="SkobkinPointToolsBundle:Blogs\Post") * @ParamConverter("post", class="SkobkinPointToolsBundle:Blogs\Post")
* *
* @return Response * @return Response
*/ */
public function showAction(Post $post): Response public function showAction(Post $post, PostRepository $postRepository): Response
{ {
return $this->render('SkobkinPointToolsBundle:Post:show.html.twig', [ 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; namespace Skobkin\Bundle\PointToolsBundle\Controller;
use Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Post; use Knp\Component\Pager\Paginator;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Skobkin\Bundle\PointToolsBundle\Repository\Blogs\PostRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
class PublicFeedController extends Controller class PublicFeedController extends AbstractController
{ {
private const POSTS_PER_PAGE = 20; 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( $postsPagination = $paginator->paginate(
$postRepository->createPublicFeedPostsQuery(), $postRepository->createPublicFeedPostsQuery(),
$request->query->getInt('page', 1), $request->query->getInt('page', 1),

View file

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

View file

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

View file

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

View file

@ -157,7 +157,7 @@ class User
/** /**
* @return Subscription[]|ArrayCollection * @return Subscription[]|ArrayCollection
*/ */
public function getSubscribers(): ArrayCollection public function getSubscribers(): iterable
{ {
return $this->subscribers; return $this->subscribers;
} }
@ -165,7 +165,7 @@ class User
/** /**
* @return Subscription[]|ArrayCollection * @return Subscription[]|ArrayCollection
*/ */
public function getSubscriptions(): ArrayCollection public function getSubscriptions(): iterable
{ {
return $this->subscriptions; return $this->subscriptions;
} }
@ -180,7 +180,7 @@ class User
/** /**
* @return SubscriptionEvent[]|ArrayCollection * @return SubscriptionEvent[]|ArrayCollection
*/ */
public function getNewSubscriberEvents(): ArrayCollection public function getNewSubscriberEvents(): iterable
{ {
return $this->newSubscriberEvents; 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_date", columns={"date"}),
* @ORM\Index(name="idx_rename_log_old_login", columns={"old_login"}) * @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 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: 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\ClientInterface;
use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Exception\TransferException;
use JMS\Serializer\{DeserializationContext, Serializer}; use JMS\Serializer\{
DeserializationContext, SerializerInterface
};
use Psr\Http\Message\{ResponseInterface, StreamInterface}; use Psr\Http\Message\{ResponseInterface, StreamInterface};
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Skobkin\Bundle\PointToolsBundle\Exception\Api\{ForbiddenException, NetworkException, NotFoundException, ServerProblemException, UnauthorizedException}; use Skobkin\Bundle\PointToolsBundle\Exception\Api\{ForbiddenException, NetworkException, NotFoundException, ServerProblemException, UnauthorizedException};
@ -18,7 +20,7 @@ class AbstractApi
protected $client; protected $client;
/** /**
* @var Serializer * @var SerializerInterface
*/ */
protected $serializer; protected $serializer;
@ -38,7 +40,7 @@ class AbstractApi
protected $csRfToken; protected $csRfToken;
public function __construct(ClientInterface $httpClient, Serializer $serializer, LoggerInterface $logger) public function __construct(ClientInterface $httpClient, SerializerInterface $serializer, LoggerInterface $logger)
{ {
$this->client = $httpClient; $this->client = $httpClient;
$this->serializer = $serializer; $this->serializer = $serializer;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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