diff --git a/.env b/.env
index 72c17907d..4147e1afd 100644
--- a/.env
+++ b/.env
@@ -56,3 +56,7 @@ MONGO_PORT=27017
APP_ENV=dev
APP_SECRET=da5a5677b6c493354372096ff690766a
###< symfony/framework-bundle ###
+
+###> sentry/sentry-symfony ###
+SENTRY_DSN=
+###< sentry/sentry-symfony ###
diff --git a/.gitignore b/.gitignore
index fee225caf..b2ba1034b 100755
--- a/.gitignore
+++ b/.gitignore
@@ -2,7 +2,6 @@
*.psd
/nbproject/
-/vendor/
/node_modules/
/var/logs
@@ -10,7 +9,9 @@
.idea
.phpunit.result.cache
-.env.local
+.env.prod
+
+supervisord.pid
###> symfony/framework-bundle ###
/.env.local
diff --git a/composer.json b/composer.json
index ed6fa64f5..84bebc1a9 100644
--- a/composer.json
+++ b/composer.json
@@ -9,6 +9,7 @@
"ext-redis": "*",
"psr/log": "^3.0",
"sentry/sdk": "^3.1",
+ "sentry/sentry-symfony": "^4.2",
"symfony/amqp-messenger": "^6.0",
"symfony/asset": "6.0.*",
"symfony/config": "~6.0",
diff --git a/composer.lock b/composer.lock
index bc971989d..724e7ca2a 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "7d0e359cbe47e3dbc9bb750d09ebe1c8",
+ "content-hash": "ccc9cd4003d2164fce79cb9393b800ee",
"packages": [
{
"name": "clue/stream-filter",
@@ -1344,6 +1344,120 @@
],
"time": "2021-12-27T12:31:24+00:00"
},
+ {
+ "name": "sentry/sentry-symfony",
+ "version": "4.2.6",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/getsentry/sentry-symfony.git",
+ "reference": "c3f2c687b45e3e42573372ac75e643c9e4f3f896"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/getsentry/sentry-symfony/zipball/c3f2c687b45e3e42573372ac75e643c9e4f3f896",
+ "reference": "c3f2c687b45e3e42573372ac75e643c9e4f3f896",
+ "shasum": ""
+ },
+ "require": {
+ "jean85/pretty-package-versions": "^1.5 || ^2.0",
+ "php": "^7.2||^8.0",
+ "php-http/discovery": "^1.11",
+ "sentry/sdk": "^3.1",
+ "symfony/cache-contracts": "^1.1||^2.4||^3.0",
+ "symfony/config": "^3.4.44||^4.4.20||^5.0.11||^6.0",
+ "symfony/console": "^3.4.44||^4.4.20||^5.0.11||^6.0",
+ "symfony/dependency-injection": "^3.4.44||^4.4.20||^5.0.11||^6.0",
+ "symfony/event-dispatcher": "^3.4.44||^4.4.20||^5.0.11||^6.0",
+ "symfony/http-kernel": "^3.4.44||^4.4.20||^5.0.11||^6.0",
+ "symfony/polyfill-php80": "^1.22",
+ "symfony/psr-http-message-bridge": "^1.2||^2.0",
+ "symfony/security-core": "^3.4.44||^4.4.20||^5.0.11||^6.0"
+ },
+ "require-dev": {
+ "doctrine/dbal": "^2.13||^3.0",
+ "doctrine/doctrine-bundle": "^1.12||^2.5",
+ "friendsofphp/php-cs-fixer": "^2.18",
+ "jangregor/phpstan-prophecy": "^0.8",
+ "monolog/monolog": "^1.3||^2.0",
+ "phpspec/prophecy": "!=1.11.0",
+ "phpspec/prophecy-phpunit": "^1.1||^2.0",
+ "phpstan/extension-installer": "^1.0",
+ "phpstan/phpstan": "^0.12",
+ "phpstan/phpstan-phpunit": "^0.12",
+ "phpunit/phpunit": "^8.5.14||^9.3.9",
+ "symfony/browser-kit": "^3.4.44||^4.4.20||^5.0.11||^6.0",
+ "symfony/cache": "^3.4.44||^4.4.20||^5.0.11||^6.0",
+ "symfony/dom-crawler": "^3.4.44||^4.4.20||^5.0.11||^6.0",
+ "symfony/framework-bundle": "^3.4.44||^4.4.20||^5.0.11||^6.0",
+ "symfony/messenger": "^4.4.20||^5.0.11||^6.0",
+ "symfony/monolog-bundle": "^3.4",
+ "symfony/phpunit-bridge": "^5.2.6||^6.0",
+ "symfony/process": "^3.4.44||^4.4.20||^5.0.11||^6.0",
+ "symfony/twig-bundle": "^3.4.44||^4.4.20||^5.0.11||^6.0",
+ "symfony/yaml": "^3.4.44||^4.4.20||^5.0.11||^6.0",
+ "vimeo/psalm": "^4.3"
+ },
+ "suggest": {
+ "doctrine/doctrine-bundle": "Allow distributed tracing of database queries using Sentry.",
+ "monolog/monolog": "Allow sending log messages to Sentry by using the included Monolog handler.",
+ "symfony/cache": "Allow distributed tracing of cache pools using Sentry.",
+ "symfony/twig-bundle": "Allow distributed tracing of Twig template rendering using Sentry."
+ },
+ "type": "symfony-bundle",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "4.2.x-dev",
+ "releases/3.2.x": "3.2.x-dev",
+ "releases/2.x": "2.x-dev",
+ "releases/1.x": "1.x-dev"
+ }
+ },
+ "autoload": {
+ "files": [
+ "src/aliases.php"
+ ],
+ "psr-4": {
+ "Sentry\\SentryBundle\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache-2.0"
+ ],
+ "authors": [
+ {
+ "name": "David Cramer",
+ "email": "dcramer@gmail.com"
+ },
+ {
+ "name": "Alessandro Lai",
+ "email": "alessandro.lai85@gmail.com"
+ }
+ ],
+ "description": "Symfony integration for Sentry (http://getsentry.com)",
+ "homepage": "http://getsentry.com",
+ "keywords": [
+ "errors",
+ "logging",
+ "sentry",
+ "symfony"
+ ],
+ "support": {
+ "issues": "https://github.com/getsentry/sentry-symfony/issues",
+ "source": "https://github.com/getsentry/sentry-symfony/tree/4.2.6"
+ },
+ "funding": [
+ {
+ "url": "https://sentry.io/",
+ "type": "custom"
+ },
+ {
+ "url": "https://sentry.io/pricing/",
+ "type": "custom"
+ }
+ ],
+ "time": "2022-01-10T08:56:54+00:00"
+ },
{
"name": "symfony/amqp-messenger",
"version": "v6.0.1",
@@ -3202,6 +3316,78 @@
],
"time": "2021-11-23T19:05:29+00:00"
},
+ {
+ "name": "symfony/password-hasher",
+ "version": "v6.0.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/password-hasher.git",
+ "reference": "4d04edcbcee4a97f39c72d1cf6149681d634e63f"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/password-hasher/zipball/4d04edcbcee4a97f39c72d1cf6149681d634e63f",
+ "reference": "4d04edcbcee4a97f39c72d1cf6149681d634e63f",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.0.2"
+ },
+ "conflict": {
+ "symfony/security-core": "<5.4"
+ },
+ "require-dev": {
+ "symfony/console": "^5",
+ "symfony/security-core": "^5.4|^6.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\PasswordHasher\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Robin Chalas",
+ "email": "robin.chalas@gmail.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Provides password hashing utilities",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "hashing",
+ "password"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/password-hasher/tree/v6.0.3"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-01-02T09:55:41+00:00"
+ },
{
"name": "symfony/polyfill-intl-grapheme",
"version": "v1.24.0",
@@ -3611,6 +3797,94 @@
],
"time": "2021-10-20T20:35:02+00:00"
},
+ {
+ "name": "symfony/psr-http-message-bridge",
+ "version": "v2.1.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/psr-http-message-bridge.git",
+ "reference": "22b37c8a3f6b5d94e9cdbd88e1270d96e2f97b34"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/psr-http-message-bridge/zipball/22b37c8a3f6b5d94e9cdbd88e1270d96e2f97b34",
+ "reference": "22b37c8a3f6b5d94e9cdbd88e1270d96e2f97b34",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.1",
+ "psr/http-message": "^1.0",
+ "symfony/http-foundation": "^4.4 || ^5.0 || ^6.0"
+ },
+ "require-dev": {
+ "nyholm/psr7": "^1.1",
+ "psr/log": "^1.1 || ^2 || ^3",
+ "symfony/browser-kit": "^4.4 || ^5.0 || ^6.0",
+ "symfony/config": "^4.4 || ^5.0 || ^6.0",
+ "symfony/event-dispatcher": "^4.4 || ^5.0 || ^6.0",
+ "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0",
+ "symfony/http-kernel": "^4.4 || ^5.0 || ^6.0",
+ "symfony/phpunit-bridge": "^5.4@dev || ^6.0"
+ },
+ "suggest": {
+ "nyholm/psr7": "For a super lightweight PSR-7/17 implementation"
+ },
+ "type": "symfony-bridge",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "2.1-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Bridge\\PsrHttpMessage\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ }
+ ],
+ "description": "PSR HTTP message bridge",
+ "homepage": "http://symfony.com",
+ "keywords": [
+ "http",
+ "http-message",
+ "psr-17",
+ "psr-7"
+ ],
+ "support": {
+ "issues": "https://github.com/symfony/psr-http-message-bridge/issues",
+ "source": "https://github.com/symfony/psr-http-message-bridge/tree/v2.1.2"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2021-11-05T13:13:39+00:00"
+ },
{
"name": "symfony/routing",
"version": "v6.0.1",
@@ -3775,6 +4049,97 @@
],
"time": "2021-11-07T13:29:17+00:00"
},
+ {
+ "name": "symfony/security-core",
+ "version": "v6.0.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/security-core.git",
+ "reference": "eccb5675df44b2d7f3ad3a936c09ee8cb8340de5"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/security-core/zipball/eccb5675df44b2d7f3ad3a936c09ee8cb8340de5",
+ "reference": "eccb5675df44b2d7f3ad3a936c09ee8cb8340de5",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.0.2",
+ "symfony/event-dispatcher-contracts": "^1.1|^2|^3",
+ "symfony/password-hasher": "^5.4|^6.0",
+ "symfony/service-contracts": "^1.1.6|^2|^3"
+ },
+ "conflict": {
+ "symfony/event-dispatcher": "<5.4",
+ "symfony/http-foundation": "<5.4",
+ "symfony/ldap": "<5.4",
+ "symfony/security-guard": "<5.4",
+ "symfony/validator": "<5.4"
+ },
+ "require-dev": {
+ "psr/cache": "^1.0|^2.0|^3.0",
+ "psr/container": "^1.1|^2.0",
+ "psr/log": "^1|^2|^3",
+ "symfony/cache": "^5.4|^6.0",
+ "symfony/event-dispatcher": "^5.4|^6.0",
+ "symfony/expression-language": "^5.4|^6.0",
+ "symfony/http-foundation": "^5.4|^6.0",
+ "symfony/ldap": "^5.4|^6.0",
+ "symfony/translation": "^5.4|^6.0",
+ "symfony/validator": "^5.4|^6.0"
+ },
+ "suggest": {
+ "psr/container-implementation": "To instantiate the Security class",
+ "symfony/event-dispatcher": "",
+ "symfony/expression-language": "For using the expression voter",
+ "symfony/http-foundation": "",
+ "symfony/ldap": "For using LDAP integration",
+ "symfony/validator": "For using the user password constraint"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Security\\Core\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony Security Component - Core Library",
+ "homepage": "https://symfony.com",
+ "support": {
+ "source": "https://github.com/symfony/security-core/tree/v6.0.3"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-01-02T09:55:41+00:00"
+ },
{
"name": "symfony/service-contracts",
"version": "v3.0.0",
diff --git a/config/bundles.php b/config/bundles.php
index 8ec35088f..92d7174ff 100644
--- a/config/bundles.php
+++ b/config/bundles.php
@@ -6,4 +6,5 @@
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true],
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
+ Sentry\SentryBundle\SentryBundle::class => ['all' => true],
];
diff --git a/config/packages/sentry.yaml b/config/packages/sentry.yaml
new file mode 100644
index 000000000..342036fe4
--- /dev/null
+++ b/config/packages/sentry.yaml
@@ -0,0 +1,2 @@
+sentry:
+ dsn: '%env(SENTRY_DSN)%'
diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml
new file mode 100644
index 000000000..fdd9b073c
--- /dev/null
+++ b/docker-compose.prod.yml
@@ -0,0 +1,44 @@
+version: '3'
+
+volumes:
+ caddy_data:
+ caddy_config:
+
+services:
+ phpfpm:
+ container_name: kalaxia_app
+ build: docker/fpm
+ env_file: '.env.prod'
+ volumes:
+ - "./:/srv/app"
+ networks:
+ - asylamba
+
+ caddy:
+ container_name: kalaxia_caddy_webserver
+ image: caddy
+ depends_on:
+ - 'phpfpm'
+ ports:
+ - '80:80'
+ - '443:443'
+ volumes:
+ - './docker/caddy/Caddyfile:/etc/caddy/Caddyfile'
+ - './:/srv/app'
+ - caddy_data:/data
+ - caddy_config:/config
+ networks:
+ - asylamba
+
+ supervisord:
+ container_name: kalaxia_worker
+ build: docker/supervisord
+ env_file: '.env.prod'
+ volumes:
+ - "./:/srv/app"
+ - "./var/logs/supervisord/:/var/log/supervisord/"
+ - "./supervisord.conf:/etc/supervisor/supervisord.conf"
+ networks:
+ - asylamba
+
+
diff --git a/docker-compose.yml b/docker-compose.yml
index 095fc6754..601cba799 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,4 +1,5 @@
version: "3"
+
networks:
asylamba:
driver: bridge
diff --git a/docker/caddy/Caddyfile b/docker/caddy/Caddyfile
new file mode 100644
index 000000000..6f7f712ce
--- /dev/null
+++ b/docker/caddy/Caddyfile
@@ -0,0 +1,14 @@
+api.kalaxia.com {
+ root * /srv/app/public
+ php_fastcgi /* kalaxia_app:9000
+ file_server
+
+ basicauth /* {
+ kalaxia JDJhJDE0JDlWOXN6OEF1Q1NIbmdVU29ySEJTL3V1U2suY1JSb2xLL3lCRnlaVkNZOU9uanlKMTVmZnNt
+ }
+
+ # Enable HTTP request logging
+ log {
+ output file /var/log/caddy/access.log
+ }
+}
diff --git a/docker/fpm/Dockerfile b/docker/fpm/Dockerfile
new file mode 100644
index 000000000..aa09f4c51
--- /dev/null
+++ b/docker/fpm/Dockerfile
@@ -0,0 +1,29 @@
+FROM php:8.1-fpm-alpine
+
+# Install SUPERVISOR and dependencies
+RUN apk update
+
+RUN apk add rabbitmq-c-dev icu-dev
+
+# Install PHP etxensions
+RUN apk --no-cache add pcre-dev ${PHPIZE_DEPS} \
+ && docker-php-ext-configure intl \
+ && docker-php-ext-install pdo_mysql intl opcache \
+ && pecl install amqp redis \
+ && docker-php-ext-enable amqp pdo_mysql redis \
+ && apk del pcre-dev ${PHPIZE_DEPS}
+
+RUN curl -s https://getcomposer.org/installer | php
+RUN alias composer="php composer.phar"
+
+COPY cron/ /etc/periodic/
+
+RUN chmod -R a+x /etc/periodic/
+
+COPY docker-entrypoint.sh /entrypoint.sh
+
+RUN chmod a+x /entrypoint.sh
+
+WORKDIR /srv/app
+
+ENTRYPOINT ["/entrypoint.sh"]
diff --git a/docker/fpm/cron/daily/daily_tasks.sh b/docker/fpm/cron/daily/daily_tasks.sh
new file mode 100644
index 000000000..ea22d2cb5
--- /dev/null
+++ b/docker/fpm/cron/daily/daily_tasks.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+php bin/console app:hephaistos:execute-daily-tasks
diff --git a/docker/fpm/cron/hourly/hourly_tasks.sh b/docker/fpm/cron/hourly/hourly_tasks.sh
new file mode 100644
index 000000000..c74323f85
--- /dev/null
+++ b/docker/fpm/cron/hourly/hourly_tasks.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+php bin/console app:hephaistos:execute-hourly-tasks
diff --git a/docker/fpm/docker-entrypoint.sh b/docker/fpm/docker-entrypoint.sh
new file mode 100644
index 000000000..c9617a267
--- /dev/null
+++ b/docker/fpm/docker-entrypoint.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+crond -f -l 8 &
+
+php-fpm
diff --git a/docker/supervisord/Dockerfile b/docker/supervisord/Dockerfile
new file mode 100644
index 000000000..53058dbd7
--- /dev/null
+++ b/docker/supervisord/Dockerfile
@@ -0,0 +1,18 @@
+FROM php:8.1-cli-alpine
+
+# Install SUPERVISOR and dependencies
+RUN apk update
+
+RUN apk add supervisor wget rabbitmq-c-dev icu-dev
+
+# Install PHP etxensions
+RUN apk --no-cache add pcre-dev ${PHPIZE_DEPS} \
+ && docker-php-ext-configure intl \
+ && docker-php-ext-install pdo_mysql intl opcache \
+ && pecl install amqp redis \
+ && docker-php-ext-enable amqp pdo_mysql redis \
+ && apk del pcre-dev ${PHPIZE_DEPS}
+
+WORKDIR /srv/app
+
+CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 303bfaa07..8aa43476e 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -27,6 +27,10 @@
+
+
+
+
diff --git a/src/Classes/Database/Database.php b/src/Classes/Database/Database.php
index c7e2c2c5c..7819cfd4a 100644
--- a/src/Classes/Database/Database.php
+++ b/src/Classes/Database/Database.php
@@ -32,22 +32,16 @@ public function init($dumpFile)
public function refresh()
{
- try {
- // Close previous connection
- $this->connection = null;
- $this->connection = new \PDO(
- "mysql:dbname={$this->name};host={$this->host};charset=utf8",
- $this->user,
- $this->password,
- [
- \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
- \PDO::ATTR_EMULATE_PREPARES => false,
- \PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC
- ]
- );
- } catch (\PDOException $e) {
- die('Erreur de connection à la base de données : ' . $e->getMessage());
- }
+ $this->connection = new \PDO(
+ "mysql:dbname={$this->name};host={$this->host};charset=utf8",
+ $this->user,
+ $this->password,
+ [
+ \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
+ \PDO::ATTR_EMULATE_PREPARES => false,
+ \PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC
+ ]
+ );
}
public function beginTransaction(): bool
diff --git a/src/Classes/Kernel/ApplicationKernel.php b/src/Classes/Kernel/ApplicationKernel.php
deleted file mode 100644
index b053dfa09..000000000
--- a/src/Classes/Kernel/ApplicationKernel.php
+++ /dev/null
@@ -1,102 +0,0 @@
-container = $this->buildContainer();
- $this->container->compile(true);
-
- $this->buildTwig();
-
- $this->init();
- }
-
- public function buildTwig(): void
- {
- $loader = new \Twig\Loader\FilesystemLoader($this->projectDir.'/templates');
- $twig = new Environment($loader, [
- 'cache' => $this->projectDir . '/var/cache/twig',
- ]);
- $this->container->set(Environment::class, $twig);
-
- foreach (['app_description', 'app_subname', 'media', 'css'] as $variable) {
- $twig->addGlobal($variable, $this->container->getParameter($variable));
- }
- }
-
- public function init(): void
- {
- if (!empty($sentryDsn = $this->container->getParameter('sentry_dsn'))) {
- $this->initSentry($sentryDsn);
- }
- $this->container->get(Database::class)->init($this->container->getParameter('root_path') . '/build/database/structure.sql');
- $this->container->get(EntityManager::class)->init();
- $this->container->get(CyclicActionScheduler::class)->init();
- $this->container->get(SectorManager::class)->initOwnershipData();
-
- $this->bootSymfonyKernel();
- }
-
- public function bootSymfonyKernel()
- {
- $loader = new YamlFileLoader(new FileLocator($this->projectDir . '/config/routes/'));
- $routes = $loader->load('routes.yaml');
- $matcher = new UrlMatcher($routes, new RequestContext());
-
- /** @var EventDispatcherInterface $eventDispatcher */
- $eventDispatcher = $this->container->get(EventDispatcherInterface::class);
- $eventDispatcher->dispatch(new ServerInitEvent(), ServerInitEvent::NAME);
- $eventDispatcher->addSubscriber(new RouterListener($matcher, new RequestStack()));
-
- $request = Request::createFromGlobals();
- $this->container->set(Request::class, $request);
-
- // create your controller and argument resolvers
- $controllerResolver = new ControllerResolver();
- $argumentResolver = new ArgumentResolver();
-
- // instantiate the kernel
- $kernel = new HttpKernel($eventDispatcher, $controllerResolver, new RequestStack(), $argumentResolver);
-
- // actually execute the kernel, which turns the request into a response
- // by dispatching events, calling a controller, and returning the response
- $response = $kernel->handle($request);
-
- // send the headers and echo the content
- $response->send();
-
- // trigger the kernel.terminate event
- $kernel->terminate($request, $response);
- }
-}
diff --git a/src/Classes/Kernel/Kernel.php b/src/Classes/Kernel/Kernel.php
deleted file mode 100644
index 8df7d4ee9..000000000
--- a/src/Classes/Kernel/Kernel.php
+++ /dev/null
@@ -1,129 +0,0 @@
-set('container', $containerBuilder);
- $containerBuilder->setParameter('root_path', $this->projectDir);
- $this->buildEventDispatcher($containerBuilder);
-
- $this->loadEnvironment($containerBuilder);
-
- $loader = new YamlFileLoader($containerBuilder, new FileLocator($this->projectDir . '/config/'));
- $loader->load('services.yml');
-
- $this->buildMessenger($containerBuilder);
-
- $this->registerModules($containerBuilder);
- $containerBuilder->registerForAutoconfiguration(Manager::class)->addTag('app.stateful_manager');
-
- return $containerBuilder;
- }
-
- protected function buildEventDispatcher(ContainerBuilder $containerBuilder): void
- {
- $containerBuilder->addCompilerPass(new RegisterListenersPass());
- $containerBuilder->register(EventDispatcherInterface::class, EventDispatcher::class);
- $containerBuilder->setAlias('event_dispatcher', EventDispatcherInterface::class);
- }
-
- protected function buildMessenger(ContainerBuilder $containerBuilder): void
- {
- $containerBuilder->addCompilerPass(new MessengerPass());
-
- $enableLogs = $containerBuilder->resolveEnvPlaceholders($containerBuilder->getParameter('messenger_logs'), true);
-
- if (true === $enableLogs) {
- return;
- }
-
- $workerDefinition = $containerBuilder->getDefinition(Worker::class);
- $workerDefinition->setArgument('$logger', null);
- }
-
- protected function initSentry(string $dsn): void
- {
- \Sentry\init(['dsn' => $dsn]);
- }
-
- protected function loadEnvironment(ContainerBuilder $container): void
- {
- foreach(explode(',', getenv('SYMFONY_DOTENV_VARS')) as $key) {
- $container->setParameter(strtolower($key), getenv($key));
- }
- }
-
- protected function registerModules(ContainerBuilder $containerBuilder): void
- {
- foreach ($this->getRegisteredModules() as $moduleClass) {
- /** @var Module $module */
- $module = new $moduleClass();
- $module->configure($containerBuilder, $this->projectDir);
-
- $this->modules[strtolower($module->getName())] = $module;
- }
- }
-
- protected function getRegisteredModules(): array
- {
- return [
- AresModule::class,
- ArtemisModule::class,
- AthenaModule::class,
- AtlasModule::class,
- DemeterModule::class,
- GaiaModule::class,
- HephaistosModule::class,
- HermesModule::class,
- PrometheeModule::class,
- ZeusModule::class,
- ];
- }
-
- public function getModules(): array
- {
- return $this->modules;
- }
-
- public function getModule(string $name): Module
- {
- return $this->modules[$name];
- }
-
- public function getContainer(): ContainerBuilder
- {
- return $this->container;
- }
-}
diff --git a/src/Classes/Kernel/KernelInterface.php b/src/Classes/Kernel/KernelInterface.php
deleted file mode 100644
index d6edc0b81..000000000
--- a/src/Classes/Kernel/KernelInterface.php
+++ /dev/null
@@ -1,10 +0,0 @@
-container = $this->buildContainer();
- $this->container->setParameter('app.name', $this->name);
- $this->container->compile(true);
- $this->init();
- }
-
- public function init(): void
- {
- if (!empty($sentryDsn = $this->container->getParameter('sentry_dsn'))) {
- $this->initSentry($sentryDsn);
- }
- $this->container->get(Database::class)->init($this->container->getParameter('root_path') . '/build/database/structure.sql');
- $this->container->get(EntityManager::class)->init();
- $this->container->get(Worker::class)->run();
- }
-}
diff --git a/src/Classes/Scheduler/CyclicActionScheduler.php b/src/Classes/Scheduler/CyclicActionScheduler.php
index f39b273fd..ed5eabcec 100644
--- a/src/Classes/Scheduler/CyclicActionScheduler.php
+++ b/src/Classes/Scheduler/CyclicActionScheduler.php
@@ -14,8 +14,6 @@
class CyclicActionScheduler
{
- protected ?int $lastExecutedDay = null;
- protected ?int $lastExecutedHour = null;
/** @var array> **/
protected array $queues = [
self::TYPE_DAILY => [
@@ -41,33 +39,14 @@ public function __construct(
) {
}
- public function init(): void
- {
- $this->execute();
- }
-
- public function execute()
- {
- if (($currentHour = intval(date('H'))) === $this->lastExecutedHour) {
- return;
- }
- $this->executeHourly();
- $this->executeDaily($currentHour);
- $this->lastExecutedHour = $currentHour;
- }
-
- protected function executeHourly(): void
+ public function executeHourlyTasks(): void
{
$this->processQueue(self::TYPE_HOURLY);
}
- protected function executeDaily(int $currentHour): void
+ public function executeDailyTasks(): void
{
- if (($currentDay = intval(date('d'))) === $this->lastExecutedDay || ($currentHour < $this->dailyScriptHour)) {
- return;
- }
$this->processQueue(self::TYPE_DAILY);
- $this->lastExecutedDay = $currentDay;
}
protected function processQueue(string $queue): void
diff --git a/src/Modules/Hephaistos/Resource/config/config.yml b/src/Modules/Hephaistos/Resource/config/config.yml
index b361f294c..626617360 100644
--- a/src/Modules/Hephaistos/Resource/config/config.yml
+++ b/src/Modules/Hephaistos/Resource/config/config.yml
@@ -12,10 +12,17 @@ services:
- '../../Repository'
- '../../Resource'
+ App\Modules\Hephaistos\Ui\Cli\PopulateDatabase:
+ arguments:
+ $jeanMiId: '%id_jeanmi%'
+ $availableFactions: '%game.available_factions%'
+
App\Modules\Hephaistos\Ui\Cli\ScheduleActions:
arguments:
$schedulers: !tagged_iterator app.scheduler
+
+
App\Modules\Hephaistos\Handler\DailyRoutineHandler:
arguments:
$apiMode: "%apimode%"
diff --git a/src/Modules/Hephaistos/Ui/Cli/ExecuteDailyTasks.php b/src/Modules/Hephaistos/Ui/Cli/ExecuteDailyTasks.php
new file mode 100644
index 000000000..2596ec93b
--- /dev/null
+++ b/src/Modules/Hephaistos/Ui/Cli/ExecuteDailyTasks.php
@@ -0,0 +1,28 @@
+cyclicActionScheduler->executeDailyTasks();
+
+ return self::SUCCESS;
+ }
+}
diff --git a/src/Modules/Hephaistos/Ui/Cli/ExecuteHourlyTasks.php b/src/Modules/Hephaistos/Ui/Cli/ExecuteHourlyTasks.php
new file mode 100644
index 000000000..a2931ede6
--- /dev/null
+++ b/src/Modules/Hephaistos/Ui/Cli/ExecuteHourlyTasks.php
@@ -0,0 +1,28 @@
+cyclicActionScheduler->executeHourlyTasks();
+
+ return self::SUCCESS;
+ }
+}
diff --git a/src/script/scripts/deploy/dbinstall.php b/src/Modules/Hephaistos/Ui/Cli/PopulateDatabase.php
old mode 100755
new mode 100644
similarity index 61%
rename from src/script/scripts/deploy/dbinstall.php
rename to src/Modules/Hephaistos/Ui/Cli/PopulateDatabase.php
index ec857185d..11ede35c9
--- a/src/script/scripts/deploy/dbinstall.php
+++ b/src/Modules/Hephaistos/Ui/Cli/PopulateDatabase.php
@@ -1,24 +1,55 @@
getContainer();
-$availableFactions = $this->getContainer()->getParameter('game.available_factions');
-$db = $this->getContainer()->get(\App\Classes\Database\DatabaseAdmin::class);
-
-$db->query('SET FOREIGN_KEY_CHECKS = 0;');
+use Symfony\Component\Console\Attribute\AsCommand;
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+#[AsCommand(
+ name: 'app:hephaistos:populate-database',
+ description: 'fill the database and set it to ready state for a new game',
+)]
+class PopulateDatabase extends Command
+{
+ public function __construct(
+ private DatabaseAdmin $database,
+ private GalaxyGenerator $galaxyGenerator,
+ private PlayerManager $playerManager,
+ private ConversationManager $conversationManager,
+ private ConversationUserManager $conversationUserManager,
+ private ColorManager $colorManager,
+ private array $availableFactions,
+ private int $jeanMiId,
+ ) {
+ parent::__construct();
+ }
+
+ public function execute(InputInterface $input, OutputInterface $output): int
+ {
+ $this->database->query('SET FOREIGN_KEY_CHECKS = 0;');
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table color
';
+ $output->writeln('Ajout de la table color');;
-$db->query("DROP TABLE IF EXISTS `color`");
-$db->query("CREATE TABLE IF NOT EXISTS `color` (
+ $this->database->query("DROP TABLE IF EXISTS `color`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `color` (
`id` INT unsigned NOT NULL,
`alive` TINYINT NOT NULL DEFAULT 0,
@@ -40,22 +71,22 @@
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
-echo 'Remplissage de la table color
';
-$qr = $db->prepare("INSERT INTO `color` (`id`, `alive`, `credits`, `players`, `activePlayers`, `points`, `sectors`, `regime`, `electionStatement`, `isClosed`, `isInGame`, `description`, `dClaimVictory`, `dLastElection`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, ?)");
-$date = Utils::addSecondsToDate(Utils::now(), - 500000);
+ $output->writeln('Remplissage de la table color');
+ $qr = $this->database->prepare("INSERT INTO `color` (`id`, `alive`, `credits`, `players`, `activePlayers`, `points`, `sectors`, `regime`, `electionStatement`, `isClosed`, `isInGame`, `description`, `dClaimVictory`, `dLastElection`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, ?)");
+ $date = Utils::addSecondsToDate(Utils::now(), -500000);
# génération de la faction zero
-$qr->execute(array(0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, $date));
+ $qr->execute(array(0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, $date));
# génération des factions disponibles
-foreach ($availableFactions as $faction) {
- $qr->execute(array($faction, 1, 0, 0, 0, 0, 0, ColorResource::getInfo($faction, 'regime'), 1, 0, 1, $date));
-}
+ foreach ($this->availableFactions as $faction) {
+ $qr->execute(array($faction, 1, 0, 0, 0, 0, 0, ColorResource::getInfo($faction, 'regime'), 1, 0, 1, $date));
+ }
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table factionNews
';
+ $output->writeln('Ajout de la table factionNews');;
-$db->query("DROP TABLE IF EXISTS `factionNews`");
-$db->query("CREATE TABLE IF NOT EXISTS `factionNews` (
+ $this->database->query("DROP TABLE IF EXISTS `factionNews`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `factionNews` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rFaction` INT unsigned NOT NULL,
@@ -72,108 +103,106 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table player
';
-
-$db->query("DROP TABLE IF EXISTS `player`");
-$db->query("CREATE TABLE IF NOT EXISTS `player` (
- `id` INT unsigned NOT NULL AUTO_INCREMENT,
- `rColor` INT unsigned NOT NULL,
- `rGodfather` INT unsigned NULL,
-
- `bind` varchar(50) default NULL,
- `name` varchar(25) NOT NULL,
- `avatar` varchar(12) NOT NULL,
- `sex` TINYINT NOT NULL DEFAULT 1,
- `status` SMALLINT unsigned NOT NULL DEFAULT 1,
- `credit` BIGINT unsigned NOT NULL DEFAULT 0,
- `experience` INT unsigned NOT NULL DEFAULT 0,
- `factionPoint` INT unsigned NOT NULL DEFAULT 0,
- `level` TINYINT unsigned DEFAULT NULL DEFAULT 0,
- `victory` INT unsigned DEFAULT NULL DEFAULT 0,
- `defeat` INT unsigned DEFAULT NULL DEFAULT 0,
- `premium` TINYINT NOT NULL DEFAULT 0,
- `statement` TINYINT NOT NULL DEFAULT 0,
- `description` text DEFAULT NULL,
-
- `stepTutorial` TINYINT unsigned DEFAULT NULL,
- `stepDone` TINYINT unsigned NOT NULL DEFAULT 0,
-
- `iUniversity` INT unsigned NOT NULL DEFAULT 0,
- `partNaturalSciences` TINYINT unsigned NOT NULL DEFAULT 0,
- `partLifeSciences` TINYINT unsigned NOT NULL DEFAULT 0,
- `partSocialPoliticalSciences` TINYINT unsigned NOT NULL DEFAULT 0,
- `partInformaticEngineering` TINYINT unsigned NOT NULL DEFAULT 0,
-
- `dInscription` datetime DEFAULT NULL,
- `dLastConnection` datetime DEFAULT NULL,
- `dLastActivity` datetime DEFAULT NULL,
- `uPlayer` datetime DEFAULT NULL,
-
- PRIMARY KEY (`id`),
- UNIQUE KEY `name_UNIQUE` (`name`),
- CONSTRAINT fkPlayerColor FOREIGN KEY (rColor) REFERENCES color(id),
- CONSTRAINT fkPlayerPlayer FOREIGN KEY (rGodfather) REFERENCES player(id)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT = 1;");
-
-#--------------------------------------------------------------------------------------------
-echo 'Ajout du Joueur Gaia
';
-
-$playerManager = $this->getContainer()->get(\App\Modules\Zeus\Manager\PlayerManager::class);
-
-$p = new Player();
-$p->status = 1;
-$p->credit = 10000000;
-$p->uPlayer = Utils::now();
-$p->experience = 15000;
-$p->factionPoint = 0;
-$p->level = 5;
-$p->victory = 0;
-$p->defeat = 0;
-$p->stepTutorial = 0;
-$p->stepDone = 0;
-$p->iUniversity = 0;
-$p->partNaturalSciences = 25;
-$p->partLifeSciences = 25;
-$p->partSocialPoliticalSciences = 25;
-$p->partInformaticEngineering = 25;
-$p->dInscription = Utils::now();
-$p->dLastConnection = Utils::now();
-$p->dLastActivity = Utils::now();
-$p->premium = 0;
-$p->statement = Player::DEAD;
+ $output->writeln('Ajout de la table player');;
+
+ $this->database->query("DROP TABLE IF EXISTS `player`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `player` (
+ `id` INT unsigned NOT NULL AUTO_INCREMENT,
+ `rColor` INT unsigned NOT NULL,
+ `rGodfather` INT unsigned NULL,
+
+ `bind` varchar(50) default NULL,
+ `name` varchar(25) NOT NULL,
+ `avatar` varchar(12) NOT NULL,
+ `sex` TINYINT NOT NULL DEFAULT 1,
+ `status` SMALLINT unsigned NOT NULL DEFAULT 1,
+ `credit` BIGINT unsigned NOT NULL DEFAULT 0,
+ `experience` INT unsigned NOT NULL DEFAULT 0,
+ `factionPoint` INT unsigned NOT NULL DEFAULT 0,
+ `level` TINYINT unsigned DEFAULT NULL DEFAULT 0,
+ `victory` INT unsigned DEFAULT NULL DEFAULT 0,
+ `defeat` INT unsigned DEFAULT NULL DEFAULT 0,
+ `premium` TINYINT NOT NULL DEFAULT 0,
+ `statement` TINYINT NOT NULL DEFAULT 0,
+ `description` text DEFAULT NULL,
+
+ `stepTutorial` TINYINT unsigned DEFAULT NULL,
+ `stepDone` TINYINT unsigned NOT NULL DEFAULT 0,
+
+ `iUniversity` INT unsigned NOT NULL DEFAULT 0,
+ `partNaturalSciences` TINYINT unsigned NOT NULL DEFAULT 0,
+ `partLifeSciences` TINYINT unsigned NOT NULL DEFAULT 0,
+ `partSocialPoliticalSciences` TINYINT unsigned NOT NULL DEFAULT 0,
+ `partInformaticEngineering` TINYINT unsigned NOT NULL DEFAULT 0,
+
+ `dInscription` datetime DEFAULT NULL,
+ `dLastConnection` datetime DEFAULT NULL,
+ `dLastActivity` datetime DEFAULT NULL,
+ `uPlayer` datetime DEFAULT NULL,
+
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `name_UNIQUE` (`name`),
+ CONSTRAINT fkPlayerColor FOREIGN KEY (rColor) REFERENCES color(id),
+ CONSTRAINT fkPlayerPlayer FOREIGN KEY (rGodfather) REFERENCES player(id)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT = 1;");
+
+ #--------------------------------------------------------------------------------------------
+ $output->writeln('Ajout du Joueur Gaia');
+
+ $p = new Player();
+ $p->status = 1;
+ $p->credit = 10000000;
+ $p->uPlayer = Utils::now();
+ $p->experience = 15000;
+ $p->factionPoint = 0;
+ $p->level = 5;
+ $p->victory = 0;
+ $p->defeat = 0;
+ $p->stepTutorial = 0;
+ $p->stepDone = 0;
+ $p->iUniversity = 0;
+ $p->partNaturalSciences = 25;
+ $p->partLifeSciences = 25;
+ $p->partSocialPoliticalSciences = 25;
+ $p->partInformaticEngineering = 25;
+ $p->dInscription = Utils::now();
+ $p->dLastConnection = Utils::now();
+ $p->dLastActivity = Utils::now();
+ $p->premium = 0;
+ $p->statement = Player::DEAD;
# Joueur rebelle
-$p = clone($p);
-$p->bind = Utils::generateString(25);
-$p->name = 'Rebelle';
-$p->avatar = 'rebel';
-$p->rColor = 0;
-$playerManager->add($p);
+ $p = clone($p);
+ $p->bind = Utils::generateString(25);
+ $p->name = 'Rebelle';
+ $p->avatar = 'rebel';
+ $p->rColor = 0;
+ $this->playerManager->add($p);
# Jean-Mi
-$p = clone($p);
-$p->bind = Utils::generateString(25);
-$p->name = 'Jean-Mi';
-$p->avatar = 'jm';
-$p->rColor = 0;
-$playerManager->add($p);
+ $p = clone($p);
+ $p->bind = Utils::generateString(25);
+ $p->name = 'Jean-Mi';
+ $p->avatar = 'jm';
+ $p->rColor = 0;
+ $this->playerManager->add($p);
# Joueurs de factions
-foreach ($availableFactions as $faction) {
- $p = clone($p);
- $p->bind = Utils::generateString(25);
- $p->name = ColorResource::getInfo($faction, 'officialName');
- $p->avatar = ('color-' . $faction);
- $p->rColor = $faction;
- $p->status = 6;
- $playerManager->add($p);
-}
+ foreach ($this->availableFactions as $faction) {
+ $p = clone($p);
+ $p->bind = Utils::generateString(25);
+ $p->name = ColorResource::getInfo($faction, 'officialName');
+ $p->avatar = ('color-' . $faction);
+ $p->rColor = $faction;
+ $p->status = 6;
+ $this->playerManager->add($p);
+ }
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table sector
';
+ $output->writeln('Ajout de la table sector');;
-$db->query("DROP TABLE IF EXISTS `sector`");
-$db->query("CREATE TABLE IF NOT EXISTS `sector` (
+ $this->database->query("DROP TABLE IF EXISTS `sector`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `sector` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rColor` INT unsigned NOT NULL,
`rSurrender` INT unsigned DEFAULT NULL,
@@ -193,9 +222,9 @@
CONSTRAINT fkSectorColor FOREIGN KEY (rColor) REFERENCES color(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
-echo 'Ajout du trigger sector
';
-$db->query("DROP TRIGGER IF EXISTS `saveSectorChange`;");
-$db->query("CREATE TRIGGER `saveSectorChange` BEFORE UPDATE ON `sector`
+ $output->writeln('Ajout du trigger sector');
+ $this->database->query("DROP TRIGGER IF EXISTS `saveSectorChange`;");
+ $this->database->query("CREATE TRIGGER `saveSectorChange` BEFORE UPDATE ON `sector`
FOR EACH ROW BEGIN
IF NEW.rColor != OLD.rColor THEN
INSERT INTO changeColorSector(
@@ -212,10 +241,10 @@
END;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table system
';
+ $output->writeln('Ajout de la table system');;
-$db->query("DROP TABLE IF EXISTS `system`");
-$db->query("CREATE TABLE IF NOT EXISTS `system` (
+ $this->database->query("DROP TABLE IF EXISTS `system`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `system` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rSector` INT unsigned NOT NULL,
`rColor` INT unsigned NOT NULL,
@@ -229,9 +258,9 @@
CONSTRAINT fkSystemColor FOREIGN KEY (rColor) REFERENCES color(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
-echo 'Ajout du trigger system
';
-$db->query("DROP TRIGGER IF EXISTS `saveSystemChange`;");
-$db->query("CREATE TRIGGER `saveSystemChange` BEFORE UPDATE ON `system`
+ $output->writeln('Ajout du trigger system');
+ $this->database->query("DROP TRIGGER IF EXISTS `saveSystemChange`;");
+ $this->database->query("CREATE TRIGGER `saveSystemChange` BEFORE UPDATE ON `system`
FOR EACH ROW BEGIN
IF NEW.rColor != OLD.rColor THEN
INSERT INTO changeColorSystem(
@@ -248,10 +277,10 @@
END;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table place
';
+ $output->writeln('Ajout de la table place');;
-$db->query("DROP TABLE IF EXISTS `place`");
-$db->query("CREATE TABLE IF NOT EXISTS `place` (
+ $this->database->query("DROP TABLE IF EXISTS `place`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `place` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rPlayer` INT unsigned NULL,
`rSystem` INT unsigned NOT NULL,
@@ -274,10 +303,10 @@
CONSTRAINT fkPlaceSystem FOREIGN KEY (rSystem) REFERENCES system(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
-echo 'Ajout du trigger place
';
+ $output->writeln('Ajout du trigger place');
-$db->query("DROP TRIGGER IF EXISTS `savePlaceChange`;");
-$db->query("CREATE TRIGGER `savePlaceChange` BEFORE UPDATE ON `place`
+ $this->database->query("DROP TRIGGER IF EXISTS `savePlaceChange`;");
+ $this->database->query("CREATE TRIGGER `savePlaceChange` BEFORE UPDATE ON `place`
FOR EACH ROW BEGIN
IF NEW.rPlayer != OLD.rPlayer THEN
INSERT INTO changeColorPlace(
@@ -294,10 +323,10 @@
END;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table changeColorPlace
';
+ $output->writeln('Ajout de la table changeColorPlace');;
-$db->query("DROP TABLE IF EXISTS `changeColorPlace`");
-$db->query("CREATE TABLE IF NOT EXISTS `changeColorPlace` (
+ $this->database->query("DROP TABLE IF EXISTS `changeColorPlace`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `changeColorPlace` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rPlace` INT unsigned NOT NULL,
`oldPlayer` TINYINT unsigned NOT NULL,
@@ -307,10 +336,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table changeColorSector
';
+ $output->writeln('Ajout de la table changeColorSector');;
-$db->query("DROP TABLE IF EXISTS `changeColorSector`");
-$db->query("CREATE TABLE IF NOT EXISTS `changeColorSector` (
+ $this->database->query("DROP TABLE IF EXISTS `changeColorSector`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `changeColorSector` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rSector` INT unsigned NOT NULL,
`oldColor` TINYINT unsigned NOT NULL,
@@ -320,10 +349,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table changeColorSystem
';
+ $output->writeln('Ajout de la table changeColorSystem');;
-$db->query("DROP TABLE IF EXISTS `changeColorSystem`");
-$db->query("CREATE TABLE IF NOT EXISTS `changeColorSystem` (
+ $this->database->query("DROP TABLE IF EXISTS `changeColorSystem`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `changeColorSystem` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rSystem` INT unsigned NOT NULL,
`oldColor` TINYINT unsigned NOT NULL,
@@ -333,22 +362,22 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout des trois vues
';
+ $output->writeln('Ajout des trois vues');
-$db->query("DROP VIEW IF EXISTS `vGalaxyDiary`;");
-$db->query("CREATE VIEW `vGalaxyDiary` AS select `h`.`id` AS `id`,`h`.`rSector` AS `sector`,`h`.`oldColor` AS `oldColor`,`h`.`newColor` AS `newColor`,`h`.`dChangement` AS `dChangement` from (`changeColorSector` `h` left join `system` `s` on((`h`.`rSector` = `s`.`id`))) order by `h`.`dChangement` desc limit 0,100;");
+ $this->database->query("DROP VIEW IF EXISTS `vGalaxyDiary`;");
+ $this->database->query("CREATE VIEW `vGalaxyDiary` AS select `h`.`id` AS `id`,`h`.`rSector` AS `sector`,`h`.`oldColor` AS `oldColor`,`h`.`newColor` AS `newColor`,`h`.`dChangement` AS `dChangement` from (`changeColorSector` `h` left join `system` `s` on((`h`.`rSector` = `s`.`id`))) order by `h`.`dChangement` desc limit 0,100;");
-$db->query("DROP VIEW IF EXISTS `vSectorDiary`;");
-$db->query("CREATE VIEW `vSectorDiary` AS select count(`h`.`id`) AS `occurency`,`h`.`id` AS `id`,`h`.`rSystem` AS `system`,`s`.`rSector` AS `sector`,`h`.`oldColor` AS `oldColor`,`h`.`newColor` AS `newColor`,`h`.`dChangement` AS `dChangement` from (((`changeColorSystem` `h` left join `system` `s` on((`h`.`rSystem` = `s`.`id`))) left join `color` `c1` on((`h`.`oldColor` = `c1`.`id`))) left join `color` `c2` on((`h`.`newColor` = `c2`.`id`))) group by `c1`.`id`,`c2`.`id`,hour(`h`.`dChangement`) order by `h`.`dChangement` desc limit 0,1000;");
+ $this->database->query("DROP VIEW IF EXISTS `vSectorDiary`;");
+ $this->database->query("CREATE VIEW `vSectorDiary` AS select count(`h`.`id`) AS `occurency`,`h`.`id` AS `id`,`h`.`rSystem` AS `system`,`s`.`rSector` AS `sector`,`h`.`oldColor` AS `oldColor`,`h`.`newColor` AS `newColor`,`h`.`dChangement` AS `dChangement` from (((`changeColorSystem` `h` left join `system` `s` on((`h`.`rSystem` = `s`.`id`))) left join `color` `c1` on((`h`.`oldColor` = `c1`.`id`))) left join `color` `c2` on((`h`.`newColor` = `c2`.`id`))) group by `c1`.`id`,`c2`.`id`,hour(`h`.`dChangement`) order by `h`.`dChangement` desc limit 0,1000;");
-$db->query("DROP VIEW IF EXISTS `vSystemDiary`;");
-$db->query("CREATE VIEW `vSystemDiary` AS select `h`.`id` AS `id`,`h`.`rPlace` AS `place`,`h`.`oldPlayer` AS `oldPlayer`,`p1`.`name` AS `oldName`,`c1`.`id` AS `oldColor`,`h`.`newPlayer` AS `newPlayer`,`p2`.`name` AS `newName`,`c2`.`id` AS `newColor`,`h`.`dChangement` AS `dChangement`,`p`.`position` AS `position`,`p`.`rSystem` AS `system` from (((((`changeColorPlace` `h` left join `place` `p` on((`p`.`id` = `h`.`rPlace`))) left join `player` `p1` on((`h`.`oldPlayer` = `p1`.`id`))) left join `color` `c1` on((`p1`.`rColor` = `c1`.`id`))) left join `player` `p2` on((`h`.`newPlayer` = `p2`.`id`))) left join `color` `c2` on((`p2`.`rColor` = `c2`.`id`))) order by `h`.`dChangement` desc limit 0,5000;");
+ $this->database->query("DROP VIEW IF EXISTS `vSystemDiary`;");
+ $this->database->query("CREATE VIEW `vSystemDiary` AS select `h`.`id` AS `id`,`h`.`rPlace` AS `place`,`h`.`oldPlayer` AS `oldPlayer`,`p1`.`name` AS `oldName`,`c1`.`id` AS `oldColor`,`h`.`newPlayer` AS `newPlayer`,`p2`.`name` AS `newName`,`c2`.`id` AS `newColor`,`h`.`dChangement` AS `dChangement`,`p`.`position` AS `position`,`p`.`rSystem` AS `system` from (((((`changeColorPlace` `h` left join `place` `p` on((`p`.`id` = `h`.`rPlace`))) left join `player` `p1` on((`h`.`oldPlayer` = `p1`.`id`))) left join `color` `c1` on((`p1`.`rColor` = `c1`.`id`))) left join `player` `p2` on((`h`.`newPlayer` = `p2`.`id`))) left join `color` `c2` on((`p2`.`rColor` = `c2`.`id`))) order by `h`.`dChangement` desc limit 0,5000;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table orbitalBase
';
+ $output->writeln('Ajout de la table orbitalBase');;
-$db->query("DROP TABLE IF EXISTS `orbitalBase`");
-$db->query("CREATE TABLE IF NOT EXISTS `orbitalBase` (
+ $this->database->query("DROP TABLE IF EXISTS `orbitalBase`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `orbitalBase` (
`rPlace` INT unsigned NOT NULL,
`rPlayer` INT unsigned NOT NULL,
@@ -395,10 +424,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table commercialRoute
';
+ $output->writeln('Ajout de la table commercialRoute');;
-$db->query("DROP TABLE IF EXISTS `commercialRoute`");
-$db->query("CREATE TABLE IF NOT EXISTS `commercialRoute` (
+ $this->database->query("DROP TABLE IF EXISTS `commercialRoute`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `commercialRoute` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rOrbitalBase` INT unsigned NOT NULL,
`rOrbitalBaseLinked` INT unsigned NOT NULL,
@@ -418,10 +447,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table orbitalBaseBuildingQueue
';
+ $output->writeln('Ajout de la table orbitalBaseBuildingQueue');;
-$db->query("DROP TABLE IF EXISTS `orbitalBaseBuildingQueue`");
-$db->query("CREATE TABLE IF NOT EXISTS `orbitalBaseBuildingQueue` (
+ $this->database->query("DROP TABLE IF EXISTS `orbitalBaseBuildingQueue`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `orbitalBaseBuildingQueue` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rOrbitalBase` INT unsigned NOT NULL,
@@ -435,10 +464,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table orbitalBaseShipQueue
';
+ $output->writeln('Ajout de la table orbitalBaseShipQueue');;
-$db->query("DROP TABLE IF EXISTS `orbitalBaseShipQueue`");
-$db->query("CREATE TABLE IF NOT EXISTS `orbitalBaseShipQueue` (
+ $this->database->query("DROP TABLE IF EXISTS `orbitalBaseShipQueue`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `orbitalBaseShipQueue` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rOrbitalBase` INT unsigned NOT NULL,
@@ -454,10 +483,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table transaction
';
+ $output->writeln('Ajout de la table transaction');;
-$db->query("DROP TABLE IF EXISTS `transaction`");
-$db->query("CREATE TABLE IF NOT EXISTS `transaction` (
+ $this->database->query("DROP TABLE IF EXISTS `transaction`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `transaction` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rPlayer` INT unsigned NOT NULL,
`rPlace` INT unsigned NOT NULL,
@@ -477,21 +506,21 @@
CONSTRAINT fkTransactionPlayer FOREIGN KEY (rPlayer) REFERENCES player(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
-echo 'Remplissage de la table transaction
';
+ $output->writeln('Remplissage de la table transaction');
-$qr = $db->prepare("INSERT INTO `transaction` (`rPlayer`, `rPlace`, `type`, `quantity`, `identifier`, `price`, `commercialShipQuantity`, `statement`, `dPublication`, `dValidation`, `currentRate`) VALUES
+ $qr = $this->database->prepare("INSERT INTO `transaction` (`rPlayer`, `rPlace`, `type`, `quantity`, `identifier`, `price`, `commercialShipQuantity`, `statement`, `dPublication`, `dValidation`, `currentRate`) VALUES
(1, 0, ?, 8, NULL, 10, 0, ?, ?, ?, ?),
(1, 0, ?, 1, NULL, 12, 0, ?, ?, ?, ?),
(1, 0, ?, 8, NULL, 15, 0, ?, ?, ?, ?);");
-$qr->execute(array(Transaction::TYP_RESOURCE, Transaction::ST_COMPLETED, Utils::now(), Utils::now(), 1.26,
- Transaction::TYP_COMMANDER, Transaction::ST_COMPLETED, Utils::now(), Utils::now(), 12,
- Transaction::TYP_SHIP, Transaction::ST_COMPLETED, Utils::now(), Utils::now(), 1.875));
+ $qr->execute(array(Transaction::TYP_RESOURCE, Transaction::ST_COMPLETED, Utils::now(), Utils::now(), 1.26,
+ Transaction::TYP_COMMANDER, Transaction::ST_COMPLETED, Utils::now(), Utils::now(), 12,
+ Transaction::TYP_SHIP, Transaction::ST_COMPLETED, Utils::now(), Utils::now(), 1.875));
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table commercialShipping
';
+ $output->writeln('Ajout de la table commercialShipping');;
-$db->query("DROP TABLE IF EXISTS `commercialShipping`");
-$db->query("CREATE TABLE IF NOT EXISTS `commercialShipping` (
+ $this->database->query("DROP TABLE IF EXISTS `commercialShipping`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `commercialShipping` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rPlayer` INT unsigned NOT NULL,
`rBase` INT unsigned NOT NULL,
@@ -509,10 +538,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table commercialTax
';
+ $output->writeln('Ajout de la table commercialTax');;
-$db->query("DROP TABLE IF EXISTS `commercialTax`");
-$db->query("CREATE TABLE IF NOT EXISTS `commercialTax` (
+ $this->database->query("DROP TABLE IF EXISTS `commercialTax`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `commercialTax` (
`id` INT NOT NULL AUTO_INCREMENT,
`faction` SMALLINT NOT NULL,
`relatedFaction` SMALLINT NOT NULL,
@@ -521,21 +550,21 @@
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
-echo 'Remplissage de la table commercialTax
';
-$qr = $db->prepare("INSERT INTO `commercialTax` (`faction`, `relatedFaction`, `exportTax`, `importTax`) VALUES (?, ?, 5, 5)");
+ $output->writeln('Remplissage de la table commercialTax');
+ $qr = $this->database->prepare("INSERT INTO `commercialTax` (`faction`, `relatedFaction`, `exportTax`, `importTax`) VALUES (?, ?, 5, 5)");
# génération des taxes
-foreach ($availableFactions as $faction) {
- foreach ($availableFactions as $rfaction) {
- $qr->execute(array($faction, $rfaction));
- }
-}
+ foreach ($this->availableFactions as $faction) {
+ foreach ($this->availableFactions as $rfaction) {
+ $qr->execute(array($faction, $rfaction));
+ }
+ }
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table law
';
+ $output->writeln('Ajout de la table law');;
-$db->query("DROP TABLE IF EXISTS `law`");
-$db->query("CREATE TABLE IF NOT EXISTS `law` (
+ $this->database->query("DROP TABLE IF EXISTS `law`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `law` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rColor` INT unsigned NOT NULL,
@@ -552,10 +581,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table voteLaw
';
+ $output->writeln('Ajout de la table voteLaw');;
-$db->query("DROP TABLE IF EXISTS `voteLaw`");
-$db->query("CREATE TABLE IF NOT EXISTS `voteLaw` (
+ $this->database->query("DROP TABLE IF EXISTS `voteLaw`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `voteLaw` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rLaw` INT unsigned NOT NULL,
@@ -570,10 +599,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table forumTopic
';
+ $output->writeln('Ajout de la table forumTopic');;
-$db->query("DROP TABLE IF EXISTS `forumTopic`");
-$db->query("CREATE TABLE IF NOT EXISTS `forumTopic` (
+ $this->database->query("DROP TABLE IF EXISTS `forumTopic`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `forumTopic` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rColor` INT unsigned NOT NULL,
`rPlayer` INT unsigned NOT NULL,
@@ -593,10 +622,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table forumMessage
';
+ $output->writeln('Ajout de la table forumMessage');;
-$db->query("DROP TABLE IF EXISTS `forumMessage`");
-$db->query("CREATE TABLE IF NOT EXISTS `forumMessage` (
+ $this->database->query("DROP TABLE IF EXISTS `forumMessage`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `forumMessage` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rPlayer` INT unsigned NOT NULL,
`rTopic` INT unsigned NOT NULL,
@@ -615,10 +644,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table forumLastView
';
+ $output->writeln('Ajout de la table forumLastView');;
-$db->query("DROP TABLE IF EXISTS `forumLastView`");
-$db->query("CREATE TABLE IF NOT EXISTS `forumLastView` (
+ $this->database->query("DROP TABLE IF EXISTS `forumLastView`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `forumLastView` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rPlayer` INT unsigned NOT NULL,
`rTopic` INT unsigned NOT NULL,
@@ -631,10 +660,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table election
';
+ $output->writeln('Ajout de la table election');;
-$db->query("DROP TABLE IF EXISTS `election`");
-$db->query("CREATE TABLE IF NOT EXISTS `election` (
+ $this->database->query("DROP TABLE IF EXISTS `election`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `election` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rColor` INT unsigned NOT NULL,
@@ -644,10 +673,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table candidate
';
+ $output->writeln('Ajout de la table candidate');;
-$db->query("DROP TABLE IF EXISTS `candidate`");
-$db->query("CREATE TABLE IF NOT EXISTS `candidate` (
+ $this->database->query("DROP TABLE IF EXISTS `candidate`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `candidate` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rElection` INT unsigned NOT NULL,
`rPlayer` INT unsigned NOT NULL,
@@ -666,10 +695,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table vote
';
+ $output->writeln('Ajout de la table vote');;
-$db->query("DROP TABLE IF EXISTS `vote`");
-$db->query("CREATE TABLE IF NOT EXISTS `vote` (
+ $this->database->query("DROP TABLE IF EXISTS `vote`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `vote` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rCandidate` INT unsigned NOT NULL,
`rPlayer` INT unsigned NOT NULL,
@@ -684,10 +713,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table commander
';
+ $output->writeln('Ajout de la table commander');;
-$db->query("DROP TABLE IF EXISTS `commander`");
-$db->query("CREATE TABLE IF NOT EXISTS `commander` (
+ $this->database->query("DROP TABLE IF EXISTS `commander`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `commander` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rPlayer` INT unsigned NOT NULL,
`rBase` INT unsigned NOT NULL,
@@ -721,10 +750,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table squadron
';
+ $output->writeln('Ajout de la table squadron');;
-$db->query("DROP TABLE IF EXISTS `squadron`");
-$db->query("CREATE TABLE IF NOT EXISTS `squadron` (
+ $this->database->query("DROP TABLE IF EXISTS `squadron`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `squadron` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rCommander` INT unsigned NOT NULL,
@@ -749,10 +778,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table report
';
+ $output->writeln('Ajout de la table report');;
-$db->query("DROP TABLE IF EXISTS `report`");
-$db->query("CREATE TABLE IF NOT EXISTS `report` (
+ $this->database->query("DROP TABLE IF EXISTS `report`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `report` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rPlayerAttacker` INT unsigned NOT NULL,
`rPlayerDefender` INT unsigned NOT NULL,
@@ -795,10 +824,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table squadronReport
';
+ $output->writeln('Ajout de la table squadronReport');;
-$db->query("DROP TABLE IF EXISTS `squadronReport`");
-$db->query("CREATE TABLE IF NOT EXISTS `squadronReport` (
+ $this->database->query("DROP TABLE IF EXISTS `squadronReport`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `squadronReport` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rReport` INT unsigned NOT NULL,
`rCommander` INT unsigned NULL,
@@ -825,10 +854,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table spyReport
';
+ $output->writeln('Ajout de la table spyReport');;
-$db->query("DROP TABLE IF EXISTS `spyReport`");
-$db->query("CREATE TABLE IF NOT EXISTS `spyReport` (
+ $this->database->query("DROP TABLE IF EXISTS `spyReport`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `spyReport` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rPlayer` INT unsigned NOT NULL,
`rPlace` INT unsigned NOT NULL,
@@ -859,24 +888,24 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table ranking
';
+ $output->writeln('Ajout de la table ranking');;
-$qr = $db->prepare("DROP TABLE IF EXISTS `ranking`");
-$qr = $db->prepare("CREATE TABLE IF NOT EXISTS `ranking` (
+ $qr = $this->database->prepare("DROP TABLE IF EXISTS `ranking`");
+ $qr = $this->database->prepare("CREATE TABLE IF NOT EXISTS `ranking` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`dRanking` datetime NOT NULL,
`player` TINYINT unsigned NOT NULL DEFAULT 0,
`faction` TINYINT unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
-$qr->execute();
+ $qr->execute();
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table playerRanking
';
+ $output->writeln('Ajout de la table playerRanking');;
-$qr = $db->prepare("DROP TABLE IF EXISTS `playerRanking`");
-$qr->execute();
-$qr = $db->prepare("CREATE TABLE IF NOT EXISTS `playerRanking` (
+ $qr = $this->database->prepare("DROP TABLE IF EXISTS `playerRanking`");
+ $qr->execute();
+ $qr = $this->database->prepare("CREATE TABLE IF NOT EXISTS `playerRanking` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rRanking` INT unsigned NOT NULL,
`rPlayer` INT unsigned NOT NULL,
@@ -917,14 +946,14 @@
CONSTRAINT fkPlayerRankingRanking FOREIGN KEY (rRanking) REFERENCES ranking(id),
CONSTRAINT fkPlayerRankingPlayer FOREIGN KEY (rPlayer) REFERENCES player(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
-$qr->execute();
+ $qr->execute();
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table factionRanking
';
+ $output->writeln('Ajout de la table factionRanking');;
-$qr = $db->prepare("DROP TABLE IF EXISTS `factionRanking`");
-$qr->execute();
-$qr = $db->prepare("CREATE TABLE IF NOT EXISTS `factionRanking` (
+ $qr = $this->database->prepare("DROP TABLE IF EXISTS `factionRanking`");
+ $qr->execute();
+ $qr = $this->database->prepare("CREATE TABLE IF NOT EXISTS `factionRanking` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rRanking` INT unsigned NOT NULL,
`rFaction` INT unsigned NOT NULL,
@@ -950,16 +979,15 @@
CONSTRAINT fkFactionRankingRanking FOREIGN KEY (rRanking) REFERENCES ranking(id),
CONSTRAINT fkFactionRankingPlayer FOREIGN KEY (rFaction) REFERENCES color(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
-$qr->execute();
+ $qr->execute();
#--------------------------------------------------------------------------------------------
-echo 'Ajout du module de Conversation
';
+ $output->writeln('Ajout du module de Conversation');
-echo 'Ajout de la table Conversation
';
+ $output->writeln('Ajout de la table Conversation');;
-$db = $this->getContainer()->get(Database::class);
-$db->query("DROP TABLE IF EXISTS `conversation`");
-$qr = $db->prepare("CREATE TABLE IF NOT EXISTS `conversation` (
+ $this->database->query("DROP TABLE IF EXISTS `conversation`");
+ $qr = $this->database->prepare("CREATE TABLE IF NOT EXISTS `conversation` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`title` VARCHAR(255) NULL,
`messages` INT(5) NOT NULL DEFAULT 0,
@@ -968,12 +996,12 @@
`dLastMessage` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
-$qr->execute();
+ $qr->execute();
-echo 'Ajout de la table userConversation
';
+ $output->writeln('Ajout de la table userConversation');;
-$db->query("DROP TABLE IF EXISTS `conversationUser`");
-$qr = $db->prepare("CREATE TABLE IF NOT EXISTS `conversationUser` (
+ $this->database->query("DROP TABLE IF EXISTS `conversationUser`");
+ $qr = $this->database->prepare("CREATE TABLE IF NOT EXISTS `conversationUser` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`rConversation` INT(11) NOT NULL,
`rPlayer` INT(11) NOT NULL,
@@ -982,12 +1010,12 @@
`dLastView` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
-$qr->execute();
+ $qr->execute();
-echo 'Ajout de la table messageConversation
';
+ $output->writeln('Ajout de la table messageConversation');;
-$db->query("DROP TABLE IF EXISTS `conversationMessage`");
-$qr = $db->prepare("CREATE TABLE IF NOT EXISTS `conversationMessage` (
+ $this->database->query("DROP TABLE IF EXISTS `conversationMessage`");
+ $qr = $this->database->prepare("CREATE TABLE IF NOT EXISTS `conversationMessage` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`rConversation` INT(11) NOT NULL,
`rPlayer` INT(11) NOT NULL,
@@ -999,54 +1027,52 @@
`dLastModification` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
-$qr->execute();
+ $qr->execute();
-echo 'Remplissage des conversations
';
+ $output->writeln('Remplissage des conversations');;
# conv jeanmi
-$conv = new Conversation();
-$conv->messages = 0;
-$conv->type = Conversation::TY_SYSTEM;
-$conv->title = 'Jean-Mi, administrateur système';
-$conv->dCreation = Utils::now();
-$conv->dLastMessage = Utils::now();
-$conversationManager = $this->getContainer()->get(\App\Modules\Hermes\Manager\ConversationManager::class);
-$conversationManager->add($conv);
-
-$user = new ConversationUser();
-$user->rConversation = $conv->id;
-$user->rPlayer = $container->getParameter('id_jeanmi');
-$user->convPlayerStatement = ConversationUser::US_ADMIN;
-$user->convStatement = ConversationUser::CS_DISPLAY;
-$user->dLastView = Utils::now();
-$conversationUserManager = $this->getContainer()->get(\App\Modules\Hermes\Manager\ConversationUserManager::class);
-$conversationUserManager->add($user);
-
-foreach ($availableFactions as $faction) {
- $player = $playerManager->getFactionAccount($faction);
-
- $conv = new Conversation();
- $conv->messages = 0;
- $conv->type = Conversation::TY_SYSTEM;
- $conv->title = 'Communication de ' . ColorResource::getInfo($player->rColor, 'popularName');
- $conv->dCreation = Utils::now();
- $conv->dLastMessage = Utils::now();
- $conversationManager->add($conv);
-
- $user = new ConversationUser();
- $user->rConversation = $conv->id;
- $user->rPlayer = $player->id;
- $user->convPlayerStatement = ConversationUser::US_ADMIN;
- $user->convStatement = ConversationUser::CS_DISPLAY;
- $user->dLastView = Utils::now();
- $conversationUserManager->add($user);
-}
+ $conv = new Conversation();
+ $conv->messages = 0;
+ $conv->type = Conversation::TY_SYSTEM;
+ $conv->title = 'Jean-Mi, administrateur système';
+ $conv->dCreation = Utils::now();
+ $conv->dLastMessage = Utils::now();
+ $this->conversationManager->add($conv);
+
+ $user = new ConversationUser();
+ $user->rConversation = $conv->id;
+ $user->rPlayer = $this->jeanMiId;
+ $user->convPlayerStatement = ConversationUser::US_ADMIN;
+ $user->convStatement = ConversationUser::CS_DISPLAY;
+ $user->dLastView = Utils::now();
+ $this->conversationUserManager->add($user);
+
+ foreach ($this->availableFactions as $faction) {
+ $player = $this->playerManager->getFactionAccount($faction);
+
+ $conv = new Conversation();
+ $conv->messages = 0;
+ $conv->type = Conversation::TY_SYSTEM;
+ $conv->title = 'Communication de ' . ColorResource::getInfo($player->rColor, 'popularName');
+ $conv->dCreation = Utils::now();
+ $conv->dLastMessage = Utils::now();
+ $this->conversationManager->add($conv);
+
+ $user = new ConversationUser();
+ $user->rConversation = $conv->id;
+ $user->rPlayer = $player->id;
+ $user->convPlayerStatement = ConversationUser::US_ADMIN;
+ $user->convStatement = ConversationUser::CS_DISPLAY;
+ $user->dLastView = Utils::now();
+ $this->conversationUserManager->add($user);
+ }
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table notification
';
+ $output->writeln('Ajout de la table notification');;
-$db->query("DROP TABLE IF EXISTS `notification`");
-$db->query("CREATE TABLE IF NOT EXISTS `notification` (
+ $this->database->query("DROP TABLE IF EXISTS `notification`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `notification` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rPlayer` INT unsigned NOT NULL,
`title` varchar(100) NOT NULL,
@@ -1060,10 +1086,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table roadMap
';
+ $output->writeln('Ajout de la table roadMap');;
-$db->query("DROP TABLE IF EXISTS `roadMap`");
-$db->query("CREATE TABLE IF NOT EXISTS `roadMap` (
+ $this->database->query("DROP TABLE IF EXISTS `roadMap`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `roadMap` (
`id` INT NOT NULL AUTO_INCREMENT,
`rPlayer` INT NOT NULL,
`oContent` text NOT NULL,
@@ -1074,10 +1100,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table research
';
+ $output->writeln('Ajout de la table research');;
-$db->query("DROP TABLE IF EXISTS `research`");
-$db->query("CREATE TABLE IF NOT EXISTS `research` (
+ $this->database->query("DROP TABLE IF EXISTS `research`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `research` (
`rPlayer` INT unsigned NOT NULL,
`mathLevel` TINYINT unsigned NOT NULL DEFAULT 0,
@@ -1104,10 +1130,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table technology
';
+ $output->writeln('Ajout de la table technology');;
-$db->query("DROP TABLE IF EXISTS `technology`");
-$db->query("CREATE TABLE IF NOT EXISTS `technology` (
+ $this->database->query("DROP TABLE IF EXISTS `technology`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `technology` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rPlayer` INT unsigned NOT NULL,
@@ -1119,10 +1145,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table technologyQueue
';
+ $output->writeln('Ajout de la table technologyQueue');;
-$db->query("DROP TABLE IF EXISTS `technologyQueue`");
-$db->query("CREATE TABLE IF NOT EXISTS `technologyQueue` (
+ $this->database->query("DROP TABLE IF EXISTS `technologyQueue`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `technologyQueue` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rPlayer` INT unsigned NOT NULL,
`rPlace` INT unsigned NOT NULL,
@@ -1139,12 +1165,12 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-$db->query("DROP TABLE IF EXISTS `recyclingLog`");
-$db->query("DROP TABLE IF EXISTS `recyclingMission`");
+ $this->database->query("DROP TABLE IF EXISTS `recyclingLog`");
+ $this->database->query("DROP TABLE IF EXISTS `recyclingMission`");
-echo 'Ajout de la table recyclingMission
';
+ $output->writeln('Ajout de la table recyclingMission');;
-$db->query("CREATE TABLE IF NOT EXISTS `recyclingMission` (
+ $this->database->query("CREATE TABLE IF NOT EXISTS `recyclingMission` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rBase` INT unsigned NOT NULL,
`rTarget` INT unsigned NOT NULL,
@@ -1161,9 +1187,9 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table recyclingLog
';
+ $output->writeln('Ajout de la table recyclingLog');;
-$db->query("CREATE TABLE IF NOT EXISTS `recyclingLog` (
+ $this->database->query("CREATE TABLE IF NOT EXISTS `recyclingLog` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rRecycling` INT unsigned NOT NULL,
@@ -1188,10 +1214,10 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
#--------------------------------------------------------------------------------------------
-echo 'Ajout de la table creditTransaction
';
+ $output->writeln('Ajout de la table creditTransaction');;
-$db->query("DROP TABLE IF EXISTS `creditTransaction`");
-$db->query("CREATE TABLE IF NOT EXISTS `creditTransaction` (
+ $this->database->query("DROP TABLE IF EXISTS `creditTransaction`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `creditTransaction` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rSender` INT unsigned NOT NULL,
`rReceiver` INT unsigned NOT NULL,
@@ -1203,9 +1229,9 @@
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
-echo 'Ajout de la table colorLink
';
-$db->query("DROP TABLE IF EXISTS `colorLink`");
-$db->query("CREATE TABLE IF NOT EXISTS `colorLink` (
+ $output->writeln('Ajout de la table colorLink');;
+ $this->database->query("DROP TABLE IF EXISTS `colorLink`");
+ $this->database->query("CREATE TABLE IF NOT EXISTS `colorLink` (
`id` INT unsigned NOT NULL AUTO_INCREMENT,
`rColor` TINYINT NOT NULL DEFAULT 0,
@@ -1214,39 +1240,41 @@
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
-$values = '';
-$colorManager = $this->getContainer()->get(\App\Modules\Demeter\Manager\ColorManager::class);
-$factions = $colorManager->getAll();
-$nbFactions = count($factions);
-for ($i = 1; $i < $nbFactions; $i++) {
- for ($j = 1; $j < $nbFactions; $j++) {
- if (!(($i == $nbFactions - 1) && ($j == $nbFactions - 1))) {
- $values .= '(' . $factions[$i]->id . ',' . $factions[$j]->id . ',' . 0 .'),';
+ $values = '';
+ $factions = $this->colorManager->getAll();
+ $nbFactions = count($factions);
+ for ($i = 1; $i < $nbFactions; $i++) {
+ for ($j = 1; $j < $nbFactions; $j++) {
+ if (!(($i == $nbFactions - 1) && ($j == $nbFactions - 1))) {
+ $values .= '(' . $factions[$i]->id . ',' . $factions[$j]->id . ',' . 0 . '),';
+ }
+ }
}
- }
-}
-$values .= '(' . $factions[$nbFactions - 1]->id . ',' . $factions[$nbFactions - 1]->id . ',' . 0 .');';
+ $values .= '(' . $factions[$nbFactions - 1]->id . ',' . $factions[$nbFactions - 1]->id . ',' . 0 . ');';
-echo 'Remplissage de la table colorLink
';
-$qr = $db->prepare("INSERT INTO `colorLink` (`rColor`, `rColorLinked`, `statement`) VALUES" . $values);
-$qr->execute();
+ $output->writeln('Remplissage de la table colorLink');
+ $qr = $this->database->prepare("INSERT INTO `colorLink` (`rColor`, `rColorLinked`, `statement`) VALUES" . $values);
+ $qr->execute();
-$db->query('SET FOREIGN_KEY_CHECKS = 1;');
+ $this->database->query('SET FOREIGN_KEY_CHECKS = 1;');
-if ($container->getParameter('data_analysis')) {
- echo 'Création des tables du module d\'analyse
';
+// if ($container->getParameter('data_analysis')) {
+// $output->writeln('Création des tables du module d\'analyse');
+//
+// include 'data-analysis/player.php';
+// include 'data-analysis/playerDaily.php';
+//// include 'data-analysis/fleetMovement.php';
+// include 'data-analysis/commercialRelation.php';
+// include 'data-analysis/socialRelation.php';
+// include 'data-analysis/baseAction.php';
+// }
- include 'data-analysis/player.php';
- include 'data-analysis/playerDaily.php';
-// include 'data-analysis/fleetMovement.php';
- include 'data-analysis/commercialRelation.php';
- include 'data-analysis/socialRelation.php';
- include 'data-analysis/baseAction.php';
-}
+ $output->writeln('Génération de la galaxie');
-echo 'Génération de la galaxie
';
+ $this->galaxyGenerator->generate();
+ // echo $galaxyGenerator->getLog();
-$galaxyGenerator = $this->getContainer()->get(\App\Modules\Gaia\Helper\GalaxyGenerator::class);
-$galaxyGenerator->generate();
-echo $galaxyGenerator->getLog();
+ return self::SUCCESS;
+ }
+}
diff --git a/supervisord.conf b/supervisord.conf
new file mode 100644
index 000000000..73eccdff3
--- /dev/null
+++ b/supervisord.conf
@@ -0,0 +1,12 @@
+[program:worker]
+command=php bin/console messenger:consume async -vv --time-limit=60
+numprocs=1
+autostart=true
+autorestart=true
+process_name=%(program_name)s_%(process_num)02d
+stderr_logfile=/dev/stderr
+stderr_logfile_maxbytes=0
+
+[supervisord]
+nodaemon=true
+logfile=/var/log/supervisord/supervisord.log
diff --git a/symfony.lock b/symfony.lock
index 2f5b08bc7..75024a7f2 100644
--- a/symfony.lock
+++ b/symfony.lock
@@ -2,6 +2,18 @@
"psr/cache": {
"version": "3.0.0"
},
+ "sentry/sentry-symfony": {
+ "version": "4.2",
+ "recipe": {
+ "repo": "github.com/symfony/recipes-contrib",
+ "branch": "master",
+ "version": "3.0",
+ "ref": "9746f0823302d7980e5273ef7a69ef3f5ac80914"
+ },
+ "files": [
+ "config/packages/sentry.yaml"
+ ]
+ },
"symfony/asset": {
"version": "v6.0.1"
},
@@ -123,12 +135,18 @@
"symfony/options-resolver": {
"version": "v6.0.0"
},
+ "symfony/password-hasher": {
+ "version": "v6.0.3"
+ },
"symfony/polyfill-intl-grapheme": {
"version": "v1.24.0"
},
"symfony/polyfill-intl-normalizer": {
"version": "v1.24.0"
},
+ "symfony/psr-http-message-bridge": {
+ "version": "v2.1.2"
+ },
"symfony/routing": {
"version": "6.0",
"recipe": {
@@ -145,6 +163,9 @@
"symfony/runtime": {
"version": "v6.0.0"
},
+ "symfony/security-core": {
+ "version": "v6.0.3"
+ },
"symfony/service-contracts": {
"version": "v3.0.0"
},
diff --git a/worker.php b/worker.php
deleted file mode 100644
index b548f4a17..000000000
--- a/worker.php
+++ /dev/null
@@ -1,30 +0,0 @@
-usePutenv(false);
-$dotenv->load($projectDir.'/.env');
-
-$worker = new WorkerKernel($options['process'] ?? 'worker', $projectDir);
-$worker->boot();