Commit 5922fc19 authored by Mat's avatar Mat

Merge branch 'master' into prod

parents 3f77a6d3 9feae2fb
......@@ -22,6 +22,7 @@ class AppKernel extends Kernel
new JMS\SerializerBundle\JMSSerializerBundle(),
new FOS\JsRoutingBundle\FOSJsRoutingBundle(),
new Vich\UploaderBundle\VichUploaderBundle(),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
];
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
......
......@@ -10,6 +10,9 @@ imports:
parameters:
locale: fr
app.path.legume_images: /uploads/images/legumes
# Fixe le nommage des variables de plusieurs mots
# Attention, ça va disfonctionner, il faut repasser dans tous les javascripts !!!!
# jms_serializer.camel_case_naming_strategy.class: JMS\Serializer\Naming\IdenticalPropertyNamingStrategy
framework:
#esi: ~
......@@ -64,6 +67,9 @@ doctrine:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
dql:
string_functions:
field: PotageBundle\Query\Mysql\Field
# Swiftmailer Configuration
swiftmailer:
......@@ -87,7 +93,13 @@ fos_js_routing:
routes_to_expose:
- api_legume_*
- api_offre_*
- potage_offre_legumes_ajax_display
- api_lettre_*
- api_info_*
- api_utilisateur_*
- api_groupe_*
- api_depot_*
- potage_offre_legumes_ajax_display # tester si utile ??
- potage_lettre_infos_ajax_display
# VichUploaderBundle Configuration
vich_uploader:
......@@ -96,3 +108,9 @@ vich_uploader:
legume_images:
uri_prefix: '%app.path.legume_images%'
upload_destination: '%kernel.root_dir%/../web/uploads/images/legumes'
# Stof\DoctrineExtensionsBundle configuration
stof_doctrine_extensions:
orm:
default:
sluggable: true
\ No newline at end of file
......@@ -30,5 +30,6 @@ security:
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
- { path: ^/API/, role: ROLE_ADMIN }
## TODO Comment je sécurise l'APIBundle ?
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "bddd0ec40e25816f1e7988b1f6a2d09c",
"content-hash": "5ef27ac453236c22b49a7d30048e6593",
"packages": [
{
"name": "behat/transliterator",
"version": "v1.2.0",
"source": {
"type": "git",
"url": "https://github.com/Behat/Transliterator.git",
"reference": "826ce7e9c2a6664c0d1f381cbb38b1fb80a7ee2c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Behat/Transliterator/zipball/826ce7e9c2a6664c0d1f381cbb38b1fb80a7ee2c",
"reference": "826ce7e9c2a6664c0d1f381cbb38b1fb80a7ee2c",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"chuyskywalker/rolling-curl": "^3.1",
"php-yaoi/php-yaoi": "^1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2-dev"
}
},
"autoload": {
"psr-0": {
"Behat\\Transliterator": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Artistic-1.0"
],
"description": "String transliterator",
"keywords": [
"i18n",
"slug",
"transliterator"
],
"time": "2017-04-04T11:38:05+00:00"
},
{
"name": "composer/ca-bundle",
"version": "1.1.1",
......@@ -1024,6 +1068,87 @@
],
"time": "2018-03-08T08:59:27+00:00"
},
{
"name": "gedmo/doctrine-extensions",
"version": "v2.4.35",
"source": {
"type": "git",
"url": "https://github.com/Atlantic18/DoctrineExtensions.git",
"reference": "1e400fbd05b7e5f912f55fe95805450f7d3bed60"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Atlantic18/DoctrineExtensions/zipball/1e400fbd05b7e5f912f55fe95805450f7d3bed60",
"reference": "1e400fbd05b7e5f912f55fe95805450f7d3bed60",
"shasum": ""
},
"require": {
"behat/transliterator": "~1.2",
"doctrine/common": "~2.4",
"php": ">=5.3.2"
},
"conflict": {
"doctrine/annotations": "<1.2"
},
"require-dev": {
"doctrine/common": ">=2.5.0",
"doctrine/mongodb-odm": ">=1.0.2",
"doctrine/orm": ">=2.5.0",
"phpunit/phpunit": "^4.8.35|^5.7|^6.5",
"symfony/yaml": "~2.6|~3.0|~4.0"
},
"suggest": {
"doctrine/mongodb-odm": "to use the extensions with the MongoDB ODM",
"doctrine/orm": "to use the extensions with the ORM"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4.x-dev"
}
},
"autoload": {
"psr-4": {
"Gedmo\\": "lib/Gedmo"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "David Buchmann",
"email": "david@liip.ch"
},
{
"name": "Gediminas Morkevicius",
"email": "gediminas.morkevicius@gmail.com"
},
{
"name": "Gustavo Falco",
"email": "comfortablynumb84@gmail.com"
}
],
"description": "Doctrine2 behavioral extensions",
"homepage": "http://gediminasm.org/",
"keywords": [
"Blameable",
"behaviors",
"doctrine2",
"extensions",
"gedmo",
"loggable",
"nestedset",
"sluggable",
"sortable",
"timestampable",
"translatable",
"tree",
"uploadable"
],
"time": "2018-05-08T12:28:40+00:00"
},
{
"name": "hirak/prestissimo",
"version": "0.3.7",
......@@ -2049,6 +2174,71 @@
"description": "A security checker for your composer.lock",
"time": "2018-02-28T22:10:01+00:00"
},
{
"name": "stof/doctrine-extensions-bundle",
"version": "v1.3.0",
"source": {
"type": "git",
"url": "https://github.com/stof/StofDoctrineExtensionsBundle.git",
"reference": "46db71ec7ffee9122eca3cdddd4ef8d84bae269c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/stof/StofDoctrineExtensionsBundle/zipball/46db71ec7ffee9122eca3cdddd4ef8d84bae269c",
"reference": "46db71ec7ffee9122eca3cdddd4ef8d84bae269c",
"shasum": ""
},
"require": {
"gedmo/doctrine-extensions": "^2.3.4",
"php": ">=5.3.2",
"symfony/framework-bundle": "~2.7|~3.2|~4.0"
},
"require-dev": {
"symfony/phpunit-bridge": "^4.0",
"symfony/security-bundle": "^2.7 || ^3.2 || ^4.0"
},
"suggest": {
"doctrine/doctrine-bundle": "to use the ORM extensions",
"doctrine/mongodb-odm-bundle": "to use the MongoDB ODM extensions"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "1.3.x-dev"
}
},
"autoload": {
"psr-4": {
"Stof\\DoctrineExtensionsBundle\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Christophe Coevoet",
"email": "stof@notk.org"
}
],
"description": "Integration of the gedmo/doctrine-extensions with Symfony2",
"homepage": "https://github.com/stof/StofDoctrineExtensionsBundle",
"keywords": [
"behaviors",
"doctrine2",
"extensions",
"gedmo",
"loggable",
"nestedset",
"sluggable",
"sortable",
"timestampable",
"translatable",
"tree"
],
"time": "2017-12-24T16:06:50+00:00"
},
{
"name": "swiftmailer/swiftmailer",
"version": "v5.4.9",
......
<?php
namespace APIBundle\Controller;
use APIBundle\Form\DepotAPIType;
use PotageBundle\Entity\Depot;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class DepotAPIController extends MasterAPIController
{
/**
* @param Request $request
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function createAction(Request $request)
{
$depot = new Depot();
$form = $this->createForm(DepotAPIType::class, $depot);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid())
{
$em = $this->getDoctrine()->getManager();
$em->persist($depot);
$em->flush();
return $this->api($depot);
}
return $this->api($form, Response::HTTP_BAD_REQUEST);
}
/**
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function readAction()
{
$em = $this->getDoctrine()->getManager();
$depots = $em->getRepository('PotageBundle:Depot')->findAllForAPIRead();
return $this->api($depots);
}
/**
* @param $id
* @return \Symfony\Component\HttpFoundation\JsonResponse
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function readOneAction($id)
{
$em = $this->getDoctrine()->getManager();
$depot = $em->getRepository('PotageBundle:Depot')->findOneForAPIReadOne($id);
if ($depot === null)
{
return $this->api('Not found', Response::HTTP_NOT_FOUND);
}
return $this->api($depot);
}
/**
* @param Request $request
* @param $id
* @return \Symfony\Component\HttpFoundation\JsonResponse
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function updateAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$depot = $em->getRepository('PotageBundle:Depot')->findOneForUpdateAPI($id);
if ($depot === null)
{
return $this->api('Not found', Response::HTTP_NOT_FOUND);
}
$form = $this->createForm(DepotAPIType::class, $depot);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid())
{
$em->flush();
return $this->api($depot);
}
return $this->api($form, Response::HTTP_BAD_REQUEST);
}
/**
* @param $id
* @return \Symfony\Component\HttpFoundation\JsonResponse
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function deleteAction($id)
{
$em = $this->getDoctrine()->getManager();
$depot = $em->getRepository('PotageBundle:Depot')->findOneForDeleteAPI($id);
if ($depot !== null)
{
$em->remove($depot);
$em->flush();
}
return $this->api([]);
}
}
<?php
namespace APIBundle\Controller;
use APIBundle\Form\GroupeAPIType;
use PotageBundle\Entity\Groupe;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class GroupeAPIController extends MasterAPIController
{
/**
* @param Request $request
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function createAction(Request $request)
{
$groupe = new Groupe();
$form = $this->createForm(GroupeAPIType::class, $groupe);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid())
{
$em = $this->getDoctrine()->getManager();
$em->persist($groupe);
$em->flush();
return $this->api($groupe);
}
return $this->api($form, Response::HTTP_BAD_REQUEST);
}
/**
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function readAction()
{
$em = $this->getDoctrine()->getManager();
$groupes = $em->getRepository('PotageBundle:Groupe')->findAllForAPIRead();
return $this->api($groupes, 200, array('readGroupes'));
}
/**
* @param $id
* @return \Symfony\Component\HttpFoundation\JsonResponse
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function readOneAction($id)
{
$em = $this->getDoctrine()->getManager();
$groupe = $em->getRepository('PotageBundle:Groupe')->findOneForAPIRead($id);
if ($groupe === null)
{
return $this->api('Not found', Response::HTTP_NOT_FOUND);
}
return $this->api($groupe);
}
/**
* @param Request $request
* @param $id
* @return \Symfony\Component\HttpFoundation\JsonResponse
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function updateAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$groupe = $em->getRepository('PotageBundle:Groupe')->findOneForUpdateAPI($id);
if ($groupe === null)
{
return $this->api('Not found', Response::HTTP_NOT_FOUND);
}
$form = $this->createForm(GroupeAPIType::class, $groupe);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid())
{
$em->flush();
return $this->api($groupe);
}
return $this->api($form, Response::HTTP_BAD_REQUEST);
}
/**
* @param $id
* @return \Symfony\Component\HttpFoundation\JsonResponse
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function deleteAction($id)
{
$em = $this->getDoctrine()->getManager();
$groupe = $em->getRepository('PotageBundle:Groupe')->findOneForDeleteAPI($id);
if ($groupe !== null)
{
$em->remove($groupe);
$em->flush();
}
return $this->api([]);
}
/**
* @param $id
* @return \Symfony\Component\HttpFoundation\JsonResponse
* @throws \Doctrine\ORM\NoResultException
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function getJourPanierAction($id)
{
$em = $this->getDoctrine()->getManager();
$jour = $em->getRepository('PotageBundle:Groupe')->findJourPanier($id);
return $this->api($jour);
}
}
<?php
namespace APIBundle\Controller;
use APIBundle\Form\InfoAPIType;
use APIBundle\Form\InfoInsertAPIType;
use PotageBundle\Entity\Info;
use PotageBundle\Entity\Lettre;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class InfoAPIController extends MasterAPIController
{
/**
* @param Request $request
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function createAction(Request $request)
{
$info = new Info();
$form = $this->createForm(InfoAPIType::class, $info);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid())
{
$em = $this->getDoctrine()->getManager();
$em->persist($info);
$em->flush();
return $this->api($info);
}
return $this->api($form, Response::HTTP_BAD_REQUEST);
}
/**
* @param $type
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function readByTypeAction($type)
{
$isPost = $type === 'actu' ? 1 : 0;
$em = $this->getDoctrine()->getManager();
$infos = $em->getRepository('PotageBundle:Info')->findAllByTypeForAPIRead($isPost);
return $this->api($infos, 200, array('readInfos'));
}
/**
* @param $id
* @return \Symfony\Component\HttpFoundation\JsonResponse
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function readOneAction($id)
{
$em = $this->getDoctrine()->getManager();
$info = $em->getRepository('PotageBundle:Info')->findOneForAPIRead($id);
if ($info === null) {
return $this->api('Not found', Response::HTTP_NOT_FOUND);
}
return $this->api($info);
}
/**
* @param Request $request
* @param $id
* @return \Symfony\Component\HttpFoundation\JsonResponse
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function updateAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$info = $em->getRepository('PotageBundle:Info')->findOneForAPIUpdate($id);
if ($info === null) {
return $this->api('Not found', Response::HTTP_NOT_FOUND);
}
$form = $this->createForm(InfoAPIType::class, $info);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid())
{
$em->flush();
return $this->api($info);
}
return $this->api($form, Response::HTTP_BAD_REQUEST);
}
/**
* @param $id
* @return \Symfony\Component\HttpFoundation\JsonResponse
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function deleteAction($id)
{
$em = $this->getDoctrine()->getManager();
$info = $em->getRepository('PotageBundle:Info')->findOneForAPIDelete($id);
if ($info !== null)
{
$em->remove($info);
$em->flush();
}
return $this->api([]);
}
/**
* @param Request $request
* @param $id
* @return \Symfony\Component\HttpFoundation\JsonResponse
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function insertAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$info = $em->getRepository('PotageBundle:Info')->findOneForAPIInsert($id);
if ($info === null) {
return $this->api('Not found', Response::HTTP_NOT_FOUND);
}
$form = $this->createForm(InfoInsertAPIType::class, $info);
$form->handleRequest($request);
if($form->isSubmitted() && $form->isValid())
{
// TODO ceci est temporaire, avant de comprendre pq il ne passe pas dans la méthode addLettre() de l'entité Info
foreach ($info->getLettres() as $lettre){
/**
* @var $lettre Lettre
*/
$lettre->addInfo($info);
}
$em->flush();
return $this->api($info);
}
return $this->api($form, Response::HTTP_BAD_REQUEST);
}
}
......@@ -39,7 +39,6 @@ class LegumeAPIController extends MasterAPIController
*/
public function readAction(Request