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:
mime_types: ['application/json']
html:
mime_types: ['text/html' ]
mime_types: ['text/html']
graphql:
mime_types: ['application/graphql']
collection:

@ -57,17 +57,15 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
public const HIDDEN = 4;
/**
* @var int
*
* @Groups({"course:read", "course_rel_user:read"})
* @ORM\Column(name="id", type="integer", nullable=false, unique=false)
* @ORM\Id
* @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")
*
@ -75,10 +73,11 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
*
* @ORM\Column(name="title", type="string", length=250, nullable=true, unique=false)
*/
protected $title;
protected string $title;
/**
* @var string
* The course code.
*
* @Assert\NotBlank()
* @ApiProperty(iri="http://schema.org/courseCode")
* @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)
*/
protected $code;
protected string $code;
/**
* @var CourseRelUser[]|ArrayCollection
@ -118,7 +117,10 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
/**
* @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;
@ -221,11 +223,9 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
protected $courseLanguage;
/**
* @var string
*
* @ORM\Column(name="description", type="text", nullable=true, unique=false)
*/
protected $description;
protected string $description;
/**
* @var ArrayCollection
@ -393,7 +393,7 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
$this->creationDate = new \DateTime();
$this->lastVisit = new \DateTime();
$this->lastEdit = new \DateTime();
$this->description = '';
$this->users = new ArrayCollection();
$this->urls = new ArrayCollection();
$this->tools = new ArrayCollection();

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

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

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

Loading…
Cancel
Save