diff --git a/.env b/.env
index 328eac4..ef5fa78 100644
--- a/.env
+++ b/.env
@@ -30,3 +30,7 @@ APP_SECRET=ed4570d9c2866990932c9e834745ba21
# DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7"
DATABASE_URL="postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=13&charset=utf8"
###< doctrine/doctrine-bundle ###
+
+###> nelmio/cors-bundle ###
+CORS_ALLOW_ORIGIN='^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$'
+###< nelmio/cors-bundle ###
diff --git a/.gitignore b/.gitignore
index eaa3cd3..6f33dab 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-
+.idea/
###> symfony/framework-bundle ###
/.env.local
/.env.local.php
diff --git a/.idea/php.xml b/.idea/php.xml
index 0708da5..7a74033 100644
--- a/.idea/php.xml
+++ b/.idea/php.xml
@@ -103,6 +103,10 @@
+
+
+
+
diff --git a/.idea/src.iml b/.idea/src.iml
index a3d6fc8..5fd7604 100644
--- a/.idea/src.iml
+++ b/.idea/src.iml
@@ -106,6 +106,9 @@
+
+
+
diff --git a/composer.json b/composer.json
index 907283a..6836bb1 100644
--- a/composer.json
+++ b/composer.json
@@ -7,11 +7,13 @@
"php": ">=7.2.5",
"ext-ctype": "*",
"ext-iconv": "*",
+ "api-platform/core": "^2.6",
"composer/package-versions-deprecated": "1.11.99.1",
"doctrine/annotations": "^1.0",
"doctrine/doctrine-bundle": "^2.3",
"doctrine/doctrine-migrations-bundle": "^3.0",
"doctrine/orm": "^2.8",
+ "nelmio/cors-bundle": "^2.1",
"phpdocumentor/reflection-docblock": "^5.2",
"sensio/framework-extra-bundle": "^5.1",
"symfony/asset": "5.2.*",
diff --git a/composer.lock b/composer.lock
index 309927c..7a52ebd 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,8 +4,162 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "8a9a2eb7d2fd01fec399e0a9a10e4180",
+ "content-hash": "ae2e9c67c9b1291a357031a97bb24bb9",
"packages": [
+ {
+ "name": "api-platform/core",
+ "version": "v2.6.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/api-platform/core.git",
+ "reference": "1ba77218dfe61ca9e6cff1bbb3e9a4a6658d4538"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/api-platform/core/zipball/1ba77218dfe61ca9e6cff1bbb3e9a4a6658d4538",
+ "reference": "1ba77218dfe61ca9e6cff1bbb3e9a4a6658d4538",
+ "shasum": ""
+ },
+ "require": {
+ "doctrine/inflector": "^1.0 || ^2.0",
+ "fig/link-util": "^1.0",
+ "php": ">=7.1",
+ "psr/cache": "^1.0",
+ "psr/container": "^1.0",
+ "symfony/http-foundation": "^4.4 || ^5.1",
+ "symfony/http-kernel": "^4.4 || ^5.1",
+ "symfony/property-access": "^3.4.19 || ^4.4 || ^5.1",
+ "symfony/property-info": "^3.4 || ^4.4 || ^5.2.1",
+ "symfony/serializer": "^4.4 || ^5.1",
+ "symfony/web-link": "^4.4 || ^5.1",
+ "willdurand/negotiation": "^2.0.3 || ^3.0"
+ },
+ "conflict": {
+ "doctrine/common": "<2.7",
+ "doctrine/mongodb-odm": "<2.0",
+ "doctrine/persistence": "<1.3"
+ },
+ "require-dev": {
+ "behat/behat": "^3.1",
+ "behat/mink": "^1.7",
+ "doctrine/annotations": "^1.7",
+ "doctrine/common": "^2.11 || ^3.0",
+ "doctrine/data-fixtures": "^1.2.2",
+ "doctrine/doctrine-bundle": "^1.12 || ^2.0",
+ "doctrine/mongodb-odm": "^2.0",
+ "doctrine/mongodb-odm-bundle": "^4.0",
+ "doctrine/orm": "^2.6.4 || ^3.0",
+ "elasticsearch/elasticsearch": "^6.0 || ^7.0",
+ "friends-of-behat/mink-browserkit-driver": "^1.3.1",
+ "friends-of-behat/mink-extension": "^2.2",
+ "friends-of-behat/symfony-extension": "^2.1",
+ "guzzlehttp/guzzle": "^6.0 || ^7.0",
+ "jangregor/phpstan-prophecy": "^0.8",
+ "justinrainbow/json-schema": "^5.2.1",
+ "phpdocumentor/reflection-docblock": "^3.0 || ^4.0 || ^5.1",
+ "phpdocumentor/type-resolver": "^0.3 || ^0.4 || ^1.4",
+ "phpstan/extension-installer": "^1.0",
+ "phpstan/phpstan": "^0.12.65",
+ "phpstan/phpstan-doctrine": "^0.12.7",
+ "phpstan/phpstan-phpunit": "^0.12.4",
+ "phpstan/phpstan-symfony": "^0.12.4",
+ "psr/log": "^1.0",
+ "ramsey/uuid": "^3.7 || ^4.0",
+ "ramsey/uuid-doctrine": "^1.4",
+ "soyuka/contexts": "^3.3.1",
+ "soyuka/stubs-mongodb": "^1.0",
+ "symfony/asset": "^3.4 || ^4.4 || ^5.1",
+ "symfony/browser-kit": "^4.4 || ^5.1",
+ "symfony/cache": "^3.4 || ^4.4 || ^5.1",
+ "symfony/config": "^3.4 || ^4.4 || ^5.1",
+ "symfony/console": "^3.4 || ^4.4 || ^5.1",
+ "symfony/css-selector": "^3.4 || ^4.4 || ^5.1",
+ "symfony/debug": "^3.4 || ^4.4 || ^5.1",
+ "symfony/dependency-injection": "^3.4 || ^4.4 || ^5.1",
+ "symfony/doctrine-bridge": "^3.4 || ^4.4 || ^5.1",
+ "symfony/dom-crawler": "^3.4 || ^4.4 || ^5.1",
+ "symfony/event-dispatcher": "^3.4 || ^4.4 || ^5.1",
+ "symfony/expression-language": "^3.4 || ^4.4 || ^5.1",
+ "symfony/finder": "^3.4 || ^4.4 || ^5.1",
+ "symfony/form": "^3.4 || ^4.4 || ^5.1",
+ "symfony/framework-bundle": "^4.4 || ^5.1",
+ "symfony/http-client": "^4.4 || ^5.1",
+ "symfony/mercure-bundle": "*",
+ "symfony/messenger": "^4.4 || ^5.1",
+ "symfony/phpunit-bridge": "^5.1.7",
+ "symfony/routing": "^3.4 || ^4.4 || ^5.1",
+ "symfony/security-bundle": "^3.4 || ^4.4 || ^5.1",
+ "symfony/security-core": "^4.4 || ^5.1",
+ "symfony/twig-bundle": "^3.4 || ^4.4 || ^5.1",
+ "symfony/validator": "^3.4 || ^4.4 || ^5.1",
+ "symfony/web-profiler-bundle": "^4.4 || ^5.1",
+ "symfony/yaml": "^3.4 || ^4.4 || ^5.1",
+ "twig/twig": "^1.42.3 || ^2.12 || ^3.0",
+ "webonyx/graphql-php": "^14.0"
+ },
+ "suggest": {
+ "doctrine/mongodb-odm-bundle": "To support MongoDB. Only versions 4.0 and later are supported.",
+ "elasticsearch/elasticsearch": "To support Elasticsearch.",
+ "guzzlehttp/guzzle": "To use the HTTP cache invalidation system.",
+ "ocramius/package-versions": "To display the API Platform's version in the debug bar.",
+ "phpdocumentor/reflection-docblock": "To support extracting metadata from PHPDoc.",
+ "psr/cache-implementation": "To use metadata caching.",
+ "ramsey/uuid": "To support Ramsey's UUID identifiers.",
+ "symfony/cache": "To have metadata caching when using Symfony integration.",
+ "symfony/config": "To load XML configuration files.",
+ "symfony/expression-language": "To use authorization features.",
+ "symfony/security": "To use authorization features.",
+ "symfony/twig-bundle": "To use the Swagger UI integration.",
+ "symfony/uid": "To support Symfony UUID/ULID identifiers.",
+ "symfony/web-profiler-bundle": "To use the data collector.",
+ "webonyx/graphql-php": "To support GraphQL."
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "2.7.x-dev"
+ },
+ "symfony": {
+ "require": "^3.4 || ^4.4 || ^5.1"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "ApiPlatform\\Core\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Kévin Dunglas",
+ "email": "dunglas@gmail.com",
+ "homepage": "https://dunglas.fr"
+ }
+ ],
+ "description": "Build a fully-featured hypermedia or GraphQL API in minutes!",
+ "homepage": "https://api-platform.com",
+ "keywords": [
+ "Hydra",
+ "JSON-LD",
+ "api",
+ "graphql",
+ "hal",
+ "jsonapi",
+ "openapi",
+ "rest",
+ "swagger"
+ ],
+ "funding": [
+ {
+ "url": "https://tidelift.com/funding/github/packagist/api-platform/core",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2021-03-07T19:13:33+00:00"
+ },
{
"name": "composer/package-versions-deprecated",
"version": "1.11.99.1",
@@ -1394,6 +1548,63 @@
],
"time": "2021-03-07T14:33:28+00:00"
},
+ {
+ "name": "fig/link-util",
+ "version": "1.1.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/link-util.git",
+ "reference": "5d7b8d04ed3393b4b59968ca1e906fb7186d81e8"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/link-util/zipball/5d7b8d04ed3393b4b59968ca1e906fb7186d81e8",
+ "reference": "5d7b8d04ed3393b4b59968ca1e906fb7186d81e8",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.5.0",
+ "psr/link": "~1.0@dev"
+ },
+ "provide": {
+ "psr/link-implementation": "1.0"
+ },
+ "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": "https://www.php-fig.org/"
+ }
+ ],
+ "description": "Common utility implementations for HTTP links",
+ "keywords": [
+ "http",
+ "http-link",
+ "link",
+ "psr",
+ "psr-13",
+ "rest"
+ ],
+ "time": "2021-02-03T23:36:04+00:00"
+ },
{
"name": "friendsofphp/proxy-manager-lts",
"version": "v1.0.3",
@@ -1741,6 +1952,63 @@
],
"time": "2020-12-14T13:15:25+00:00"
},
+ {
+ "name": "nelmio/cors-bundle",
+ "version": "2.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/nelmio/NelmioCorsBundle.git",
+ "reference": "be4d5824caebc86da9e224e935e02e1201b3ea54"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/nelmio/NelmioCorsBundle/zipball/be4d5824caebc86da9e224e935e02e1201b3ea54",
+ "reference": "be4d5824caebc86da9e224e935e02e1201b3ea54",
+ "shasum": ""
+ },
+ "require": {
+ "symfony/framework-bundle": "^4.3 || ^5.0"
+ },
+ "require-dev": {
+ "mockery/mockery": "^1.2",
+ "symfony/phpunit-bridge": "^4.3 || ^5.0"
+ },
+ "type": "symfony-bundle",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Nelmio\\CorsBundle\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nelmio",
+ "homepage": "http://nelm.io"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://github.com/nelmio/NelmioCorsBundle/contributors"
+ }
+ ],
+ "description": "Adds CORS (Cross-Origin Resource Sharing) headers support in your Symfony application",
+ "keywords": [
+ "api",
+ "cors",
+ "crossdomain"
+ ],
+ "time": "2020-07-22T11:44:28+00:00"
+ },
{
"name": "phpdocumentor/reflection-common",
"version": "2.2.0",
@@ -7146,6 +7414,58 @@
"validate"
],
"time": "2021-03-09T10:59:23+00:00"
+ },
+ {
+ "name": "willdurand/negotiation",
+ "version": "3.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/willdurand/Negotiation.git",
+ "reference": "04e14f38d4edfcc974114a07d2777d90c98f3d9c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/willdurand/Negotiation/zipball/04e14f38d4edfcc974114a07d2777d90c98f3d9c",
+ "reference": "04e14f38d4edfcc974114a07d2777d90c98f3d9c",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.1.0"
+ },
+ "require-dev": {
+ "symfony/phpunit-bridge": "^5.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Negotiation\\": "src/Negotiation"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "William Durand",
+ "email": "will+git@drnd.me"
+ }
+ ],
+ "description": "Content Negotiation tools for PHP provided as a standalone library.",
+ "homepage": "http://williamdurand.fr/Negotiation/",
+ "keywords": [
+ "accept",
+ "content",
+ "format",
+ "header",
+ "negotiation"
+ ],
+ "time": "2020-09-25T08:01:41+00:00"
}
],
"packages-dev": [
diff --git a/config/bundles.php b/config/bundles.php
index 70fae29..d208c11 100644
--- a/config/bundles.php
+++ b/config/bundles.php
@@ -12,4 +12,6 @@ return [
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
+ Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
+ ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
];
diff --git a/config/packages/api_platform.yaml b/config/packages/api_platform.yaml
new file mode 100644
index 0000000..2eb7b4c
--- /dev/null
+++ b/config/packages/api_platform.yaml
@@ -0,0 +1,7 @@
+api_platform:
+ mapping:
+ paths: ['%kernel.project_dir%/src/Entity']
+ patch_formats:
+ json: ['application/merge-patch+json']
+ swagger:
+ versions: [3]
diff --git a/config/packages/nelmio_cors.yaml b/config/packages/nelmio_cors.yaml
new file mode 100644
index 0000000..c766508
--- /dev/null
+++ b/config/packages/nelmio_cors.yaml
@@ -0,0 +1,10 @@
+nelmio_cors:
+ defaults:
+ origin_regex: true
+ allow_origin: ['%env(CORS_ALLOW_ORIGIN)%']
+ allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
+ allow_headers: ['Content-Type', 'Authorization']
+ expose_headers: ['Link']
+ max_age: 3600
+ paths:
+ '^/': null
diff --git a/config/routes/api_platform.yaml b/config/routes/api_platform.yaml
new file mode 100644
index 0000000..38f11cb
--- /dev/null
+++ b/config/routes/api_platform.yaml
@@ -0,0 +1,4 @@
+api_platform:
+ resource: .
+ type: api_platform
+ prefix: /api
diff --git a/migrations/Version20210326134141.php b/migrations/Version20210326134141.php
new file mode 100644
index 0000000..cde1e12
--- /dev/null
+++ b/migrations/Version20210326134141.php
@@ -0,0 +1,41 @@
+addSql('CREATE TABLE generation (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
+ $this->addSql('CREATE TABLE pokemon (id INT AUTO_INCREMENT NOT NULL, type1_id INT NOT NULL, type2_id INT DEFAULT NULL, generation_id INT NOT NULL, nom VARCHAR(255) NOT NULL, vie INT NOT NULL, attaque INT NOT NULL, defense INT NOT NULL, legendaire TINYINT(1) NOT NULL, INDEX IDX_62DC90F3BFAFA3E1 (type1_id), INDEX IDX_62DC90F3AD1A0C0F (type2_id), INDEX IDX_62DC90F3553A6EC4 (generation_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
+ $this->addSql('CREATE TABLE type (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
+ $this->addSql('ALTER TABLE pokemon ADD CONSTRAINT FK_62DC90F3BFAFA3E1 FOREIGN KEY (type1_id) REFERENCES type (id)');
+ $this->addSql('ALTER TABLE pokemon ADD CONSTRAINT FK_62DC90F3AD1A0C0F FOREIGN KEY (type2_id) REFERENCES type (id)');
+ $this->addSql('ALTER TABLE pokemon ADD CONSTRAINT FK_62DC90F3553A6EC4 FOREIGN KEY (generation_id) REFERENCES generation (id)');
+ }
+
+ public function down(Schema $schema) : void
+ {
+ // this down() migration is auto-generated, please modify it to your needs
+ $this->addSql('ALTER TABLE pokemon DROP FOREIGN KEY FK_62DC90F3553A6EC4');
+ $this->addSql('ALTER TABLE pokemon DROP FOREIGN KEY FK_62DC90F3BFAFA3E1');
+ $this->addSql('ALTER TABLE pokemon DROP FOREIGN KEY FK_62DC90F3AD1A0C0F');
+ $this->addSql('DROP TABLE generation');
+ $this->addSql('DROP TABLE pokemon');
+ $this->addSql('DROP TABLE type');
+ }
+}
diff --git a/migrations/Version20210326143537.php b/migrations/Version20210326143537.php
new file mode 100644
index 0000000..7b75548
--- /dev/null
+++ b/migrations/Version20210326143537.php
@@ -0,0 +1,45 @@
+addSql('ALTER TABLE pokemon DROP FOREIGN KEY FK_62DC90F3553A6EC4');
+ $this->addSql('ALTER TABLE pokemon DROP FOREIGN KEY FK_62DC90F3AD1A0C0F');
+ $this->addSql('ALTER TABLE pokemon DROP FOREIGN KEY FK_62DC90F3BFAFA3E1');
+ $this->addSql('CREATE TABLE generation_poke (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
+ $this->addSql('CREATE TABLE type_poke (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
+ $this->addSql('DROP TABLE generation');
+ $this->addSql('DROP TABLE pokemon');
+ $this->addSql('DROP TABLE type');
+ }
+
+ public function down(Schema $schema) : void
+ {
+ // this down() migration is auto-generated, please modify it to your needs
+ $this->addSql('CREATE TABLE generation (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
+ $this->addSql('CREATE TABLE pokemon (id INT AUTO_INCREMENT NOT NULL, type1_id INT NOT NULL, type2_id INT DEFAULT NULL, generation_id INT NOT NULL, nom VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, vie INT NOT NULL, attaque INT NOT NULL, defense INT NOT NULL, legendaire TINYINT(1) NOT NULL, INDEX IDX_62DC90F3553A6EC4 (generation_id), INDEX IDX_62DC90F3BFAFA3E1 (type1_id), INDEX IDX_62DC90F3AD1A0C0F (type2_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
+ $this->addSql('CREATE TABLE type (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
+ $this->addSql('ALTER TABLE pokemon ADD CONSTRAINT FK_62DC90F3553A6EC4 FOREIGN KEY (generation_id) REFERENCES generation (id)');
+ $this->addSql('ALTER TABLE pokemon ADD CONSTRAINT FK_62DC90F3AD1A0C0F FOREIGN KEY (type2_id) REFERENCES type (id)');
+ $this->addSql('ALTER TABLE pokemon ADD CONSTRAINT FK_62DC90F3BFAFA3E1 FOREIGN KEY (type1_id) REFERENCES type (id)');
+ $this->addSql('DROP TABLE generation_poke');
+ $this->addSql('DROP TABLE type_poke');
+ }
+}
diff --git a/migrations/Version20210326144901.php b/migrations/Version20210326144901.php
new file mode 100644
index 0000000..4f2f010
--- /dev/null
+++ b/migrations/Version20210326144901.php
@@ -0,0 +1,34 @@
+addSql('CREATE TABLE pokemon (id INT AUTO_INCREMENT NOT NULL, type1_id INT NOT NULL, type2_id INT DEFAULT NULL, generation_id INT DEFAULT NULL, nom VARCHAR(255) NOT NULL, vie INT NOT NULL, attaque INT NOT NULL, defense INT NOT NULL, legendaire TINYINT(1) NOT NULL, INDEX IDX_62DC90F3BFAFA3E1 (type1_id), INDEX IDX_62DC90F3AD1A0C0F (type2_id), INDEX IDX_62DC90F3553A6EC4 (generation_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
+ $this->addSql('ALTER TABLE pokemon ADD CONSTRAINT FK_62DC90F3BFAFA3E1 FOREIGN KEY (type1_id) REFERENCES type_poke (id)');
+ $this->addSql('ALTER TABLE pokemon ADD CONSTRAINT FK_62DC90F3AD1A0C0F FOREIGN KEY (type2_id) REFERENCES type_poke (id)');
+ $this->addSql('ALTER TABLE pokemon ADD CONSTRAINT FK_62DC90F3553A6EC4 FOREIGN KEY (generation_id) REFERENCES generation_poke (id)');
+ }
+
+ public function down(Schema $schema) : void
+ {
+ // this down() migration is auto-generated, please modify it to your needs
+ $this->addSql('DROP TABLE pokemon');
+ }
+}
diff --git a/sql/generation.sql b/sql/generation.sql
new file mode 100644
index 0000000..1597c53
--- /dev/null
+++ b/sql/generation.sql
@@ -0,0 +1,8 @@
+INSERT INTO generation_poke(Id,Name) VALUES (1,'1 Kanto');
+INSERT INTO generation_poke(Id,Name) VALUES (2,'2 Johto');
+INSERT INTO generation_poke(Id,Name) VALUES (3,'3 Hoenn');
+INSERT INTO generation_poke(Id,Name) VALUES (4,'4 Sinnoh');
+INSERT INTO generation_poke(Id,Name) VALUES (5,'5 Unys');
+INSERT INTO generation_poke(Id,Name) VALUES (6,'6 Kalos');
+INSERT INTO generation_poke(Id,Name) VALUES (7,'7 Alola');
+INSERT INTO generation_poke(Id,Name) VALUES (8,'8 Galar');
\ No newline at end of file
diff --git a/sql/pokemon.sql b/sql/pokemon.sql
new file mode 100644
index 0000000..e69de29
diff --git a/sql/type.sql b/sql/type.sql
new file mode 100644
index 0000000..af168e9
--- /dev/null
+++ b/sql/type.sql
@@ -0,0 +1,18 @@
+INSERT INTO type_poke(Id,Name) VALUES (1,'Bug');
+INSERT INTO type_poke(Id,Name) VALUES (2,'Dark');
+INSERT INTO type_poke(Id,Name) VALUES (3,'Dragon');
+INSERT INTO type_poke(Id,Name) VALUES (4,'Electric');
+INSERT INTO type_poke(Id,Name) VALUES (5,'Fairy');
+INSERT INTO type_poke(Id,Name) VALUES (6,'Fighting');
+INSERT INTO type_poke(Id,Name) VALUES (7,'Fire');
+INSERT INTO type_poke(Id,Name) VALUES (8,'Flying');
+INSERT INTO type_poke(Id,Name) VALUES (9,'Ghost');
+INSERT INTO type_poke(Id,Name) VALUES (10,'Grass');
+INSERT INTO type_poke(Id,Name) VALUES (11,'Ground');
+INSERT INTO type_poke(Id,Name) VALUES (12,'Ice');
+INSERT INTO type_poke(Id,Name) VALUES (13,'Normal');
+INSERT INTO type_poke(Id,Name) VALUES (14,'Poison');
+INSERT INTO type_poke(Id,Name) VALUES (15,'Psychic');
+INSERT INTO type_poke(Id,Name) VALUES (16,'Rock');
+INSERT INTO type_poke(Id,Name) VALUES (17,'Steel');
+INSERT INTO type_poke(Id,Name) VALUES (18,'Water');
\ No newline at end of file
diff --git a/src/Entity/GenerationPoke.php b/src/Entity/GenerationPoke.php
new file mode 100644
index 0000000..c468779
--- /dev/null
+++ b/src/Entity/GenerationPoke.php
@@ -0,0 +1,87 @@
+pokemon = new ArrayCollection();
+ }
+
+ public function getId(): ?int
+ {
+ return $this->id;
+ }
+
+ public function getName(): ?string
+ {
+ return $this->name;
+ }
+
+ public function setName(string $name): self
+ {
+ $this->name = $name;
+
+ return $this;
+ }
+
+ /**
+ * @return Collection|Pokemon[]
+ */
+ public function getPokemon(): Collection
+ {
+ return $this->pokemon;
+ }
+
+ public function addPokemon(Pokemon $pokemon): self
+ {
+ if (!$this->pokemon->contains($pokemon)) {
+ $this->pokemon[] = $pokemon;
+ $pokemon->setGeneration($this);
+ }
+
+ return $this;
+ }
+
+ public function removePokemon(Pokemon $pokemon): self
+ {
+ if ($this->pokemon->removeElement($pokemon)) {
+ // set the owning side to null (unless already changed)
+ if ($pokemon->getGeneration() === $this) {
+ $pokemon->setGeneration(null);
+ }
+ }
+
+ return $this;
+ }
+}
diff --git a/src/Entity/Pokemon.php b/src/Entity/Pokemon.php
new file mode 100644
index 0000000..dc9b0ed
--- /dev/null
+++ b/src/Entity/Pokemon.php
@@ -0,0 +1,177 @@
+id;
+ }
+
+ public function getNom(): ?string
+ {
+ return $this->nom;
+ }
+
+ public function setNom(string $nom): self
+ {
+ $this->nom = $nom;
+
+ return $this;
+ }
+
+ public function getType1(): ?TypePoke
+ {
+ return $this->type1;
+ }
+
+ public function setType1(?TypePoke $type1): self
+ {
+ $this->type1 = $type1;
+
+ return $this;
+ }
+
+ public function getType2(): ?TypePoke
+ {
+ return $this->type2;
+ }
+
+ public function setType2(?TypePoke $type2): self
+ {
+ $this->type2 = $type2;
+
+ return $this;
+ }
+
+ public function getVie(): ?int
+ {
+ return $this->vie;
+ }
+
+ public function setVie(int $vie): self
+ {
+ $this->vie = $vie;
+
+ return $this;
+ }
+
+ public function getAttaque(): ?int
+ {
+ return $this->attaque;
+ }
+
+ public function setAttaque(int $attaque): self
+ {
+ $this->attaque = $attaque;
+
+ return $this;
+ }
+
+ public function getDefense(): ?int
+ {
+ return $this->defense;
+ }
+
+ public function setDefense(int $defense): self
+ {
+ $this->defense = $defense;
+
+ return $this;
+ }
+
+ public function getLegendaire(): ?bool
+ {
+ return $this->legendaire;
+ }
+
+ public function setLegendaire(bool $legendaire): self
+ {
+ $this->legendaire = $legendaire;
+
+ return $this;
+ }
+
+ public function getGeneration(): ?GenerationPoke
+ {
+ return $this->generation;
+ }
+
+ public function setGeneration(?GenerationPoke $generation): self
+ {
+ $this->generation = $generation;
+
+ return $this;
+ }
+}
diff --git a/src/Entity/TypePoke.php b/src/Entity/TypePoke.php
new file mode 100644
index 0000000..5713354
--- /dev/null
+++ b/src/Entity/TypePoke.php
@@ -0,0 +1,91 @@
+pokemon = new ArrayCollection();
+ }
+
+ public function getId(): ?int
+ {
+ return $this->id;
+ }
+
+ public function getName(): ?string
+ {
+ return $this->name;
+ }
+
+ public function setName(string $name): self
+ {
+ $this->name = $name;
+
+ return $this;
+ }
+
+ /**
+ * @return Collection|Pokemon[]
+ */
+ public function getPokemon(): Collection
+ {
+ return $this->pokemon;
+ }
+
+ public function addPokemon(Pokemon $pokemon): self
+ {
+ if (!$this->pokemon->contains($pokemon)) {
+ $this->pokemon[] = $pokemon;
+ $pokemon->setType1($this);
+ }
+
+ return $this;
+ }
+
+ public function removePokemon(Pokemon $pokemon): self
+ {
+ if ($this->pokemon->removeElement($pokemon)) {
+ // set the owning side to null (unless already changed)
+ if ($pokemon->getType1() === $this) {
+ $pokemon->setType1(null);
+ }
+ }
+
+ return $this;
+ }
+}
diff --git a/src/Repository/GenerationPokeRepository.php b/src/Repository/GenerationPokeRepository.php
new file mode 100644
index 0000000..529db77
--- /dev/null
+++ b/src/Repository/GenerationPokeRepository.php
@@ -0,0 +1,50 @@
+createQueryBuilder('g')
+ ->andWhere('g.exampleField = :val')
+ ->setParameter('val', $value)
+ ->orderBy('g.id', 'ASC')
+ ->setMaxResults(10)
+ ->getQuery()
+ ->getResult()
+ ;
+ }
+ */
+
+ /*
+ public function findOneBySomeField($value): ?GenerationPoke
+ {
+ return $this->createQueryBuilder('g')
+ ->andWhere('g.exampleField = :val')
+ ->setParameter('val', $value)
+ ->getQuery()
+ ->getOneOrNullResult()
+ ;
+ }
+ */
+}
diff --git a/src/Repository/PokemonRepository.php b/src/Repository/PokemonRepository.php
new file mode 100644
index 0000000..148620f
--- /dev/null
+++ b/src/Repository/PokemonRepository.php
@@ -0,0 +1,50 @@
+createQueryBuilder('p')
+ ->andWhere('p.exampleField = :val')
+ ->setParameter('val', $value)
+ ->orderBy('p.id', 'ASC')
+ ->setMaxResults(10)
+ ->getQuery()
+ ->getResult()
+ ;
+ }
+ */
+
+ /*
+ public function findOneBySomeField($value): ?Pokemon
+ {
+ return $this->createQueryBuilder('p')
+ ->andWhere('p.exampleField = :val')
+ ->setParameter('val', $value)
+ ->getQuery()
+ ->getOneOrNullResult()
+ ;
+ }
+ */
+}
diff --git a/src/Repository/TypePokeRepository.php b/src/Repository/TypePokeRepository.php
new file mode 100644
index 0000000..0c0948d
--- /dev/null
+++ b/src/Repository/TypePokeRepository.php
@@ -0,0 +1,50 @@
+createQueryBuilder('t')
+ ->andWhere('t.exampleField = :val')
+ ->setParameter('val', $value)
+ ->orderBy('t.id', 'ASC')
+ ->setMaxResults(10)
+ ->getQuery()
+ ->getResult()
+ ;
+ }
+ */
+
+ /*
+ public function findOneBySomeField($value): ?TypePoke
+ {
+ return $this->createQueryBuilder('t')
+ ->andWhere('t.exampleField = :val')
+ ->setParameter('val', $value)
+ ->getQuery()
+ ->getOneOrNullResult()
+ ;
+ }
+ */
+}
diff --git a/symfony.lock b/symfony.lock
index a2e69dc..ce5c9e5 100644
--- a/symfony.lock
+++ b/symfony.lock
@@ -1,4 +1,21 @@
{
+ "api-platform/api-pack": {
+ "version": "v1.3.0"
+ },
+ "api-platform/core": {
+ "version": "2.5",
+ "recipe": {
+ "repo": "github.com/symfony/recipes",
+ "branch": "master",
+ "version": "2.5",
+ "ref": "a93061567140e386f107be75340ac2aee3f86cbf"
+ },
+ "files": [
+ "config/packages/api_platform.yaml",
+ "config/routes/api_platform.yaml",
+ "src/Entity/.gitignore"
+ ]
+ },
"composer/package-versions-deprecated": {
"version": "1.11.99.1"
},
@@ -82,6 +99,9 @@
"egulias/email-validator": {
"version": "3.1.0"
},
+ "fig/link-util": {
+ "version": "1.1.2"
+ },
"friendsofphp/proxy-manager-lts": {
"version": "v1.0.3"
},
@@ -97,6 +117,18 @@
"monolog/monolog": {
"version": "2.2.0"
},
+ "nelmio/cors-bundle": {
+ "version": "1.5",
+ "recipe": {
+ "repo": "github.com/symfony/recipes",
+ "branch": "master",
+ "version": "1.5",
+ "ref": "6bea22e6c564fba3a1391615cada1437d0bde39c"
+ },
+ "files": [
+ "config/packages/nelmio_cors.yaml"
+ ]
+ },
"nikic/php-parser": {
"version": "v4.10.4"
},
@@ -517,5 +549,8 @@
},
"webmozart/assert": {
"version": "1.10.0"
+ },
+ "willdurand/negotiation": {
+ "version": "3.0.0"
}
}