Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 8 no information from the user in serialization #37

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ fos_rest:
rules:
- { path: '^/api/', priorities: ['json'], fallback_format: json, prefer_extension: false }
- { path: '^/', priorities: ['json', 'html'], fallback_format: 'html' }
serializer:
param_fetcher_listener: true
view:
view_response_listener: 'force'
Expand All @@ -102,7 +101,7 @@ fos_user:
firewall_name: main
from_email:
address: [email protected]
sender_name: Demo App
sender_name: ADFC Radschulwegplan Hamburg
user_class: AppBundle\Entity\User
service:
mailer: fos_user.mailer.twig_swift
Expand All @@ -116,3 +115,9 @@ nelmio_api_doc:
title: 'ADFC-Radschulwegplan-Backend'
description: 'ADFC Hamburg Radschulwegplan Backend'
version: 0.0.2
jms_serializer:
metadata:
directories:
FOSUB:
namespace_prefix: "FOS\\UserBundle"
path: "%kernel.root_dir%/serializer/FOSUB"
7 changes: 3 additions & 4 deletions app/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ services:
tags:
- { name: doctrine.event_subscriber }

# add more services, or override services that need manual wiring
# AppBundle\Service\ExampleService:
# arguments:
# $someArgument: 'some_value'
AppBundle\EventListener\ADFCResponseListener:
tags:
- { name: kernel.event_subscriber }
21 changes: 21 additions & 0 deletions app/serializer/FOSUB/Model.User.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FOS\UserBundle\Model\User:
exclusion_policy: all
properties:
id:
expose: true
groups: ["any"]
email:
expose: true
groups: ["role-admin"]
enabled:
expose: true
groups: ["role-admin"]
username:
expose: true
groups: ["role-admin"]
lastLogin:
expose: true
groups: ["role-admin"]
roles:
expose: true
groups: ["role-admin"]
3 changes: 3 additions & 0 deletions src/AppBundle/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
* UserControler.
*/
class UserController extends FOSRestController
{
/**
Expand Down
9 changes: 9 additions & 0 deletions src/AppBundle/Entity/BaseEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as JMS;

/**
* BaseEntity.
Expand All @@ -32,13 +33,17 @@ abstract class BaseEntity
* @var \DateTime
*
* @ORM\Column(name="created", type="datetime")
*
* @JMS\Groups({"role-admin", "role-school-admin"})
*/
protected $created;

/**
* @var \DateTime
*
* @ORM\Column(name="changed", type="datetime")
*
* @JMS\Groups({"role-admin", "role-school-admin"})
*/
protected $changed;

Expand All @@ -47,6 +52,8 @@ abstract class BaseEntity
*
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(name="created_by", referencedColumnName="id")
*
* @JMS\Groups({"role-admin", "role-school-admin"})
*/
protected $createdBy;

Expand All @@ -55,6 +62,8 @@ abstract class BaseEntity
*
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(name="changed_by", referencedColumnName="id")
*
* @JMS\Groups({"role-admin", "role-school-admin"})
*/
protected $changedBy;

Expand Down
21 changes: 20 additions & 1 deletion src/AppBundle/Entity/DangerPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@
namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as JMS;
use Jsor\Doctrine\PostGIS\Functions\Geometry;

/**
* DangerPoint.
*
* @ORM\Table(name="danger_point")
* @ORM\Entity(repositoryClass="AppBundle\Repository\DangerPointRepository")
*
* @JMS\ExclusionPolicy("all")
*/
class DangerPoint extends BaseEntity
{
Expand All @@ -37,34 +41,49 @@ class DangerPoint extends BaseEntity
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*
* @JMS\Expose(true)
* @JMS\Groups({"role-admin", "path-danger_point-any"})
*/
private $id;

/**
* @var geometry
* @var Geometry
*
* @ORM\Column(name="pos", type="geometry",options={"geometry_type"="POINT", "srid"=4326})
*
* @JMS\Expose(true)
* @JMS\Groups({"role-admin", "path-danger_point-any"})
*/
private $pos;

/**
* @var string
*
* @ORM\Column(name="title", type="string", length=128)
*
* @JMS\Expose(true)
* @JMS\Groups({"role-admin", "path-danger_point-any"})
*/
private $title;

/**
* @var string
*
* @ORM\Column(name="description", type="text", nullable=true)
*
* @JMS\Expose(true)
* @JMS\Groups({"role-admin", "path-danger_point-any"})
*/
private $description;

/**
* @var int
*
* @ORM\Column(name="typeId", type="integer")
*
* @JMS\Expose(true)
* @JMS\Groups({"role-admin", "path-danger_point-any"})
*/
private $typeId;

Expand Down
21 changes: 21 additions & 0 deletions src/AppBundle/Entity/School.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@
namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as JMS;
use Swagger\Annotations as SWG;

/**
* School.
*
* @ORM\Table(name="school")
* @ORM\Entity(repositoryClass="AppBundle\Repository\SchoolRepository")
*
* @JMS\ExclusionPolicy("all")
*/
class School extends BaseEntity
{
Expand All @@ -39,6 +42,9 @@ class School extends BaseEntity
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @SWG\Property(format="int64")
*
* @JMS\Expose(true)
* @JMS\Groups({"any"})
*/
private $id;

Expand All @@ -47,6 +53,9 @@ class School extends BaseEntity
*
* @ORM\Column(name="name", type="string", length=255)
* @SWG\Property(format="string")
*
* @JMS\Expose(true)
* @JMS\Groups({"any"})
*/
private $name;

Expand All @@ -55,6 +64,9 @@ class School extends BaseEntity
*
* @ORM\Column(name="street", type="string", length=255)
* @SWG\Property(format="string")
*
* @JMS\Expose(true)
* @JMS\Groups({"role-admin"})
*/
private $street;

Expand All @@ -63,6 +75,9 @@ class School extends BaseEntity
*
* @ORM\Column(name="postalcode", type="string", length=5)
* @SWG\Property(format="string")
*
* @JMS\Expose(true)
* @JMS\Groups({"any"})
*/
private $postalcode;

Expand All @@ -71,6 +86,9 @@ class School extends BaseEntity
*
* @ORM\Column(name="place", type="string", length=64)
* @SWG\Property(format="string")
*
* @JMS\Expose(true)
* @JMS\Groups({"any"})
*/
private $place;

Expand All @@ -79,6 +97,9 @@ class School extends BaseEntity
*
* @ORM\Column(name="webpage", type="string", length=255, nullable=true)
* @SWG\Property(format="string")
*
* @JMS\Expose(true)
* @JMS\Groups({"any"})
*/
private $webpage;

Expand Down
15 changes: 15 additions & 0 deletions src/AppBundle/Entity/SchoolClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@
namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as JMS;
use Swagger\Annotations as SWG;

/**
* SchoolClass.
*
* @ORM\Table(name="school_class",uniqueConstraints={@ORM\UniqueConstraint(name="school_class_idx", columns={"name", "school"})})
* @ORM\Entity(repositoryClass="AppBundle\Repository\SchoolClassRepository")
*
* @JMS\ExclusionPolicy("all")

* @SWG\Definition(definition="SchoolClass")
*/
class SchoolClass extends BaseEntity
Expand All @@ -39,6 +43,10 @@ class SchoolClass extends BaseEntity
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*
* @JMS\Expose(true)
* @JMS\Groups({"any"})
*
* @SWG\Property(description="The unique identifier of the class.")
*/
private $id;
Expand All @@ -47,6 +55,10 @@ class SchoolClass extends BaseEntity
* @var string the name of the class
*
* @ORM\Column(name="name", type="string", length=16)
*
* @JMS\Expose(true)
* @JMS\Groups({"role-admin", "role-school-admin", "role-student", "role-school-reviewer"})
*
* @SWG\Property(type="string", maxLength=16)
*/
private $name;
Expand All @@ -56,6 +68,9 @@ class SchoolClass extends BaseEntity
*
* @ORM\ManyToOne(targetEntity="School")
* @ORM\JoinColumn(name="school", referencedColumnName="id", nullable=false)
*
* @JMS\Expose(true)
* @JMS\Groups({"any"})
*/
private $school;

Expand Down
18 changes: 17 additions & 1 deletion src/AppBundle/Entity/SchoolWay.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@
namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as JMS;
use Jsor\Doctrine\PostGIS\Functions\Geometry;

/**
* SchoolWay.
*
* @ORM\Table(name="school_way")
* @ORM\Entity(repositoryClass="AppBundle\Repository\SchoolWayRepository")
*
* @JMS\ExclusionPolicy("all")
*/
class SchoolWay extends BaseEntity
{
Expand All @@ -37,27 +41,39 @@ class SchoolWay extends BaseEntity
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*
* @JMS\Expose(true)
* @JMS\Groups({"any"})
*/
private $id;

/**
* @var geometry
* @var Geometry
*
* @ORM\Column(name="way", type="geometry",options={"geometry_type"="LINESTRING", "srid"=4326})
*
* @JMS\Expose(true)
* @JMS\Groups({"path-school-way"})
*/
private $way;

/**
* @var int
*
* @ORM\Column(name="wayType", type="integer")
*
* @JMS\Expose(true)
* @JMS\Groups({"path-school-way"})
*/
private $wayType;

/**
* @var int
*
* @ORM\Column(name="year", type="integer")
*
* @JMS\Expose(true)
* @JMS\Groups({"path-school-way"})
*/
private $year;

Expand Down
Loading