Compare commits
	
		
			9 Commits 
		
	
	
		
			develop
			...
			feature/sy
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | 9e320f8920 | 4 years ago | 
|  | de955465a2 | 5 years ago | 
|  | 89f7dafbe5 | 5 years ago | 
|  | bf160a49cd | 5 years ago | 
|  | a4cf69e38c | 5 years ago | 
|  | 1098e6c362 | 5 years ago | 
|  | 994e6e17cb | 5 years ago | 
|  | 334f734012 | 5 years ago | 
|  | 7594b5af67 | 5 years ago | 
| @ -1,26 +1,32 @@ | ||||
| # This file defines all environment variables that the application needs. | ||||
| # DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE. | ||||
| # Use ".env.local" for local overrides during development. | ||||
| # Use real environment variables when deploying to production. | ||||
| # https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration | ||||
| # In all environments, the following files are loaded if they exist, | ||||
| # the latter taking precedence over the former: | ||||
| # | ||||
| #  * .env                contains default values for the environment variables needed by the app | ||||
| #  * .env.local          uncommitted file with local overrides | ||||
| #  * .env.$APP_ENV       committed environment-specific defaults | ||||
| #  * .env.$APP_ENV.local uncommitted environment-specific overrides | ||||
| # | ||||
| # Real environment variables win over .env files. | ||||
| # | ||||
| # DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES. | ||||
| # | ||||
| # Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2). | ||||
| # https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration | ||||
| 
 | ||||
| ###> symfony/framework-bundle ### | ||||
| APP_ENV=dev | ||||
| APP_SECRET=879a6adeceeccbdc835a19f7e3aad7e8 | ||||
| #TRUSTED_PROXIES=127.0.0.1,127.0.0.2 | ||||
| #TRUSTED_HOSTS='^localhost|example\.com$' | ||||
| APP_SECRET=296bba2d9c7a4f6eee2c7611d66a8aec | ||||
| #TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 | ||||
| #TRUSTED_HOSTS='^(localhost|example\.com)$' | ||||
| ###< symfony/framework-bundle ### | ||||
| 
 | ||||
| ###> doctrine/doctrine-bundle ### | ||||
| # Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url | ||||
| # Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url | ||||
| # For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db" | ||||
| # Configure your db driver and server_version in config/packages/doctrine.yaml | ||||
| DATABASE_URL=sqlite:///%kernel.project_dir%/var/data.db | ||||
| # For a PostgreSQL database, use: "postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=11&charset=utf8" | ||||
| # IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml | ||||
| DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7 | ||||
| ###< doctrine/doctrine-bundle ### | ||||
| 
 | ||||
| ###> symfony/swiftmailer-bundle ### | ||||
| # For Gmail as a transport, use: "gmail://username:password@localhost" | ||||
| # For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode=" | ||||
| # Delivery is disabled by default via "null://localhost" | ||||
| MAILER_URL=null://localhost | ||||
| ###< symfony/swiftmailer-bundle ### | ||||
| ###> symfony/mailer ### | ||||
| # MAILER_DSN=smtp://localhost | ||||
| ###< symfony/mailer ### | ||||
|  | ||||
| @ -1,24 +0,0 @@ | ||||
| # This file is a "template" of which env vars need to be defined for your application | ||||
| # Copy this file to .env file for development, create environment variables when deploying to production | ||||
| # https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration | ||||
| 
 | ||||
| ###> symfony/framework-bundle ### | ||||
| APP_ENV=dev | ||||
| APP_SECRET=9d74944d92d8155f1c870695def94464 | ||||
| #TRUSTED_PROXIES=127.0.0.1,127.0.0.2 | ||||
| #TRUSTED_HOSTS=localhost,example.com | ||||
| ###< symfony/framework-bundle ### | ||||
| 
 | ||||
| ###> doctrine/doctrine-bundle ### | ||||
| # Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url | ||||
| # For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db" | ||||
| # Configure your db driver and server_version in config/packages/doctrine.yaml | ||||
| DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name | ||||
| ###< doctrine/doctrine-bundle ### | ||||
| 
 | ||||
| ###> symfony/swiftmailer-bundle ### | ||||
| # For Gmail as a transport, use: "gmail://username:password@localhost" | ||||
| # For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode=" | ||||
| # Delivery is disabled by default via "null://localhost" | ||||
| MAILER_URL=null://localhost | ||||
| ###< symfony/swiftmailer-bundle ### | ||||
| @ -1,4 +1,6 @@ | ||||
| # define your env variables for the test env here | ||||
| KERNEL_CLASS='App\Kernel' | ||||
| APP_SECRET='s$cretf0rt3st' | ||||
| APP_SECRET='$ecretf0rt3st' | ||||
| SYMFONY_DEPRECATIONS_HELPER=999999 | ||||
| PANTHER_APP_ENV=panther | ||||
| DATABASE_URL=sqlite:///%kernel.project_dir%/var/data_test.db | ||||
|  | ||||
| @ -0,0 +1,21 @@ | ||||
| pipeline { | ||||
|   agent any | ||||
|   stages { | ||||
|     stage('Build') { | ||||
|       agent any | ||||
|       steps { | ||||
|         sh 'composer install' | ||||
|       } | ||||
|     }     | ||||
|     stage('Test') { | ||||
|       steps { | ||||
|         sh 'php ./bin/phpunit --coverage-clover=\'reports/coverage/coverage.xml\' --coverage-html=\'reports/coverage\'' | ||||
|       } | ||||
|     } | ||||
|     stage('Coverage') { | ||||
|       steps { | ||||
|         step([$class: 'CloverPublisher', cloverReportDir: '/reports/coverage', cloverReportFileName: 'coverage.xml']) | ||||
|       } | ||||
|     } | ||||
|   }   | ||||
| } | ||||
| @ -1,19 +1,13 @@ | ||||
| #!/usr/bin/env php | ||||
| <?php | ||||
| 
 | ||||
| if (!file_exists(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) { | ||||
|     echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\n"; | ||||
| if (!file_exists(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) { | ||||
|     echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n"; | ||||
|     exit(1); | ||||
| } | ||||
| 
 | ||||
| if (false === getenv('SYMFONY_PHPUNIT_VERSION')) { | ||||
|     putenv('SYMFONY_PHPUNIT_VERSION=6.5'); | ||||
| } | ||||
| if (false === getenv('SYMFONY_PHPUNIT_REMOVE')) { | ||||
|     putenv('SYMFONY_PHPUNIT_REMOVE='); | ||||
| } | ||||
| if (false === getenv('SYMFONY_PHPUNIT_DIR')) { | ||||
|     putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit'); | ||||
| } | ||||
| 
 | ||||
| require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit'; | ||||
| require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php'; | ||||
|  | ||||
											
												
													File diff suppressed because it is too large
													Load Diff
												
											
										
									
								| @ -0,0 +1,23 @@ | ||||
| <?php | ||||
| 
 | ||||
| use Symfony\Component\Dotenv\Dotenv; | ||||
| 
 | ||||
| require dirname(__DIR__).'/vendor/autoload.php'; | ||||
| 
 | ||||
| if (!class_exists(Dotenv::class)) { | ||||
|     throw new LogicException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.'); | ||||
| } | ||||
| 
 | ||||
| // Load cached env vars if the .env.local.php file exists | ||||
| // Run "composer dump-env prod" to create it (requires symfony/flex >=1.2) | ||||
| if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && (!isset($env['APP_ENV']) || ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV'])) { | ||||
|     (new Dotenv(false))->populate($env); | ||||
| } else { | ||||
|     // load all the .env files | ||||
|     (new Dotenv(false))->loadEnv(dirname(__DIR__).'/.env'); | ||||
| } | ||||
| 
 | ||||
| $_SERVER += $_ENV; | ||||
| $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev'; | ||||
| $_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV']; | ||||
| $_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0'; | ||||
| @ -0,0 +1,29 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" | ||||
|     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||
|     xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping ../../vendor/doctrine/orm/doctrine-mapping.xsd "> | ||||
| 
 | ||||
|     <entity name="App\Entity\Event" repository-class="App\Repository\EventRepository"> | ||||
|         <id name="id" type="integer"> | ||||
|             <generator strategy="AUTO" /> | ||||
|         </id> | ||||
| 
 | ||||
|         <field name="type" type="integer" nullable="false" /> | ||||
|         <field name="version" type="integer" nullable="false" /> | ||||
| 
 | ||||
|         <one-to-many field="battles" mapped-by="event" target-entity="EventBattle"> | ||||
|             <cascade> | ||||
|                 <cascade-persist /> | ||||
|                 <cascade-merge /> | ||||
|             </cascade> | ||||
|         </one-to-many> | ||||
|         <one-to-many field="teams" mapped-by="event" target-entity="EventTeam"> | ||||
|             <cascade> | ||||
|                 <cascade-persist /> | ||||
|                 <cascade-merge /> | ||||
|             </cascade> | ||||
|         </one-to-many> | ||||
| 
 | ||||
| 
 | ||||
|     </entity> | ||||
| </doctrine-mapping> | ||||
| @ -0,0 +1,39 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <doctrine-mapping | ||||
| 	xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" | ||||
| 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||
| 	xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping ../../vendor/doctrine/orm/doctrine-mapping.xsd "> | ||||
| 
 | ||||
| 	<entity name="App\Entity\EventBattle" repository-class="App\Repository\EventBattleRepository"> | ||||
| 		<id name="event" association-key="true" /> | ||||
| 		<id name="event_battle_id" type="integer" /> | ||||
| 
 | ||||
| 		<field name="value" type="json" /> | ||||
| 
 | ||||
| 		<many-to-one field="event" target-entity="Event" inversed-by="battles"> | ||||
|                     <join-column on-delete="CASCADE" /> | ||||
|         </many-to-one> | ||||
|          | ||||
| 		<many-to-many field="heroes" target-entity="EventHero"> | ||||
| 		  <join-table name="event_battle_hero"> | ||||
|               <join-columns> | ||||
|                 <join-column name="event_id" referenced-column-name="event_id" on-delete="CASCADE"/> | ||||
|                 <join-column name="event_battle_id" referenced-column-name="event_battle_id" on-delete="CASCADE"/> | ||||
|               </join-columns> | ||||
|               <inverse-join-columns> | ||||
|                 <join-column name="event_id" referenced-column-name="event_id" on-delete="CASCADE" /> | ||||
|                 <join-column name="event_hero_id" referenced-column-name="event_hero_id" on-delete="CASCADE" /> | ||||
|               </inverse-join-columns> | ||||
| 		  </join-table> | ||||
| 		</many-to-many> | ||||
|         <many-to-one field="winningTeam" target-entity="EventTeam"> | ||||
|             <join-columns> | ||||
|                 <join-column name="event_id" referenced-column-name="event_id" on-delete="CASCADE" /> | ||||
|                 <join-column name="winning_team_id" referenced-column-name="event_team_id" on-delete="CASCADE" /> | ||||
|             </join-columns> | ||||
|         </many-to-one> | ||||
| 
 | ||||
| 	</entity> | ||||
| 
 | ||||
| 
 | ||||
| </doctrine-mapping> | ||||
| @ -0,0 +1,34 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" | ||||
|     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||
|     xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping ../../vendor/doctrine/orm/doctrine-mapping.xsd "> | ||||
| 
 | ||||
|     <entity name="App\Entity\EventHero" repository-class="App\Repository\EventHeroRepository"> | ||||
|         <id name="event" association-key="true" /> | ||||
|         <id name="event_hero_id" type="integer" /> | ||||
| 
 | ||||
|         <embedded name="skills" class="Skillz" /> | ||||
| 
 | ||||
|         <field name="name" type="string" length="32" unique="true" /> | ||||
| 
 | ||||
|         <many-to-one field="user" target-entity="User"> | ||||
|             <join-column on-delete="SET NULL" /> | ||||
|         </many-to-one> | ||||
| 
 | ||||
|         <many-to-one field="hero" target-entity="Hero"> | ||||
|             <join-column on-delete="SET NULL" /> | ||||
|         </many-to-one> | ||||
| 
 | ||||
|         <many-to-one field="event" target-entity="Event"> | ||||
|             <join-column on-delete="CASCADE" /> | ||||
|         </many-to-one> | ||||
| 
 | ||||
|         <many-to-one field="team" target-entity="EventTeam" inversed-by="heroes"> | ||||
|             <join-columns> | ||||
|                 <join-column name="event_id" referenced-column-name="event_id" on-delete="CASCADE "/> | ||||
|                 <join-column name="event_team_id" referenced-column-name="event_team_id" on-delete="CASCADE" /> | ||||
|             </join-columns> | ||||
|         </many-to-one> | ||||
| 
 | ||||
|     </entity> | ||||
| </doctrine-mapping> | ||||
| @ -0,0 +1,27 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" | ||||
|     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||
|     xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping ../../vendor/doctrine/orm/doctrine-mapping.xsd "> | ||||
| 
 | ||||
|     <entity name="App\Entity\EventTeam" repository-class="App\Repository\EventTeamRepository"> | ||||
|         <id name="event" association-key="true" /> | ||||
|         <id name="event_team_id" type="integer" /> | ||||
| 
 | ||||
|         <field name="name" type="string" length="32" unique="true" /> | ||||
| 
 | ||||
|         <!-- TODO: many-to-one referencing clan (nullable) --> | ||||
| 
 | ||||
|         <one-to-many field="heroes" mapped-by="team" target-entity="EventHero"> | ||||
|             <cascade> | ||||
|                 <cascade-persist /> | ||||
|                 <cascade-merge /> | ||||
|             </cascade> | ||||
|         </one-to-many> | ||||
| 
 | ||||
|         <many-to-one field="event" target-entity="Event" inversed-by="teams"> | ||||
|             <join-column on-delete="CASCADE" /> | ||||
|         </many-to-one> | ||||
| 
 | ||||
|     </entity> | ||||
| 
 | ||||
| </doctrine-mapping> | ||||
| @ -0,0 +1,20 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" | ||||
|     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||
|     xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping ../../vendor/doctrine/orm/doctrine-mapping.xsd "> | ||||
| 
 | ||||
|     <entity name="App\Entity\Hero" repository-class="App\Repository\HeroRepository"> | ||||
|         <id name="id" type="integer"> | ||||
|             <generator strategy="AUTO" /> | ||||
|         </id> | ||||
| 
 | ||||
|         <embedded name="skills" class="Skillz" /> | ||||
| 
 | ||||
|         <field name="name" type="string" length="32" unique="true" /> | ||||
| 
 | ||||
|         <many-to-one field="user" target-entity="User"> | ||||
|             <join-column on-delete="CASCADE" /> | ||||
|         </many-to-one> | ||||
| 
 | ||||
|     </entity> | ||||
| </doctrine-mapping> | ||||
| @ -1,21 +0,0 @@ | ||||
| App\Entity\Hero: | ||||
|     type: entity | ||||
|     repositoryClass: App\Repository\HeroRepository | ||||
|     table: hero | ||||
|     id: | ||||
|         id: | ||||
|             type: integer | ||||
|             generator: { strategy: AUTO } | ||||
|     fields: | ||||
|         name: | ||||
|             type: string | ||||
|             length: 32 | ||||
|             unique: true | ||||
| 
 | ||||
|     manyToOne: | ||||
|         user: | ||||
|             targetEntity: User | ||||
|             inversedBy: heroes | ||||
|             joinColumn: | ||||
|                 onDelete: CASCADE | ||||
|                 nullable: false | ||||
| @ -0,0 +1,22 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" | ||||
|     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||
|     xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping ../../vendor/doctrine/orm/doctrine-mapping.xsd "> | ||||
| 
 | ||||
|     <embeddable name="App\Entity\Skillz"> | ||||
|         <!-- basically the HP --> | ||||
|         <field name="constitution" type="integer" /> | ||||
| 
 | ||||
|         <!-- former MP! Some moves will require KI to function --> | ||||
|         <field name="ki" type="integer" /> | ||||
| 
 | ||||
|         <!-- damage dealer / block skill --> | ||||
|         <field name="strength" type="integer" /> | ||||
| 
 | ||||
|         <!-- evade / hit chance skill --> | ||||
|         <field name="agility" type="integer" /> | ||||
| 
 | ||||
|         <!-- if low => one is vulnerable for critical hits or slow attack speed / low damage --> | ||||
|         <field name="stamina" type="integer" /> | ||||
|     </embeddable> | ||||
| </doctrine-mapping> | ||||
| @ -0,0 +1,24 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" | ||||
|     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||
|     xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping ../../vendor/doctrine/orm/doctrine-mapping.xsd "> | ||||
| 
 | ||||
|     <entity name="App\Entity\User" repository-class="App\Repository\UserRepository"> | ||||
|         <id name="id" type="integer"> | ||||
|             <generator strategy="AUTO" /> | ||||
|         </id> | ||||
| 
 | ||||
|         <field name="username" type="string" length="32" unique="true" /> | ||||
|         <field name="password" /> | ||||
|         <field name="apiToken" unique="true" nullable="true" /> | ||||
|         <field name="roles" type="json" /> | ||||
| 
 | ||||
|         <one-to-many field="heroes" mapped-by="user" target-entity="Hero"> | ||||
|             <cascade> | ||||
|                 <cascade-persist /> | ||||
|                 <cascade-merge /> | ||||
|             </cascade> | ||||
|         </one-to-many> | ||||
| 
 | ||||
|     </entity> | ||||
| </doctrine-mapping> | ||||
| @ -1,26 +0,0 @@ | ||||
| App\Entity\User: | ||||
|     type: entity | ||||
|     repositoryClass: App\Repository\UserRepository | ||||
|     table: user | ||||
|     id: | ||||
|         id: | ||||
|             type: integer | ||||
|             generator: { strategy: AUTO } | ||||
|     fields: | ||||
|         username: | ||||
|             type: string | ||||
|             length: 32 | ||||
|             unique: true | ||||
|         password: # the hashed password | ||||
|             type: string | ||||
|         apiToken: | ||||
|             type: string | ||||
|             unique: true | ||||
|             nullable: true | ||||
|         roles: | ||||
|             type: json | ||||
|     oneToMany: | ||||
|         heroes: | ||||
|             targetEntity: Hero | ||||
|             mappedBy: user | ||||
|             cascade: ["persist", "merge"] | ||||
| @ -0,0 +1,19 @@ | ||||
| framework: | ||||
|     cache: | ||||
|         # Unique name of your app: used to compute stable namespaces for cache keys. | ||||
|         #prefix_seed: your_vendor_name/app_name | ||||
| 
 | ||||
|         # The "app" cache stores to the filesystem by default. | ||||
|         # The data in this cache should persist between deploys. | ||||
|         # Other options include: | ||||
| 
 | ||||
|         # Redis | ||||
|         #app: cache.adapter.redis | ||||
|         #default_redis_provider: redis://localhost | ||||
| 
 | ||||
|         # APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues) | ||||
|         #app: cache.adapter.apcu | ||||
| 
 | ||||
|         # Namespaced pools use the above "app" backend by default | ||||
|         #pools: | ||||
|             #my.dedicated.cache: null | ||||
| @ -1,4 +0,0 @@ | ||||
| # See https://symfony.com/doc/current/email/dev_environment.html | ||||
| swiftmailer: | ||||
|     # send all emails to a specific address | ||||
|     #delivery_addresses: ['me@example.com'] | ||||
| @ -1,25 +1,18 @@ | ||||
| parameters: | ||||
|     # Adds a fallback DATABASE_URL if the env var is not set. | ||||
|     # This allows you to run cache:warmup even if your | ||||
|     # environment variables are not available yet. | ||||
|     # You should not need to change this value. | ||||
|     env(DATABASE_URL): '' | ||||
| 
 | ||||
| doctrine: | ||||
|     dbal: | ||||
|         # configure these for your database server | ||||
|         driver: 'pdo_sqlite' | ||||
|         charset: utf8 | ||||
| 
 | ||||
|         url: '%env(resolve:DATABASE_URL)%' | ||||
| 
 | ||||
|         # IMPORTANT: You MUST configure your server version, | ||||
|         # either here or in the DATABASE_URL env var (see .env file) | ||||
|         #server_version: '5.7' | ||||
|     orm: | ||||
|         auto_generate_proxy_classes: true | ||||
|         naming_strategy: doctrine.orm.naming_strategy.underscore | ||||
|         naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware | ||||
|         auto_mapping: true | ||||
|         mappings: | ||||
|             App: | ||||
|                 is_bundle: false | ||||
|                 type: yml | ||||
|                 type: xml | ||||
|                 dir: '%kernel.project_dir%/config/orm' | ||||
|                 prefix: 'App\Entity' | ||||
|                 alias: App | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| doctrine_migrations: | ||||
|     dir_name: '%kernel.project_dir%/src/Migrations' | ||||
|     # namespace is arbitrary but should be different from App\Migrations | ||||
|     # as migrations classes should NOT be autoloaded | ||||
|     namespace: DoctrineMigrations | ||||
|     migrations_paths: | ||||
|         # namespace is arbitrary but should be different from App\Migrations | ||||
|         # as migrations classes should NOT be autoloaded | ||||
|         'DoctrineMigrations': '%kernel.project_dir%/migrations' | ||||
|  | ||||
| @ -0,0 +1,3 @@ | ||||
| framework: | ||||
|     mailer: | ||||
|         dsn: '%env(MAILER_DSN)%' | ||||
| @ -0,0 +1,16 @@ | ||||
| framework: | ||||
|     notifier: | ||||
|         #chatter_transports: | ||||
|         #    slack: '%env(SLACK_DSN)%' | ||||
|         #    telegram: '%env(TELEGRAM_DSN)%' | ||||
|         #texter_transports: | ||||
|         #    twilio: '%env(TWILIO_DSN)%' | ||||
|         #    nexmo: '%env(NEXMO_DSN)%' | ||||
|         channel_policy: | ||||
|             # use chat/slack, chat/telegram, sms/twilio or sms/nexmo | ||||
|             urgent: ['email'] | ||||
|             high: ['email'] | ||||
|             medium: ['email'] | ||||
|             low: ['email'] | ||||
|         admin_recipients: | ||||
|             - { email: admin@example.com } | ||||
| @ -0,0 +1,8 @@ | ||||
| # As of Symfony 5.1, deprecations are logged in the dedicated "deprecation" channel when it exists | ||||
| #monolog: | ||||
| #    channels: [deprecation] | ||||
| #    handlers: | ||||
| #        deprecation: | ||||
| #            type: stream | ||||
| #            channels: [deprecation] | ||||
| #            path: "%kernel.logs_dir%/%kernel.environment%.deprecations.log" | ||||
| @ -0,0 +1,3 @@ | ||||
| framework: | ||||
|     router: | ||||
|         strict_requirements: null | ||||
| @ -1,3 +1,7 @@ | ||||
| framework: | ||||
|     router: | ||||
|         strict_requirements: ~ | ||||
|         utf8: true | ||||
| 
 | ||||
|         # Configure how to generate URLs in non-HTTP contexts, such as CLI commands. | ||||
|         # See https://symfony.com/doc/current/routing.html#generating-urls-in-commands | ||||
|         #default_uri: http://localhost | ||||
|  | ||||
| @ -1,3 +0,0 @@ | ||||
| swiftmailer: | ||||
|     url: '%env(MAILER_URL)%' | ||||
|     spool: { type: 'memory' } | ||||
| @ -1,2 +0,0 @@ | ||||
| swiftmailer: | ||||
|     disable_delivery: true | ||||
| @ -0,0 +1,2 @@ | ||||
| twig: | ||||
|     strict_variables: true | ||||
| @ -0,0 +1,3 @@ | ||||
| framework: | ||||
|     validation: | ||||
|         not_compromised_password: false | ||||
| @ -1,6 +1,6 @@ | ||||
| framework: | ||||
|     default_locale: '%locale%' | ||||
|     default_locale: en | ||||
|     translator: | ||||
|         default_path: '%kernel.project_dir%/translations' | ||||
|         fallbacks: | ||||
|             - '%locale%' | ||||
|             - en | ||||
|  | ||||
| @ -1,3 +1,8 @@ | ||||
| framework: | ||||
|     validation: | ||||
|         email_validation_mode: html5 | ||||
| 
 | ||||
|         # Enables validator auto-mapping support. | ||||
|         # For instance, basic validation constraints will be inferred from Doctrine's metadata. | ||||
|         #auto_mapping: | ||||
|         #    App\Entity\: [] | ||||
|  | ||||
| @ -0,0 +1,5 @@ | ||||
| <?php | ||||
| 
 | ||||
| if (file_exists(dirname(__DIR__).'/var/cache/prod/App_KernelProdContainer.preload.php')) { | ||||
|     require dirname(__DIR__).'/var/cache/prod/App_KernelProdContainer.preload.php'; | ||||
| } | ||||
| @ -1,3 +1,13 @@ | ||||
| api_controllers: | ||||
|     prefix: api/ | ||||
|     resource: ../../src/Controller/Api | ||||
|     type: annotation | ||||
| 
 | ||||
| controllers: | ||||
|     resource: ../../src/Controller/ | ||||
|     prefix: main/{slug}/ | ||||
|     resource: ../../src/Controller/Std | ||||
|     type: annotation | ||||
| 
 | ||||
| kernel: | ||||
|     resource: ../../src/Kernel.php | ||||
|     type: annotation | ||||
|  | ||||
| @ -0,0 +1,3 @@ | ||||
| _errors: | ||||
|     resource: '@FrameworkBundle/Resources/config/routing/errors.xml' | ||||
|     prefix: /_error | ||||
| @ -1,3 +0,0 @@ | ||||
| _errors: | ||||
|     resource: '@TwigBundle/Resources/config/routing/errors.xml' | ||||
|     prefix: /_error | ||||
| @ -0,0 +1,12 @@ | ||||
| App\Entity\Event: | ||||
|     attributes: | ||||
|         id: | ||||
|             groups: ['Default'] | ||||
|         type: | ||||
|             groups: ['event_list', 'event_show'] | ||||
|         version: | ||||
|             groups: ['event_list', 'event_show'] | ||||
|         battles: | ||||
|             groups: ['event_show'] | ||||
|         teams: | ||||
|             groups: ['event_show'] | ||||
| @ -0,0 +1,10 @@ | ||||
| App\Entity\EventBattle: | ||||
|     attributes: | ||||
|         eid: | ||||
|             groups: ['Default'] | ||||
|         heroes: | ||||
|             groups: ['event_battle_list', 'event_battle_show'] | ||||
|         winningTeam: | ||||
|             groups: ['event_battle_list'] | ||||
|         value: | ||||
|             groups: ['event_battle_show'] | ||||
| @ -0,0 +1,14 @@ | ||||
| App\Entity\EventHero: | ||||
|     attributes: | ||||
|         eid: | ||||
|             groups: ['Default'] | ||||
|         name: | ||||
|             groups: ['event_hero_list'] | ||||
|         skills: | ||||
|             groups: ['event_hero_show'] | ||||
|         user: | ||||
|             groups: ['event_hero_show'] | ||||
|         hero: | ||||
|             groups: ['event_hero_show'] | ||||
|         team: | ||||
|             groups: ['event_hero_show'] | ||||
| @ -0,0 +1,8 @@ | ||||
| App\Entity\EventTeam: | ||||
|     attributes: | ||||
|         eid: | ||||
|             groups: ['Default'] | ||||
|         name: | ||||
|             groups: ['event_team_list', 'event_team_show'] | ||||
|         heroes: | ||||
|             groups: ['event_team_list', 'event_team_show'] | ||||
| @ -0,0 +1,12 @@ | ||||
| App\Entity\Skillz: | ||||
|     attributes: | ||||
|         constitution: | ||||
|             groups: ['Default'] | ||||
|         ki: | ||||
|             groups: ['Default'] | ||||
|         strength: | ||||
|             groups: ['Default'] | ||||
|         agility: | ||||
|             groups: ['Default'] | ||||
|         stamina: | ||||
|             groups: ['Default'] | ||||
| @ -0,0 +1,50 @@ | ||||
| <?php | ||||
| namespace App\Controller\Api; | ||||
| 
 | ||||
| use FOS\RestBundle\Controller\AbstractFOSRestController; | ||||
| use FOS\RestBundle\Controller\Annotations as Rest; | ||||
| use App\Repository\EventRepository; | ||||
| use App\Entity\Event; | ||||
| use App\Repository\EventBattleRepository; | ||||
| use App\Entity\EventBattle; | ||||
| 
 | ||||
| /** | ||||
|  * | ||||
|  * @Rest\Route("event/{eventId}/battle") | ||||
|  */ | ||||
| class EventBattleController extends AbstractFOSRestController | ||||
| { | ||||
| 
 | ||||
|     protected EventBattleRepository $repository; | ||||
| 
 | ||||
|     public function __construct(EventBattleRepository $repository) | ||||
|     { | ||||
|         $this->repository = $repository; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * | ||||
|      * @Rest\Route("s") | ||||
|      * @Rest\View(serializerGroups={"Default", "event_battle_list"}) | ||||
|      */ | ||||
|     public function cgetAction(int $eventId): array | ||||
|     { | ||||
|         return $this->repository->findBy([ | ||||
|             'event' => $eventId | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * | ||||
|      * @Rest\Route("/{eid}")) | ||||
|      * @Rest\View(serializerGroups={"Default", "event_battle_show"}) | ||||
|      */ | ||||
|     public function getAction(int $eventId, int $eid): ?EventBattle | ||||
|     { | ||||
|         return $this->repository->findOneBy([ | ||||
|             'event' => $eventId, | ||||
|             'eid' => $eid | ||||
|         ]); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @ -0,0 +1,43 @@ | ||||
| <?php | ||||
| namespace App\Controller\Api; | ||||
| 
 | ||||
| use FOS\RestBundle\Controller\AbstractFOSRestController; | ||||
| use FOS\RestBundle\Controller\Annotations as Rest; | ||||
| use App\Repository\EventRepository; | ||||
| use App\Entity\Event; | ||||
| 
 | ||||
| /** | ||||
|  * | ||||
|  * @Rest\Route("event") | ||||
|  */ | ||||
| class EventController extends AbstractFOSRestController | ||||
| { | ||||
| 
 | ||||
|     protected EventRepository $eventRepository; | ||||
| 
 | ||||
|     public function __construct(EventRepository $eventRepository) | ||||
|     { | ||||
|         $this->eventRepository = $eventRepository; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * | ||||
|      * @Rest\Route("s") | ||||
|      * @Rest\View(serializerGroups={"Default", "event_list"}) | ||||
|      */ | ||||
|     public function cgetAction(): array | ||||
|     { | ||||
|         return $this->eventRepository->findAll(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * | ||||
|      * @Rest\Route("/{id}")) | ||||
|      * @Rest\View(serializerGroups={"Default", "event_show"}) | ||||
|      */ | ||||
|     public function getAction(int $id): ?Event | ||||
|     { | ||||
|         return $this->eventRepository->find($id); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @ -0,0 +1,50 @@ | ||||
| <?php | ||||
| namespace App\Controller\Api; | ||||
| 
 | ||||
| use FOS\RestBundle\Controller\AbstractFOSRestController; | ||||
| use FOS\RestBundle\Controller\Annotations as Rest; | ||||
| use App\Repository\EventRepository; | ||||
| use App\Entity\Event; | ||||
| use App\Repository\EventHeroRepository; | ||||
| use App\Entity\EventHero; | ||||
| 
 | ||||
| /** | ||||
|  * | ||||
|  * @Rest\Route("event/{eventId}/hero") | ||||
|  */ | ||||
| class EventHeroController extends AbstractFOSRestController | ||||
| { | ||||
| 
 | ||||
|     protected EventHeroRepository $repository; | ||||
| 
 | ||||
|     public function __construct(EventHeroRepository $repository) | ||||
|     { | ||||
|         $this->repository = $repository; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * | ||||
|      * @Rest\Route("s") | ||||
|      * @Rest\View(serializerGroups={"Default", "event_hero_list"}) | ||||
|      */ | ||||
|     public function cgetAction(int $eventId): array | ||||
|     { | ||||
|         return $this->repository->findBy([ | ||||
|             'event' => $eventId | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * | ||||
|      * @Rest\Route("/{eid}")) | ||||
|      * @Rest\View(serializerGroups={"Default", "event_hero_show"}) | ||||
|      */ | ||||
|     public function getAction(int $eventId, int $eid): ?EventHero | ||||
|     { | ||||
|         return $this->repository->findOneBy([ | ||||
|             'event' => $eventId, | ||||
|             'eid' => $eid | ||||
|         ]); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @ -0,0 +1,50 @@ | ||||
| <?php | ||||
| namespace App\Controller\Api; | ||||
| 
 | ||||
| use FOS\RestBundle\Controller\AbstractFOSRestController; | ||||
| use FOS\RestBundle\Controller\Annotations as Rest; | ||||
| use App\Repository\EventRepository; | ||||
| use App\Entity\Event; | ||||
| use App\Repository\EventTeamRepository; | ||||
| use App\Entity\EventTeam; | ||||
| 
 | ||||
| /** | ||||
|  * | ||||
|  * @Rest\Route("event/{eventId}/team") | ||||
|  */ | ||||
| class EventTeamController extends AbstractFOSRestController | ||||
| { | ||||
| 
 | ||||
|     protected EventTeamRepository $repository; | ||||
| 
 | ||||
|     public function __construct(EventTeamRepository $repository) | ||||
|     { | ||||
|         $this->repository = $repository; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * | ||||
|      * @Rest\Route("s") | ||||
|      * @Rest\View(serializerGroups={"Default", "event_team_list"}) | ||||
|      */ | ||||
|     public function cgetAction(int $eventId): array | ||||
|     { | ||||
|         return $this->repository->findBy([ | ||||
|             'event' => $eventId | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * | ||||
|      * @Rest\Route("/{eid}")) | ||||
|      * @Rest\View(serializerGroups={"Default", "event_team_show"}) | ||||
|      */ | ||||
|     public function getAction(int $eventId, int $eid): ?EventTeam | ||||
|     { | ||||
|         return $this->repository->findOneBy([ | ||||
|             'event' => $eventId, | ||||
|             'eid' => $eid | ||||
|         ]); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @ -0,0 +1,42 @@ | ||||
| <?php | ||||
| namespace App\Controller\Api; | ||||
| 
 | ||||
| use App\Repository\HeroRepository; | ||||
| use FOS\RestBundle\Controller\Annotations as Rest; | ||||
| use FOS\RestBundle\Controller\AbstractFOSRestController; | ||||
| use App\Entity\Hero; | ||||
| 
 | ||||
| /** | ||||
|  * | ||||
|  * @Rest\Route("hero") | ||||
|  */ | ||||
| class HeroController extends AbstractFOSRestController | ||||
| { | ||||
| 
 | ||||
|     protected HeroRepository $heroRepository; | ||||
| 
 | ||||
|     public function __construct(HeroRepository $heroRepository) | ||||
|     { | ||||
|         $this->heroRepository = $heroRepository; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * | ||||
|      * @Rest\Route("es") | ||||
|      * @Rest\View() | ||||
|      */ | ||||
|     public function cgetAction(): array | ||||
|     { | ||||
|         return $this->heroRepository->findAll(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * | ||||
|      * @Rest\Route("/{id}")) | ||||
|      * @Rest\View() | ||||
|      */ | ||||
|     public function getAction(int $id): ?Hero | ||||
|     { | ||||
|         return $this->heroRepository->find($id); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,42 @@ | ||||
| <?php | ||||
| namespace App\Controller\Api; | ||||
| 
 | ||||
| use App\Repository\UserRepository; | ||||
| use FOS\RestBundle\Controller\Annotations as Rest; | ||||
| use FOS\RestBundle\Controller\AbstractFOSRestController; | ||||
| use App\Entity\User; | ||||
| 
 | ||||
| /** | ||||
|  * | ||||
|  * @Rest\Route("api/user") | ||||
|  */ | ||||
| class UserController extends AbstractFOSRestController | ||||
| { | ||||
| 
 | ||||
|     protected UserRepository $userRepository; | ||||
| 
 | ||||
|     public function __construct(UserRepository $userRepository) | ||||
|     { | ||||
|         $this->userRepository = $userRepository; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * | ||||
|      * @Rest\Route("s") | ||||
|      * @Rest\View() | ||||
|      */ | ||||
|     public function cgetAction(): array | ||||
|     { | ||||
|         return $this->userRepository->findAll(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * | ||||
|      * @Rest\Route("/{id}")) | ||||
|      * @Rest\View() | ||||
|      */ | ||||
|     public function getAction(int $id): ?User | ||||
|     { | ||||
|         return $this->userRepository->find($id); | ||||
|     } | ||||
| } | ||||
| @ -1,30 +0,0 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace App\Controller; | ||||
| 
 | ||||
| use App\Repository\HeroRepository; | ||||
| use FOS\RestBundle\Controller\Annotations as Rest; | ||||
| use FOS\RestBundle\Controller\FOSRestController; | ||||
| use Symfony\Component\HttpFoundation\Response; | ||||
| 
 | ||||
| /** | ||||
|  * @Rest\RouteResource("Hero") | ||||
|  */ | ||||
| class HeroController extends FOSRestController | ||||
| { | ||||
|     protected $heroRepository; | ||||
|      | ||||
|     public function __construct(HeroRepository $heroRepository) | ||||
|     { | ||||
|         $this->heroRepository = $heroRepository; | ||||
|     } | ||||
|      | ||||
|     /** | ||||
|      * @Rest\View() | ||||
|      */ | ||||
|     public function cgetAction() | ||||
|     { | ||||
|         $heroes = $this->heroRepository->findAll(); | ||||
|         return $this->view($heroes, Response::HTTP_OK); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,19 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace App\Controller\Std; | ||||
| 
 | ||||
| use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||||
| use Symfony\Component\Routing\Annotation\Route; | ||||
| 
 | ||||
| class LandingController extends AbstractController | ||||
| { | ||||
|     /** | ||||
|      * @Route("/", name="landing") | ||||
|      */ | ||||
|     public function index() | ||||
|     { | ||||
|         return $this->render('landing/index.html.twig', [ | ||||
|             'controller_name' => 'LandingController', | ||||
|         ]); | ||||
|     } | ||||
| } | ||||
| @ -1,31 +0,0 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace App\Controller; | ||||
| 
 | ||||
| use App\Repository\UserRepository; | ||||
| use FOS\RestBundle\Controller\Annotations as Rest; | ||||
| use FOS\RestBundle\Controller\FOSRestController; | ||||
| use Symfony\Component\HttpFoundation\Response; | ||||
| 
 | ||||
| /** | ||||
|  * @Rest\RouteResource("User") | ||||
|  */ | ||||
| class UserController extends FOSRestController | ||||
| { | ||||
|     protected $userRepository; | ||||
|      | ||||
|     public function __construct(UserRepository $userRepository) | ||||
|     { | ||||
|         $this->userRepository = $userRepository; | ||||
|     } | ||||
|      | ||||
|     /** | ||||
|      * @Rest\View() | ||||
|      */ | ||||
|     public function cgetAction() | ||||
|     { | ||||
|         $users = $this->userRepository->findAll(); | ||||
|         return $this->view($users, Response::HTTP_OK); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,36 @@ | ||||
| <?php | ||||
| namespace App\DataFixtures; | ||||
| 
 | ||||
| use Doctrine\Common\DataFixtures\DependentFixtureInterface; | ||||
| use Doctrine\Bundle\FixturesBundle\Fixture; | ||||
| use Doctrine\Persistence\ObjectManager; | ||||
| use App\Entity\EventBattle; | ||||
| 
 | ||||
| class EventBattleFixtures extends Fixture implements DependentFixtureInterface | ||||
| { | ||||
| 
 | ||||
|     public function load(ObjectManager $manager) | ||||
|     { | ||||
|         $event1 = $this->getReference(EventFixtures::REF_1); | ||||
|         $eventTeam1 = $this->getReference(EventFixtures::REF_EVENT1_TEAM1); | ||||
|         $eventHero1 = $this->getReference(EventFixtures::REF_EVENT1_CHAR1); | ||||
|         $eventHero2 = $this->getReference(EventFixtures::REF_EVENT1_CHAR2); | ||||
| 
 | ||||
|         $eventBattle = new EventBattle($event1, 1); | ||||
|         $eventBattle->addHero($eventHero1); | ||||
|         $eventBattle->addHero($eventHero2); | ||||
|         $eventBattle->setWinningTeam($eventTeam1); | ||||
| 
 | ||||
|         $manager->persist($eventBattle); | ||||
| 
 | ||||
|         $manager->flush(); | ||||
|     } | ||||
| 
 | ||||
|     public function getDependencies() | ||||
|     { | ||||
|         return array( | ||||
|             EventFixtures::class | ||||
|         ); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @ -0,0 +1,66 @@ | ||||
| <?php | ||||
| namespace App\DataFixtures; | ||||
| 
 | ||||
| use App\Entity\Event; | ||||
| use App\Entity\EventTeam; | ||||
| use Doctrine\Bundle\FixturesBundle\Fixture; | ||||
| use Doctrine\Common\DataFixtures\DependentFixtureInterface; | ||||
| use Doctrine\Persistence\ObjectManager; | ||||
| use App\Entity\EventHero; | ||||
| 
 | ||||
| class EventFixtures extends Fixture implements DependentFixtureInterface | ||||
| { | ||||
| 
 | ||||
|     public const REF_1 = 'event-1-reference'; | ||||
| 
 | ||||
|     public const REF_2 = 'event-2-reference'; | ||||
| 
 | ||||
|     public const REF_EVENT1_CHAR1 = 'event-1-char-1-reference'; | ||||
| 
 | ||||
|     public const REF_EVENT1_TEAM1 = 'event-1-team-1-reference'; | ||||
| 
 | ||||
|     public const REF_EVENT1_CHAR2 = 'event-1-char-2-reference'; | ||||
| 
 | ||||
|     public const REF_EVENT1_TEAM2 = 'event-1-team-2-reference'; | ||||
| 
 | ||||
|     public function load(ObjectManager $manager) | ||||
|     { | ||||
|         $heroUser1 = $this->getReference(UserFixtures::ADMIN_USER_REFERENCE)->getHeroes()[0]; | ||||
|         $heroUser2 = $this->getReference(UserFixtures::DUDE_USER_REFERENCE)->getHeroes()[0]; | ||||
| 
 | ||||
|         $event1 = new Event(Event::FREE_BATTLE); | ||||
|         $manager->persist($event1); | ||||
| 
 | ||||
|         $event2 = new Event(Event::TOURNAMENT); | ||||
|         $manager->persist($event2); | ||||
| 
 | ||||
|         $eventTeam1 = new EventTeam($event1, 1, "A Team"); | ||||
|         $eventTeam2 = new EventTeam($event1, 2, "B Team"); | ||||
| 
 | ||||
|         $manager->persist($eventTeam1); | ||||
|         $manager->persist($eventTeam2); | ||||
| 
 | ||||
|         $eventHero1 = new EventHero($event1, $heroUser1, $eventTeam1); | ||||
|         $eventHero2 = new EventHero($event1, $heroUser2, $eventTeam2); | ||||
|         $manager->persist($eventHero1); | ||||
|         $manager->persist($eventHero2); | ||||
| 
 | ||||
|         $manager->flush(); | ||||
| 
 | ||||
|         $this->addReference(self::REF_1, $event1); | ||||
|         $this->addReference(self::REF_2, $event2); | ||||
|         $this->addReference(self::REF_EVENT1_CHAR1, $eventHero1); | ||||
|         $this->addReference(self::REF_EVENT1_CHAR2, $eventHero2); | ||||
|         $this->addReference(self::REF_EVENT1_TEAM1, $eventTeam1); | ||||
|         $this->addReference(self::REF_EVENT1_TEAM2, $eventTeam2); | ||||
|     } | ||||
| 
 | ||||
|     public function getDependencies() | ||||
|     { | ||||
|         return array( | ||||
|             UserFixtures::class, | ||||
|             HeroFixtures::class | ||||
|         ); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @ -1,29 +1,34 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace App\DataFixtures; | ||||
| 
 | ||||
| use App\Entity\Hero; | ||||
| use Doctrine\Bundle\FixturesBundle\Fixture; | ||||
| use Doctrine\Common\Persistence\ObjectManager; | ||||
| use Doctrine\Persistence\ObjectManager; | ||||
| use Doctrine\Common\DataFixtures\DependentFixtureInterface; | ||||
| 
 | ||||
| class HeroFixtures extends Fixture implements DependentFixtureInterface | ||||
| { | ||||
| 
 | ||||
|     public function load(ObjectManager $manager) | ||||
|     { | ||||
|         $hero = new Hero(); | ||||
|         $hero->setName('ruffy'); | ||||
|         $hero->setUser($this->getReference(UserFixtures::ADMIN_USER_REFERENCE)); | ||||
|          | ||||
| 
 | ||||
|         $manager->persist($hero); | ||||
| 
 | ||||
|         $hero = new Hero(); | ||||
|         $hero->setName('goku'); | ||||
|         $hero->setUser($this->getReference(UserFixtures::DUDE_USER_REFERENCE)); | ||||
|         $manager->persist($hero); | ||||
| 
 | ||||
|         $manager->flush(); | ||||
|     } | ||||
|      | ||||
| 
 | ||||
|     public function getDependencies() | ||||
|     { | ||||
|         return array( | ||||
|             UserFixtures::class, | ||||
|             UserFixtures::class | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -0,0 +1,131 @@ | ||||
| <?php | ||||
| namespace App\Entity; | ||||
| 
 | ||||
| use Doctrine\Common\Collections\ArrayCollection; | ||||
| use Doctrine\Common\Collections\Collection; | ||||
| 
 | ||||
| class Event | ||||
| { | ||||
| 
 | ||||
|     const QUEST = 1; | ||||
| 
 | ||||
|     const TOURNAMENT = 2; | ||||
| 
 | ||||
|     const FREE_BATTLE = 3; | ||||
| 
 | ||||
|     const LEAGUE_MATCHDAY = 4; | ||||
| 
 | ||||
|     const RESERVED_5 = 5; | ||||
| 
 | ||||
|     const CLAN_BATTLE = 6; | ||||
| 
 | ||||
|     private ?int $id; | ||||
| 
 | ||||
|     private int $type = self::QUEST; | ||||
| 
 | ||||
|     private int $version = 1; | ||||
| 
 | ||||
|     private Collection $battles; | ||||
| 
 | ||||
|     private Collection $teams; | ||||
| 
 | ||||
|     public function __construct(int $type = self::QUEST) | ||||
|     { | ||||
|         $this->heroes = new ArrayCollection(); | ||||
|         $this->battles = new ArrayCollection(); | ||||
|         $this->type = $type; | ||||
|         $this->teams = new ArrayCollection(); | ||||
|     } | ||||
| 
 | ||||
|     public function getType(): ?int | ||||
|     { | ||||
|         return $this->type; | ||||
|     } | ||||
| 
 | ||||
|     public function setType(int $type): self | ||||
|     { | ||||
|         $this->type = $type; | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function getVersion(): ?int | ||||
|     { | ||||
|         return $this->version; | ||||
|     } | ||||
| 
 | ||||
|     public function setVersion(int $version): self | ||||
|     { | ||||
|         $this->version = $version; | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function getId(): ?int | ||||
|     { | ||||
|         return $this->id; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @return Collection|EventBattle[] | ||||
|      */ | ||||
|     public function getBattles(): Collection | ||||
|     { | ||||
|         return $this->battles; | ||||
|     } | ||||
| 
 | ||||
|     public function addBattle(EventBattle $battle): self | ||||
|     { | ||||
|         if (!$this->battles->contains($battle)) { | ||||
|             $this->battles[] = $battle; | ||||
|             $battle->setEvent($this); | ||||
|         } | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function removeBattle(EventBattle $battle): self | ||||
|     { | ||||
|         if ($this->battles->contains($battle)) { | ||||
|             $this->battles->removeElement($battle); | ||||
|             // set the owning side to null (unless already changed) | ||||
|             if ($battle->getEvent() === $this) { | ||||
|                 $battle->setEvent(null); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @return Collection|EventTeam[] | ||||
|      */ | ||||
|     public function getTeams(): Collection | ||||
|     { | ||||
|         return $this->teams; | ||||
|     } | ||||
| 
 | ||||
|     public function addTeam(EventTeam $team): self | ||||
|     { | ||||
|         if (!$this->teams->contains($team)) { | ||||
|             $this->teams[] = $team; | ||||
|             $team->setEvent($this); | ||||
|         } | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function removeTeam(EventTeam $team): self | ||||
|     { | ||||
|         if ($this->teams->contains($team)) { | ||||
|             $this->teams->removeElement($team); | ||||
|             // set the owning side to null (unless already changed) | ||||
|             if ($team->getEvent() === $this) { | ||||
|                 $team->setEvent(null); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @ -0,0 +1,103 @@ | ||||
| <?php | ||||
| namespace App\Entity; | ||||
| 
 | ||||
| use Doctrine\Common\Collections\ArrayCollection; | ||||
| use Doctrine\Common\Collections\Collection; | ||||
| 
 | ||||
| class EventBattle | ||||
| { | ||||
| 
 | ||||
|     /** | ||||
|      * | ||||
|      * @var Event | ||||
|      */ | ||||
|     private $event = null; | ||||
| 
 | ||||
|     private int $event_battle_id = 0; | ||||
| 
 | ||||
|     private array $value = []; | ||||
| 
 | ||||
|     private Collection $heroes; | ||||
| 
 | ||||
|     /** | ||||
|      * | ||||
|      * @var EventTeam | ||||
|      */ | ||||
|     private $winningTeam; | ||||
| 
 | ||||
|     public function __construct(Event $event, int $event_battle_id) | ||||
|     { | ||||
|         $this->event = $event; | ||||
|         $this->event_battle_id = $event_battle_id; | ||||
|         $this->heroes = new ArrayCollection(); | ||||
|     } | ||||
| 
 | ||||
|     public function getValue(): ?array | ||||
|     { | ||||
|         return $this->value; | ||||
|     } | ||||
| 
 | ||||
|     public function setValue(array $value): self | ||||
|     { | ||||
|         $this->value = $value; | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function getEvent(): ?Event | ||||
|     { | ||||
|         return $this->event; | ||||
|     } | ||||
| 
 | ||||
|     public function setEvent(?Event $event): self | ||||
|     { | ||||
|         $this->event = $event; | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * | ||||
|      * @return Collection|EventHero[] | ||||
|      */ | ||||
|     public function getHeroes(): Collection | ||||
|     { | ||||
|         return $this->heroes; | ||||
|     } | ||||
| 
 | ||||
|     public function addHero(EventHero $hero): self | ||||
|     { | ||||
|         if (! $this->heroes->contains($hero)) { | ||||
|             $this->heroes[] = $hero; | ||||
|         } | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function removeHero(EventHero $hero): self | ||||
|     { | ||||
|         if ($this->heroes->contains($hero)) { | ||||
|             $this->heroes->removeElement($hero); | ||||
|         } | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function getWinningTeam(): ?EventTeam | ||||
|     { | ||||
|         return $this->winningTeam; | ||||
|     } | ||||
| 
 | ||||
|     public function setWinningTeam(?EventTeam $winningTeam): self | ||||
|     { | ||||
|         $this->winningTeam = $winningTeam; | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function getEventBattleId(): ?int | ||||
|     { | ||||
|         return $this->event_battle_id; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @ -0,0 +1,125 @@ | ||||
| <?php | ||||
| namespace App\Entity; | ||||
| 
 | ||||
| class EventHero | ||||
| { | ||||
| 
 | ||||
|     private int $event_hero_id = 0; | ||||
| 
 | ||||
|     private string $name; | ||||
| 
 | ||||
|     private Skillz $skills; | ||||
| 
 | ||||
|     /** | ||||
|      * | ||||
|      * @var Hero | ||||
|      */ | ||||
|     private $hero; | ||||
| 
 | ||||
|     /** | ||||
|      * | ||||
|      * @var User | ||||
|      */ | ||||
|     private $user; | ||||
| 
 | ||||
|     /** | ||||
|      * | ||||
|      * @var Event | ||||
|      */ | ||||
|     private $event; | ||||
| 
 | ||||
|     /** | ||||
|      * | ||||
|      * @var EventTeam | ||||
|      */ | ||||
|     private $team; | ||||
| 
 | ||||
|     public function __construct(Event $event, Hero $hero, EventTeam $team) | ||||
|     { | ||||
|         $this->event = $event; | ||||
|         $this->event_hero_id = $hero->getId(); | ||||
|         $this->name = $hero->getName(); | ||||
|         $this->skills = $hero->getSkills(); | ||||
|         $this->team = $team; | ||||
|         $this->hero = $hero; | ||||
|         $this->user = $hero->getUser(); | ||||
|     } | ||||
| 
 | ||||
|     public function getSkills(): Skillz | ||||
|     { | ||||
|         return $this->skills; | ||||
|     } | ||||
| 
 | ||||
|     public function setSkills(Skillz $skills): self | ||||
|     { | ||||
|         $this->skills = $skills; | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function getName(): ?string | ||||
|     { | ||||
|         return $this->name; | ||||
|     } | ||||
| 
 | ||||
|     public function setName(string $name): self | ||||
|     { | ||||
|         $this->name = $name; | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function getUser(): ?User | ||||
|     { | ||||
|         return $this->user; | ||||
|     } | ||||
| 
 | ||||
|     public function setUser(?User $user): self | ||||
|     { | ||||
|         $this->user = $user; | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function getHero(): ?Hero | ||||
|     { | ||||
|         return $this->hero; | ||||
|     } | ||||
| 
 | ||||
|     public function setHero(?Hero $hero): self | ||||
|     { | ||||
|         $this->hero = $hero; | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function getEvent(): ?Event | ||||
|     { | ||||
|         return $this->event; | ||||
|     } | ||||
| 
 | ||||
|     public function setEvent(?Event $event): self | ||||
|     { | ||||
|         $this->event = $event; | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function getTeam(): ?EventTeam | ||||
|     { | ||||
|         return $this->team; | ||||
|     } | ||||
| 
 | ||||
|     public function setTeam(?EventTeam $team): self | ||||
|     { | ||||
|         $this->team = $team; | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function getEventHeroId(): ?int | ||||
|     { | ||||
|         return $this->event_hero_id; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @ -0,0 +1,91 @@ | ||||
| <?php | ||||
| namespace App\Entity; | ||||
| 
 | ||||
| use Doctrine\Common\Collections\Collection; | ||||
| use Doctrine\Common\Collections\ArrayCollection; | ||||
| 
 | ||||
| class EventTeam | ||||
| { | ||||
| 
 | ||||
|     /** | ||||
|      * | ||||
|      * @var Event | ||||
|      */ | ||||
|     private $event = null; | ||||
| 
 | ||||
|     private int $event_team_id = 0; | ||||
| 
 | ||||
|     private string $name = ""; | ||||
| 
 | ||||
|     private Collection $heroes; | ||||
| 
 | ||||
|     public function __construct(Event $event, int $team_id, string $name) | ||||
|     { | ||||
|         $this->event = $event; | ||||
|         $this->event_team_id = $team_id; | ||||
|         $this->name = $name; | ||||
|         $this->heroes = new ArrayCollection(); | ||||
|     } | ||||
| 
 | ||||
|     public function getName(): ?string | ||||
|     { | ||||
|         return $this->name; | ||||
|     } | ||||
| 
 | ||||
|     public function setName(string $name): self | ||||
|     { | ||||
|         $this->name = $name; | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * | ||||
|      * @return Collection|EventHero[] | ||||
|      */ | ||||
|     public function getHeroes(): Collection | ||||
|     { | ||||
|         return $this->heroes; | ||||
|     } | ||||
| 
 | ||||
|     public function addHero(EventHero $hero): self | ||||
|     { | ||||
|         if (! $this->heroes->contains($hero)) { | ||||
|             $this->heroes[] = $hero; | ||||
|             $hero->setTeam($this); | ||||
|         } | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function removeHero(EventHero $hero): self | ||||
|     { | ||||
|         if ($this->heroes->contains($hero)) { | ||||
|             $this->heroes->removeElement($hero); | ||||
|             // set the owning side to null (unless already changed) | ||||
|             if ($hero->getTeam() === $this) { | ||||
|                 $hero->setTeam(null); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function getEvent(): ?Event | ||||
|     { | ||||
|         return $this->event; | ||||
|     } | ||||
| 
 | ||||
|     public function setEvent(?Event $event): self | ||||
|     { | ||||
|         $this->event = $event; | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function getEventTeamId(): ?int | ||||
|     { | ||||
|         return $this->event_team_id; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @ -0,0 +1,72 @@ | ||||
| <?php | ||||
| namespace App\Entity; | ||||
| 
 | ||||
| class Skillz | ||||
| { | ||||
|     private int $constitution = 0; | ||||
|     private int $ki = 0; | ||||
|     private int $strength = 0; | ||||
|     private int $agility = 0; | ||||
|     private int $stamina = 0; | ||||
| 
 | ||||
|     public function getStrength(): ?int | ||||
|     { | ||||
|         return $this->strength; | ||||
|     } | ||||
| 
 | ||||
|     public function setStrength(int $strength): self | ||||
|     { | ||||
|         $this->strength = $strength; | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function getAgility(): ?int | ||||
|     { | ||||
|         return $this->agility; | ||||
|     } | ||||
| 
 | ||||
|     public function setAgility(int $agility): self | ||||
|     { | ||||
|         $this->agility = $agility; | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function getStamina(): ?int | ||||
|     { | ||||
|         return $this->stamina; | ||||
|     } | ||||
| 
 | ||||
|     public function setStamina(int $stamina): self | ||||
|     { | ||||
|         $this->stamina = $stamina; | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function getConstitution(): ?int | ||||
|     { | ||||
|         return $this->constitution; | ||||
|     } | ||||
| 
 | ||||
|     public function setConstitution(int $constitution): self | ||||
|     { | ||||
|         $this->constitution = $constitution; | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function getKi(): ?int | ||||
|     { | ||||
|         return $this->ki; | ||||
|     } | ||||
| 
 | ||||
|     public function setKi(int $ki): self | ||||
|     { | ||||
|         $this->ki = $ki; | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @ -1,35 +0,0 @@ | ||||
| <?php declare(strict_types=1); | ||||
| 
 | ||||
| namespace DoctrineMigrations; | ||||
| 
 | ||||
| use Doctrine\DBAL\Schema\Schema; | ||||
| use Doctrine\Migrations\AbstractMigration; | ||||
| 
 | ||||
| /** | ||||
|  * Auto-generated Migration: Please modify to your needs! | ||||
|  */ | ||||
| final class Version20181118195745 extends AbstractMigration | ||||
| { | ||||
|     public function up(Schema $schema) : void | ||||
|     { | ||||
|         // this up() migration is auto-generated, please modify it to your needs | ||||
|         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'sqlite', 'Migration can only be executed safely on \'sqlite\'.'); | ||||
| 
 | ||||
|         $this->addSql('CREATE TABLE hero (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, user_id INTEGER NOT NULL, name VARCHAR(32) NOT NULL)'); | ||||
|         $this->addSql('CREATE UNIQUE INDEX UNIQ_51CE6E865E237E06 ON hero (name)'); | ||||
|         $this->addSql('CREATE INDEX IDX_51CE6E86A76ED395 ON hero (user_id)'); | ||||
|         $this->addSql('CREATE TABLE user (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, username VARCHAR(32) NOT NULL, password VARCHAR(255) NOT NULL, api_token VARCHAR(255) DEFAULT NULL, roles CLOB NOT NULL --(DC2Type:json) | ||||
|         )'); | ||||
|         $this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D649F85E0677 ON user (username)'); | ||||
|         $this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D6497BA2F5EB ON user (api_token)'); | ||||
|     } | ||||
| 
 | ||||
|     public function down(Schema $schema) : void | ||||
|     { | ||||
|         // this down() migration is auto-generated, please modify it to your needs | ||||
|         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'sqlite', 'Migration can only be executed safely on \'sqlite\'.'); | ||||
| 
 | ||||
|         $this->addSql('DROP TABLE hero'); | ||||
|         $this->addSql('DROP TABLE user'); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,22 @@ | ||||
| <?php | ||||
| namespace App\Repository; | ||||
| 
 | ||||
| use App\Entity\EventBattle; | ||||
| use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | ||||
| use Doctrine\Persistence\ManagerRegistry; | ||||
| 
 | ||||
| /** | ||||
|  * | ||||
|  * @method EventBattle|null find($id, $lockMode = null, $lockVersion = null) | ||||
|  * @method EventBattle|null findOneBy(array $criteria, array $orderBy = null) | ||||
|  * @method EventBattle[] findAll() | ||||
|  * @method EventBattle[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | ||||
|  */ | ||||
| class EventBattleRepository extends ServiceEntityRepository | ||||
| { | ||||
| 
 | ||||
|     public function __construct(ManagerRegistry $registry) | ||||
|     { | ||||
|         parent::__construct($registry, EventBattle::class); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,22 @@ | ||||
| <?php | ||||
| namespace App\Repository; | ||||
| 
 | ||||
| use App\Entity\EventHero; | ||||
| use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | ||||
| use Doctrine\Persistence\ManagerRegistry; | ||||
| 
 | ||||
| /** | ||||
|  * | ||||
|  * @method EventHero|null find($id, $lockMode = null, $lockVersion = null) | ||||
|  * @method EventHero|null findOneBy(array $criteria, array $orderBy = null) | ||||
|  * @method EventHero[] findAll() | ||||
|  * @method EventHero[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | ||||
|  */ | ||||
| class EventHeroRepository extends ServiceEntityRepository | ||||
| { | ||||
| 
 | ||||
|     public function __construct(ManagerRegistry $registry) | ||||
|     { | ||||
|         parent::__construct($registry, EventHero::class); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,22 @@ | ||||
| <?php | ||||
| namespace App\Repository; | ||||
| 
 | ||||
| use App\Entity\Event; | ||||
| use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | ||||
| use Doctrine\Persistence\ManagerRegistry; | ||||
| 
 | ||||
| /** | ||||
|  * | ||||
|  * @method Event|null find($id, $lockMode = null, $lockVersion = null) | ||||
|  * @method Event|null findOneBy(array $criteria, array $orderBy = null) | ||||
|  * @method Event[] findAll() | ||||
|  * @method Event[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | ||||
|  */ | ||||
| class EventRepository extends ServiceEntityRepository | ||||
| { | ||||
| 
 | ||||
|     public function __construct(ManagerRegistry $registry) | ||||
|     { | ||||
|         parent::__construct($registry, Event::class); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,22 @@ | ||||
| <?php | ||||
| namespace App\Repository; | ||||
| 
 | ||||
| use App\Entity\EventTeam; | ||||
| use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | ||||
| use Doctrine\Persistence\ManagerRegistry; | ||||
| 
 | ||||
| /** | ||||
|  * | ||||
|  * @method EventTeam|null find($id, $lockMode = null, $lockVersion = null) | ||||
|  * @method EventTeam|null findOneBy(array $criteria, array $orderBy = null) | ||||
|  * @method EventTeam[] findAll() | ||||
|  * @method EventTeam[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | ||||
|  */ | ||||
| class EventTeamRepository extends ServiceEntityRepository | ||||
| { | ||||
| 
 | ||||
|     public function __construct(ManagerRegistry $registry) | ||||
|     { | ||||
|         parent::__construct($registry, EventTeam::class); | ||||
|     } | ||||
| } | ||||
| @ -1,50 +1,22 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace App\Repository; | ||||
| 
 | ||||
| use App\Entity\Hero; | ||||
| use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | ||||
| use Symfony\Bridge\Doctrine\RegistryInterface; | ||||
| use Doctrine\Persistence\ManagerRegistry; | ||||
| 
 | ||||
| /** | ||||
|  * | ||||
|  * @method Hero|null find($id, $lockMode = null, $lockVersion = null) | ||||
|  * @method Hero|null findOneBy(array $criteria, array $orderBy = null) | ||||
|  * @method Hero[]    findAll() | ||||
|  * @method Hero[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | ||||
|  * @method Hero[] findAll() | ||||
|  * @method Hero[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | ||||
|  */ | ||||
| class HeroRepository extends ServiceEntityRepository | ||||
| { | ||||
|     public function __construct(RegistryInterface $registry) | ||||
|     { | ||||
|         parent::__construct($registry, Hero::class); | ||||
|     } | ||||
| 
 | ||||
|     // /** | ||||
|     //  * @return Hero[] Returns an array of Hero objects | ||||
|     //  */ | ||||
|     /* | ||||
|     public function findByExampleField($value) | ||||
|     public function __construct(ManagerRegistry $registry) | ||||
|     { | ||||
|         return $this->createQueryBuilder('h') | ||||
|             ->andWhere('h.exampleField = :val') | ||||
|             ->setParameter('val', $value) | ||||
|             ->orderBy('h.id', 'ASC') | ||||
|             ->setMaxResults(10) | ||||
|             ->getQuery() | ||||
|             ->getResult() | ||||
|         ; | ||||
|     } | ||||
|     */ | ||||
| 
 | ||||
|     /* | ||||
|     public function findOneBySomeField($value): ?Hero | ||||
|     { | ||||
|         return $this->createQueryBuilder('h') | ||||
|             ->andWhere('h.exampleField = :val') | ||||
|             ->setParameter('val', $value) | ||||
|             ->getQuery() | ||||
|             ->getOneOrNullResult() | ||||
|         ; | ||||
|         parent::__construct($registry, Hero::class); | ||||
|     } | ||||
|     */ | ||||
| } | ||||
|  | ||||
| @ -1,50 +1,22 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace App\Repository; | ||||
| 
 | ||||
| use App\Entity\User; | ||||
| use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | ||||
| use Symfony\Bridge\Doctrine\RegistryInterface; | ||||
| use Doctrine\Persistence\ManagerRegistry; | ||||
| 
 | ||||
| /** | ||||
|  * | ||||
|  * @method User|null find($id, $lockMode = null, $lockVersion = null) | ||||
|  * @method User|null findOneBy(array $criteria, array $orderBy = null) | ||||
|  * @method User[]    findAll() | ||||
|  * @method User[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | ||||
|  * @method User[] findAll() | ||||
|  * @method User[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | ||||
|  */ | ||||
| class UserRepository extends ServiceEntityRepository | ||||
| { | ||||
|     public function __construct(RegistryInterface $registry) | ||||
|     { | ||||
|         parent::__construct($registry, User::class); | ||||
|     } | ||||
| 
 | ||||
|     // /** | ||||
|     //  * @return User[] Returns an array of User objects | ||||
|     //  */ | ||||
|     /* | ||||
|     public function findByExampleField($value) | ||||
|     public function __construct(ManagerRegistry $registry) | ||||
|     { | ||||
|         return $this->createQueryBuilder('u') | ||||
|             ->andWhere('u.exampleField = :val') | ||||
|             ->setParameter('val', $value) | ||||
|             ->orderBy('u.id', 'ASC') | ||||
|             ->setMaxResults(10) | ||||
|             ->getQuery() | ||||
|             ->getResult() | ||||
|         ; | ||||
|     } | ||||
|     */ | ||||
| 
 | ||||
|     /* | ||||
|     public function findOneBySomeField($value): ?User | ||||
|     { | ||||
|         return $this->createQueryBuilder('u') | ||||
|             ->andWhere('u.exampleField = :val') | ||||
|             ->setParameter('val', $value) | ||||
|             ->getQuery() | ||||
|             ->getOneOrNullResult() | ||||
|         ; | ||||
|         parent::__construct($registry, User::class); | ||||
|     } | ||||
|     */ | ||||
| } | ||||
|  | ||||
| @ -0,0 +1,88 @@ | ||||
| <?php | ||||
| namespace App\Security; | ||||
| 
 | ||||
| use App\Repository\UserRepository; | ||||
| use Symfony\Component\HttpFoundation\Request; | ||||
| use Symfony\Component\Security\Core\User\UserInterface; | ||||
| use Symfony\Component\Security\Guard\AbstractGuardAuthenticator; | ||||
| use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; | ||||
| use Symfony\Component\Security\Core\Exception\AuthenticationException; | ||||
| use Symfony\Component\Security\Core\User\UserProviderInterface; | ||||
| use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; | ||||
| use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; | ||||
| use App\Entity\User; | ||||
| 
 | ||||
| class UrlAuthenticator extends AbstractGuardAuthenticator | ||||
| { | ||||
| 
 | ||||
|     /** | ||||
|      * Called on every request to decide if this authenticator should be | ||||
|      * used for the request. | ||||
|      * Returning false will cause this authenticator | ||||
|      * to be skipped. | ||||
|      */ | ||||
|     public function supports(Request $request) | ||||
|     { | ||||
|         return str_starts_with($request->getPathInfo(), "/main/"); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Called on every request. | ||||
|      * Return whatever credentials you want to | ||||
|      * be passed to getUser() as $credentials. | ||||
|      */ | ||||
|     public function getCredentials(Request $request) | ||||
|     { | ||||
|         $result = preg_replace('#/main/([^/]+)/#i', '$1', $request->getPathInfo()); | ||||
|         return $result === $request->getPathInfo() ? null : $result; | ||||
|     } | ||||
| 
 | ||||
|     public function getUser($credentials, UserProviderInterface $userProvider) | ||||
|     { | ||||
|         if (null === $credentials) { | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         $user = new User(); | ||||
|         $user->setUsername($credentials); | ||||
|         return $user; | ||||
|     } | ||||
| 
 | ||||
|     public function checkCredentials($credentials, UserInterface $user) | ||||
|     { | ||||
|         // check credentials - e.g. make sure the password is valid | ||||
|         // no credential check is needed in this case | ||||
| 
 | ||||
|         // return true to cause authentication success | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey) | ||||
|     { | ||||
|         // on success, let the request continue | ||||
|         return null; | ||||
|     } | ||||
| 
 | ||||
|     public function onAuthenticationFailure(Request $request, AuthenticationException $exception) | ||||
|     { | ||||
|         $message = strtr($exception->getMessageKey(), $exception->getMessageData()); | ||||
|         // or to translate this message | ||||
|         // $this->translator->trans($exception->getMessageKey(), $exception->getMessageData()) | ||||
| 
 | ||||
|         // This should translated by FOSRestBundle! | ||||
|         throw new AccessDeniedHttpException($message); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Called when authentication is needed, but it's not sent | ||||
|      */ | ||||
|     public function start(Request $request, AuthenticationException $authException = null) | ||||
|     { | ||||
|         throw new UnauthorizedHttpException('', 'Authentication Required'); | ||||
|     } | ||||
| 
 | ||||
|     public function supportsRememberMe(): bool | ||||
|     { | ||||
|         return false; | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,20 @@ | ||||
| {% extends 'base.html.twig' %} | ||||
| 
 | ||||
| {% block title %}Hello LandingController!{% endblock %} | ||||
| 
 | ||||
| {% block body %} | ||||
| <style> | ||||
|     .example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; } | ||||
|     .example-wrapper code { background: #F5F5F5; padding: 2px 6px; } | ||||
| </style> | ||||
| 
 | ||||
| <div class="example-wrapper"> | ||||
|     <h1>Hello {{ controller_name }}! ✅</h1> | ||||
| 
 | ||||
|     This friendly message is coming from: | ||||
|     <ul> | ||||
|         <li>Your controller at <code><a href="{{ '/home/pascal/git/animegame/src/Controller/Std/LandingController.php'|file_link(0) }}">src/Controller/Std/LandingController.php</a></code></li> | ||||
|         <li>Your template at <code><a href="{{ '/home/pascal/git/animegame/templates/landing/index.html.twig'|file_link(0) }}">templates/landing/index.html.twig</a></code></li> | ||||
|     </ul> | ||||
| </div> | ||||
| {% endblock %} | ||||
| @ -0,0 +1,34 @@ | ||||
| <?php | ||||
| namespace App\Tests\Controller; | ||||
| 
 | ||||
| use App\DataFixtures\UserFixtures; | ||||
| 
 | ||||
| class EventControllerTest extends RestTestBase | ||||
| { | ||||
| 
 | ||||
|     /** | ||||
|      * This test verifies that requesting | ||||
|      */ | ||||
|     public function testRetrieveUser() | ||||
|     { | ||||
|         $this->createRequestBuilder() | ||||
|             ->setMethod('GET') | ||||
|             ->setUri('/api/events') | ||||
|             ->setAcceptType('application/json') | ||||
|             ->addServerParameter('HTTP_X-AUTH-TOKEN', UserFixtures::ADMIN_USER_REFERENCE) | ||||
|             ->request(); | ||||
| 
 | ||||
|         $response = $this->client->getResponse(); | ||||
| 
 | ||||
|         $this->assertTrue($response->headers->contains('Content-Type', 'application/json'), 'the "Content-Type" header is "' . $response->headers->get('Content-Type') . '"' // optional message shown on failure | ||||
|         ); | ||||
| 
 | ||||
|         $this->assertEquals(200, $response->getStatusCode(), 'Status code was ' . $response->getStatusCode() . ' but expected 200: ' . $response->getContent()); | ||||
| 
 | ||||
|         $data = json_decode($response->getContent()); | ||||
| 
 | ||||
|         // Expect two events | ||||
|         $this->assertEquals(2, count($data)); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @ -0,0 +1,11 @@ | ||||
| <?php | ||||
| 
 | ||||
| use Symfony\Component\Dotenv\Dotenv; | ||||
| 
 | ||||
| require dirname(__DIR__).'/vendor/autoload.php'; | ||||
| 
 | ||||
| if (file_exists(dirname(__DIR__).'/config/bootstrap.php')) { | ||||
|     require dirname(__DIR__).'/config/bootstrap.php'; | ||||
| } elseif (method_exists(Dotenv::class, 'bootEnv')) { | ||||
|     (new Dotenv())->bootEnv(dirname(__DIR__).'/.env'); | ||||
| } | ||||
					Loading…
					
					
				
		Reference in New Issue