Update entities - api platform

pull/3768/head
Julio Montoya 4 years ago
parent cc1f74fb28
commit 9be1d8b3df
  1. 2
      config/packages/api_platform.yaml
  2. 24
      src/CoreBundle/Entity/Course.php
  3. 31
      src/CoreBundle/Entity/Session.php
  4. 8
      src/CoreBundle/Entity/User.php
  5. 4
      src/CoreBundle/Resources/config/repositories.yml

@ -13,7 +13,7 @@ api_platform:
json: json:
mime_types: ['application/json'] mime_types: ['application/json']
html: html:
mime_types: ['text/html' ] mime_types: ['text/html']
graphql: graphql:
mime_types: ['application/graphql'] mime_types: ['application/graphql']
collection: collection:

@ -57,17 +57,15 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
public const HIDDEN = 4; public const HIDDEN = 4;
/** /**
* @var int
*
* @Groups({"course:read", "course_rel_user:read"}) * @Groups({"course:read", "course_rel_user:read"})
* @ORM\Column(name="id", type="integer", nullable=false, unique=false) * @ORM\Column(name="id", type="integer", nullable=false, unique=false)
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO") * @ORM\GeneratedValue(strategy="AUTO")
*/ */
protected $id; protected int $id;
/** /**
* @var string The course title * The course title.
* *
* @Assert\NotBlank(message="A Course requires a title") * @Assert\NotBlank(message="A Course requires a title")
* *
@ -75,10 +73,11 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
* *
* @ORM\Column(name="title", type="string", length=250, nullable=true, unique=false) * @ORM\Column(name="title", type="string", length=250, nullable=true, unique=false)
*/ */
protected $title; protected string $title;
/** /**
* @var string * The course code.
*
* @Assert\NotBlank() * @Assert\NotBlank()
* @ApiProperty(iri="http://schema.org/courseCode") * @ApiProperty(iri="http://schema.org/courseCode")
* @Groups({"course:read", "course:write", "course_rel_user:read"}) * @Groups({"course:read", "course:write", "course_rel_user:read"})
@ -91,7 +90,7 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
* ) * )
* @ORM\Column(name="code", type="string", length=40, nullable=false, unique=true) * @ORM\Column(name="code", type="string", length=40, nullable=false, unique=true)
*/ */
protected $code; protected string $code;
/** /**
* @var CourseRelUser[]|ArrayCollection * @var CourseRelUser[]|ArrayCollection
@ -118,7 +117,10 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
/** /**
* @var ArrayCollection|AccessUrlRelCourse[] * @var ArrayCollection|AccessUrlRelCourse[]
* *
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\AccessUrlRelCourse", mappedBy="course", cascade={"persist", "remove"}, orphanRemoval=true) * @ORM\OneToMany(
* targetEntity="Chamilo\CoreBundle\Entity\AccessUrlRelCourse",
* mappedBy="course", cascade={"persist", "remove"}, orphanRemoval=true
* )
*/ */
protected $urls; protected $urls;
@ -221,11 +223,9 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
protected $courseLanguage; protected $courseLanguage;
/** /**
* @var string
*
* @ORM\Column(name="description", type="text", nullable=true, unique=false) * @ORM\Column(name="description", type="text", nullable=true, unique=false)
*/ */
protected $description; protected string $description;
/** /**
* @var ArrayCollection * @var ArrayCollection
@ -393,7 +393,7 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
$this->creationDate = new \DateTime(); $this->creationDate = new \DateTime();
$this->lastVisit = new \DateTime(); $this->lastVisit = new \DateTime();
$this->lastEdit = new \DateTime(); $this->lastEdit = new \DateTime();
$this->description = '';
$this->users = new ArrayCollection(); $this->users = new ArrayCollection();
$this->urls = new ArrayCollection(); $this->urls = new ArrayCollection();
$this->tools = new ArrayCollection(); $this->tools = new ArrayCollection();

@ -22,6 +22,18 @@ use Symfony\Component\Validator\Constraints as Assert;
* attributes={"security"="is_granted('ROLE_ADMIN')"}, * attributes={"security"="is_granted('ROLE_ADMIN')"},
* normalizationContext={"groups"={"session:read"}, "swagger_definition_name"="Read"}, * normalizationContext={"groups"={"session:read"}, "swagger_definition_name"="Read"},
* denormalizationContext={"groups"={"session:write"}}, * denormalizationContext={"groups"={"session:write"}},
* collectionOperations={
* "get" = {
* "denormalization_context"={
* "groups"={"session:read"},
* },
* },
* "post"={}
* },
* itemOperations={
* "get"={},
* "put"={},
* }
* ) * )
* *
* @ApiFilter(SearchFilter::class, properties={"name": "partial"}) * @ApiFilter(SearchFilter::class, properties={"name": "partial"})
@ -57,7 +69,7 @@ class Session
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue() * @ORM\GeneratedValue()
*/ */
protected $id; protected int $id;
/** /**
* @var ArrayCollection|SkillRelCourse[] * @var ArrayCollection|SkillRelCourse[]
@ -128,20 +140,18 @@ class Session
protected $currentUrl; protected $currentUrl;
/** /**
* @var string
* @Assert\NotBlank() * @Assert\NotBlank()
* @Groups({"session:read", "session:write", "session_rel_course_rel_user:read"}) * @Groups({"session:read", "session:write", "session_rel_course_rel_user:read"})
* @ORM\Column(name="name", type="string", length=150, nullable=false, unique=false) * @ORM\Column(name="name", type="string", length=150, nullable=false, unique=false)
*/ */
protected $name; protected string $name;
/** /**
* @var string
* @Groups({"session:read", "session:write"}) * @Groups({"session:read", "session:write"})
* *
* @ORM\Column(name="description", type="text", nullable=true, unique=false) * @ORM\Column(name="description", type="text", nullable=true, unique=false)
*/ */
protected $description; protected string $description;
/** /**
* @var bool * @var bool
@ -302,6 +312,7 @@ class Session
$this->items = new ArrayCollection(); $this->items = new ArrayCollection();
$this->urls = new ArrayCollection(); $this->urls = new ArrayCollection();
$this->description = '';
$this->nbrClasses = 0; $this->nbrClasses = 0;
$this->nbrUsers = 0; $this->nbrUsers = 0;
$this->sendSubscriptionNotification = false; $this->sendSubscriptionNotification = false;
@ -630,12 +641,8 @@ class Session
/** /**
* Set description. * Set description.
*
* @param string $description
*
* @return $this
*/ */
public function setDescription($description) public function setDescription(string $description): self
{ {
$this->description = $description; $this->description = $description;
@ -644,10 +651,8 @@ class Session
/** /**
* Get description. * Get description.
*
* @return string
*/ */
public function getDescription() public function getDescription(): string
{ {
return $this->description; return $this->description;
} }

@ -32,11 +32,13 @@ use Symfony\Component\Validator\Mapping\ClassMetadata;
* iri="http://schema.org/Person", * iri="http://schema.org/Person",
* normalizationContext={"groups"={"user:read"}}, * normalizationContext={"groups"={"user:read"}},
* denormalizationContext={"groups"={"user:write"}}, * denormalizationContext={"groups"={"user:write"}},
* collectionOperations={"get"}, * collectionOperations={
* "get"={},
* "post"={}
* },
* itemOperations={ * itemOperations={
* "get"={}, * "get"={},
* "put"={}, * "put"={},
* "delete"={},
* } * }
* ) * )
* *
@ -266,7 +268,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
/** /**
* @var CourseRelUser[]|ArrayCollection * @var CourseRelUser[]|ArrayCollection
* *
* @ApiSubresource() * @ApiSubresource
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\CourseRelUser", mappedBy="user", orphanRemoval=true) * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\CourseRelUser", mappedBy="user", orphanRemoval=true)
*/ */
protected $courses; protected $courses;

@ -28,8 +28,8 @@ services:
Chamilo\CoreBundle\Repository\Node\UserRepository: Chamilo\CoreBundle\Repository\Node\UserRepository:
calls: calls:
- setEncoder: ['@security.user_password_encoder.generic'] - setEncoder: ['@security.user_password_encoder.generic']
- setAuthorizationChecker: [ '@security.authorization_checker'] - setAuthorizationChecker: ['@security.authorization_checker']
- setRouter: ['@router'] - setRouter: ['@router']
- setSlugify: ['@cocur_slugify'] - setSlugify: ['@cocur_slugify']
- setToolChain: ['@Chamilo\CoreBundle\ToolChain'] - setToolChain: ['@Chamilo\CoreBundle\ToolChain']
- setResourceNodeRepository: [ '@Chamilo\CoreBundle\Repository\ResourceNodeRepository'] - setResourceNodeRepository: ['@Chamilo\CoreBundle\Repository\ResourceNodeRepository']

Loading…
Cancel
Save