return arrays as such

develop
Baptiste Lemoine 3 years ago
parent a98f830800
commit 150dc50003
  1. 4
      .env
  2. 1
      .htaccess
  3. 5
      composer.json
  4. 64
      composer.lock
  5. 1
      config/bundles.php
  6. 15
      config/packages/nelmio_cors.yaml
  7. 15
      config/packages/nelmio_cors.yaml~
  8. 6
      src/Controller/DefaultController.php
  9. 6
      src/Entity/StackOfVotes.php
  10. 12
      symfony.lock

@ -27,3 +27,7 @@ APP_SECRET=597b0529ac702d27dcb9089f7e69c362
# IMPORTANT: You MUST also 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 ###
###> nelmio/cors-bundle ###
CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$
###< nelmio/cors-bundle ###

@ -0,0 +1 @@
Header set Access-Control-Allow-Origin "*"

@ -5,9 +5,11 @@
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"ext-json": "*",
"friendsofsymfony/rest-bundle": "^2.6",
"jms/serializer-bundle": "^3.4",
"nelmio/api-doc-bundle": "^3.4",
"nelmio/cors-bundle": "^2.0",
"sensio/framework-extra-bundle": "^5.5",
"symfony/console": "4.3.*",
"symfony/dotenv": "4.3.*",
@ -18,8 +20,7 @@
"symfony/maker-bundle": "^1.14",
"symfony/orm-pack": "^1.0",
"symfony/validator": "4.3.*",
"symfony/yaml": "4.3.*",
"ext-json": "*"
"symfony/yaml": "4.3.*"
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.2",

64
composer.lock generated

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "fa70b5946a14ecedaa82c3754b1601e7",
"content-hash": "41bf5f0471bb141a097830cb05bbf807",
"packages": [
{
"name": "doctrine/annotations",
@ -2489,6 +2489,63 @@
],
"time": "2019-02-18T16:27:10+00:00"
},
{
"name": "nelmio/cors-bundle",
"version": "2.0.1",
"source": {
"type": "git",
"url": "https://github.com/nelmio/NelmioCorsBundle.git",
"reference": "9683e6d30d000ef998919261329d825de7c53499"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nelmio/NelmioCorsBundle/zipball/9683e6d30d000ef998919261329d825de7c53499",
"reference": "9683e6d30d000ef998919261329d825de7c53499",
"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": "2019-11-15T08:54:08+00:00"
},
{
"name": "nikic/php-parser",
"version": "v4.2.5",
@ -5707,6 +5764,7 @@
"code",
"zf"
],
"abandoned": "laminas/laminas-code",
"time": "2019-10-05T23:18:22+00:00"
},
{
@ -5761,6 +5819,7 @@
"events",
"zf2"
],
"abandoned": "laminas/laminas-eventmanager",
"time": "2018-04-25T15:33:34+00:00"
},
{
@ -6068,7 +6127,8 @@
"platform": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*"
"ext-iconv": "*",
"ext-json": "*"
},
"platform-dev": []
}

@ -12,4 +12,5 @@ return [
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
Nelmio\ApiDocBundle\NelmioApiDocBundle::class => ['all' => true],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
];

@ -0,0 +1,15 @@
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
'^/api/':
allow_origin: ['*']
allow_headers: ['Content-Type', 'Authorization']
allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
max_age: 3600

@ -0,0 +1,15 @@
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
'^/api/':
allow_origin: ['*']
allow_headers: ['X-Custom-Auth']
allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
max_age: 3600

@ -226,13 +226,13 @@ class DefaultController extends AbstractController {
$stacks = [];
$choices = [];
foreach ( $poll->getComments() as $c ) {
$comments[ $c->getId() ] = $c->display();
$comments[] = $c->display();
}
foreach ( $poll->getStacksOfVotes() as $c ) {
$stacks[ $c->getId() ] = $c->display();
$stacks[] = $c->display();
}
foreach ( $poll->getChoices() as $c ) {
$choices[ $c->getId() ] = $c->display();
$choices[] = $c->display();
}
$returnedPoll = [
'message' => 'your poll config',

@ -50,15 +50,15 @@ class StackOfVotes {
'votes' => [],
];
foreach ( $this->getVotes() as $vote ) {
$tab[ 'votes' ][ $vote->getId() ] = [
$tab[ 'votes' ][] = [
'id' => $this->getId(),
'vote_id' => $vote->getId(),
'value' => $vote->getValue(),
'choice_id' => $vote->getChoice()->getId(),
'text' => $vote->getChoice()->getName(),
];
$tab[ 'pseudo' ] = $this->getOwner()->getPseudo();
$tab[ 'creation_date' ] = $vote->getCreationDate();
$tab[ 'pseudo' ] = $this->getOwner()->getPseudo();
$tab[ 'creation_date' ] = $vote->getCreationDate();
}
return $tab;

@ -183,6 +183,18 @@
"config/routes/nelmio_api_doc.yaml"
]
},
"nelmio/cors-bundle": {
"version": "1.5",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "1.5",
"ref": "6388de23860284db9acce0a7a5d9d13153bcb571"
},
"files": [
"config/packages/nelmio_cors.yaml"
]
},
"nikic/php-parser": {
"version": "v4.2.4"
},

Loading…
Cancel
Save