Internal: Portfolio: Add types to entity properties - refs BT#22232

pull/6001/head
Angel Fernando Quiroz Campos 9 months ago
parent c60a4e23f5
commit 34975cd966
No known key found for this signature in database
GPG Key ID: B284841AE3E562CD
  1. 196
      src/Chamilo/CoreBundle/Entity/Portfolio.php
  2. 31
      src/Chamilo/CoreBundle/Entity/PortfolioAttachment.php
  3. 140
      src/Chamilo/CoreBundle/Entity/PortfolioCategory.php
  4. 87
      src/Chamilo/CoreBundle/Entity/PortfolioComment.php
  5. 16
      src/Chamilo/CoreBundle/Entity/PortfolioRelTag.php

@ -4,6 +4,7 @@
namespace Chamilo\CoreBundle\Entity;
use Chamilo\UserBundle\Entity\User;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
@ -37,120 +38,90 @@ class Portfolio
public const VISIBILITY_PER_USER = 3;
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
protected $id;
protected ?int $id;
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=255)
*/
protected $title;
protected string $title;
/**
* @var string
* @ORM\Column(name="content", type="text")
*/
protected $content;
protected string $content;
/**
* @var User
*
* @ORM\ManyToOne(targetEntity="Chamilo\UserBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
*/
protected $user;
protected User $user;
/**
* @var Course
*
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course")
* @ORM\JoinColumn(name="c_id", referencedColumnName="id", onDelete="CASCADE")
*/
protected $course = null;
protected ?Course $course = null;
/**
* @var Session
*
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Session")
* @ORM\JoinColumn(name="session_id", referencedColumnName="id", onDelete="CASCADE")
*/
protected $session = null;
protected ?Session $session = null;
/**
* @var \DateTime
*
* @ORM\Column(name="creation_date", type="datetime")
*/
protected $creationDate;
protected DateTime $creationDate;
/**
* @var \DateTime
*
* @ORM\Column(name="update_date", type="datetime")
*/
protected $updateDate;
protected DateTime $updateDate;
/**
* @var int
*
* @ORM\Column(name="visibility", type="smallint", options={"default": 1})
*/
protected $visibility = 1;
protected int $visibility = self::VISIBILITY_VISIBLE;
/**
* @var \Chamilo\CoreBundle\Entity\PortfolioCategory
*
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\PortfolioCategory", inversedBy="items")
* @ORM\JoinColumn(name="category_id", referencedColumnName="id", onDelete="SET NULL")
*/
protected $category;
protected ?PortfolioCategory $category;
/**
* @var \Doctrine\Common\Collections\ArrayCollection
*
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\PortfolioComment", mappedBy="item")
*/
private $comments;
private Collection $comments;
/**
* @var int|null
*
* @ORM\Column(name="origin", type="integer", nullable=true)
*/
private $origin;
private ?int $origin = null;
/**
* @var int|null
*
* @ORM\Column(name="origin_type", type="integer", nullable=true)
*/
private $originType;
private ?int $originType = null;
/**
* @var float|null
*
* @ORM\Column(name="score", type="float", nullable=true)
*/
private $score;
private ?float $score = null;
/**
* @var bool
*
* @ORM\Column(name="is_highlighted", type="boolean", options={"default": false})
*/
private $isHighlighted = false;
private bool $isHighlighted = false;
/**
* @var bool
*
* @ORM\Column(name="is_template", type="boolean", options={"default": false})
*/
private $isTemplate = false;
private bool $isTemplate = false;
/**
* Portfolio constructor.
@ -161,89 +132,49 @@ class Portfolio
$this->comments = new ArrayCollection();
}
/**
* Set user.
*
* @return Portfolio
*/
public function setUser(User $user)
public function setUser(User $user): Portfolio
{
$this->user = $user;
return $this;
}
/**
* Get user.
*
* @return User
*/
public function getUser()
public function getUser(): User
{
return $this->user;
}
/**
* Set course.
*
* @return Portfolio
*/
public function setCourse(Course $course = null)
public function setCourse(?Course $course = null): Portfolio
{
$this->course = $course;
return $this;
}
/**
* Get course.
*
* @return Course
*/
public function getCourse()
public function getCourse(): ?Course
{
return $this->course;
}
/**
* Get session.
*
* @return Session
*/
public function getSession()
public function getSession(): ?Session
{
return $this->session;
}
/**
* Set session.
*
* @return Portfolio
*/
public function setSession(Session $session = null)
public function setSession(?Session $session = null): Portfolio
{
$this->session = $session;
return $this;
}
/**
* Set title.
*
* @param string $title
*
* @return Portfolio
*/
public function setTitle($title)
public function setTitle(string $title): Portfolio
{
$this->title = $title;
return $this;
}
/**
* Get title.
*/
public function getTitle(bool $stripTags = false): string
{
if ($stripTags) {
@ -253,87 +184,47 @@ class Portfolio
return $this->title;
}
/**
* Set content.
*
* @param string $content
*
* @return Portfolio
*/
public function setContent($content)
public function setContent(string $content): Portfolio
{
$this->content = $content;
return $this;
}
/**
* Get content.
*
* @return string
*/
public function getContent()
public function getContent(): string
{
return $this->content;
}
/**
* Set creationDate.
*
* @return Portfolio
*/
public function setCreationDate(\DateTime $creationDate)
public function setCreationDate(DateTime $creationDate): Portfolio
{
$this->creationDate = $creationDate;
return $this;
}
/**
* Get creationDate.
*
* @return \DateTime
*/
public function getCreationDate()
public function getCreationDate(): DateTime
{
return $this->creationDate;
}
/**
* Set updateDate.
*
* @return Portfolio
*/
public function setUpdateDate(\DateTime $updateDate)
public function setUpdateDate(DateTime $updateDate): Portfolio
{
$this->updateDate = $updateDate;
return $this;
}
/**
* Get updateDate.
*
* @return \DateTime
*/
public function getUpdateDate()
public function getUpdateDate(): DateTime
{
return $this->updateDate;
}
/**
* Get id.
*
* @return int
*/
public function getId()
public function getId(): ?int
{
return $this->id;
}
/**
* Set isVisible.
*/
public function setVisibility(int $visibility): Portfolio
{
$this->visibility = $visibility;
@ -341,30 +232,17 @@ class Portfolio
return $this;
}
/**
* Get isVisible.
*/
public function getVisibility(): int
{
return $this->visibility;
}
/**
* Get category.
*
* @return PortfolioCategory
*/
public function getCategory()
public function getCategory(): ?PortfolioCategory
{
return $this->category;
}
/**
* Set category.
*
* @return Portfolio
*/
public function setCategory(PortfolioCategory $category = null)
public function setCategory(?PortfolioCategory $category = null): Portfolio
{
$this->category = $category;
@ -397,9 +275,6 @@ class Portfolio
return $this->origin;
}
/**
* @return \Chamilo\CoreBundle\Entity\Portfolio
*/
public function setOrigin(?int $origin): Portfolio
{
$this->origin = $origin;
@ -412,9 +287,6 @@ class Portfolio
return $this->originType;
}
/**
* @return \Chamilo\CoreBundle\Entity\Portfolio
*/
public function setOriginType(?int $originType): Portfolio
{
$this->originType = $originType;

@ -21,52 +21,41 @@ class PortfolioAttachment
public const TYPE_COMMENT = 2;
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
protected $id;
protected ?int $id;
/**
* @var string
*
* @ORM\Column(name="path", type="string", length=255)
*/
protected $path;
protected string $path;
/**
* @var string|null
*
* @ORM\Column(name="comment", type="text", nullable=true)
*/
protected $comment;
protected ?string $comment;
/**
* @var int
*
* @ORM\Column(name="size", type="integer")
*/
protected $size;
protected int $size;
/**
* @var string
*
* @ORM\Column(name="filename", type="string", length=255)
*/
protected $filename;
protected string $filename;
/**
* @var int
*
* @ORM\Column(name="origin_id", type="integer")
*/
private $origin;
private int $origin;
/**
* @var int
*
* @ORM\Column(name="origin_type", type="integer")
*/
private $originType;
private int $originType;
public function getId(): int
{

@ -5,6 +5,7 @@ namespace Chamilo\CoreBundle\Entity;
use Chamilo\UserBundle\Entity\User;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping as ORM;
@ -25,56 +26,42 @@ use Doctrine\ORM\Mapping as ORM;
class PortfolioCategory
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
protected $id;
protected ?int $id;
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=255)
*/
protected $title;
protected string $title;
/**
* @var null
*
* @ORM\Column(name="description", type="text", nullable=true)
*/
protected $description = null;
protected ?string $description = null;
/**
* @var User
*
* @ORM\ManyToOne(targetEntity="Chamilo\UserBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
*/
protected $user;
protected User $user;
/**
* @var bool
*
* @ORM\Column(name="is_visible", type="boolean", options={"default": true})
*/
protected $isVisible = true;
protected bool $isVisible = true;
/**
* @var int
*
* @ORM\Column(name="parent_id", type="integer", nullable=false, options={"default": 0})
*/
protected $parentId = 0;
protected int $parentId = 0;
/**
* @var \Doctrine\Common\Collections\ArrayCollection
*
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\Portfolio", mappedBy="category")
*/
protected $items;
protected Collection $items;
/**
* PortfolioCategory constructor.
@ -84,160 +71,84 @@ class PortfolioCategory
$this->items = new ArrayCollection();
}
/**
* @return string
*/
public function __toString()
public function __toString(): string
{
return $this->title;
}
/**
* Get id.
*
* @return int
*/
public function getId()
public function getId(): ?int
{
return $this->id;
}
/**
* @param int $id
*
* @return PortfolioCategory
*/
public function setId($id)
public function setId(?int $id): PortfolioCategory
{
$this->id = $id;
return $this;
}
/**
* Get title.
*
* @return string
*/
public function getTitle()
public function getTitle(): string
{
return $this->title;
}
/**
* Set title.
*
* @param string $title
*
* @return PortfolioCategory
*/
public function setTitle($title)
public function setTitle(string $title): PortfolioCategory
{
$this->title = $title;
return $this;
}
/**
* Get description.
*
* @return string|null
*/
public function getDescription()
public function getDescription(): ?string
{
return $this->description;
}
/**
* Set description.
*
* @param string|null $description
*
* @return PortfolioCategory
*/
public function setDescription($description)
public function setDescription(?string $description): PortfolioCategory
{
$this->description = $description;
return $this;
}
/**
* Get user.
*
* @return User
*/
public function getUser()
public function getUser(): User
{
return $this->user;
}
/**
* Set user.
*
* @return PortfolioCategory
*/
public function setUser(User $user)
public function setUser(User $user): PortfolioCategory
{
$this->user = $user;
return $this;
}
/**
* Get isVisible.
*
* @return bool
*/
public function isVisible()
public function isVisible(): bool
{
return $this->isVisible;
}
/**
* Set isVisible.
*
* @param bool $isVisible
*
* @return PortfolioCategory
*/
public function setIsVisible($isVisible)
public function setIsVisible(bool $isVisible): PortfolioCategory
{
$this->isVisible = $isVisible;
return $this;
}
/**
* @return int
*/
public function getParentId()
public function getParentId(): int
{
return $this->parentId;
}
/**
* Set parent id.
*
* @return PortfolioCategory
*/
public function setParentId(int $parentId)
public function setParentId(int $parentId): PortfolioCategory
{
$this->parentId = $parentId;
return $this;
}
/**
* Get items.
*
* @param \Chamilo\CoreBundle\Entity\Course|null $course
* @param \Chamilo\CoreBundle\Entity\Session|null $session
* @param bool $onlyVisibles
*
* @return ArrayCollection
*/
public function getItems(Course $course = null, Session $session = null, $onlyVisibles = false)
public function getItems(Course $course = null, Session $session = null, bool $onlyVisibles = false): Collection
{
$criteria = Criteria::create();
@ -262,12 +173,7 @@ class PortfolioCategory
return $this->items->matching($criteria);
}
/**
* Set items.
*
* @return PortfolioCategory
*/
public function setItems(ArrayCollection $items)
public function setItems(Collection $items): PortfolioCategory
{
$this->items = $items;

@ -7,6 +7,7 @@ namespace Chamilo\CoreBundle\Entity;
use Chamilo\UserBundle\Entity\User;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
@ -26,111 +27,92 @@ class PortfolioComment
public const VISIBILITY_PER_USER = 2;
/**
* @var int
*
* Add @ to the next line if portfolio_advanced_sharing config setting is true
* ORM\Column(name="visibility", type="smallint", options={"default": 1})
*/
protected $visibility = 1;
protected int $visibility = 1;
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
private $id;
private ?int $id;
/**
* @var \Chamilo\UserBundle\Entity\User
*
* @ORM\ManyToOne(targetEntity="Chamilo\UserBundle\Entity\User")
* @ORM\JoinColumn(name="author_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
*/
private $author;
private User $author;
/**
* @var \Chamilo\CoreBundle\Entity\Portfolio
*
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Portfolio", inversedBy="comments")
* @ORM\JoinColumn(name="item_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
*/
private $item;
private Portfolio $item;
/**
* @var string
*
* @ORM\Column(name="content", type="text")
*/
private $content;
private string $content;
/**
* @var \DateTime
*
* @ORM\Column(name="date", type="datetime")
*/
private $date;
private DateTime $date;
/**
* @var bool
*
* @ORM\Column(name="is_important", type="boolean", options={"default":false})
*/
private $isImportant;
private bool $isImportant;
/**
* @var int
*
* @Gedmo\TreeLeft()
* @ORM\Column(name="lft", type="integer")
*/
private $lft;
private int $lft;
/**
* @var int
*
* @Gedmo\TreeLevel()
* @ORM\Column(name="lvl", type="integer")
*/
private $lvl;
private int $lvl;
/**
* @var int
*
* @Gedmo\TreeRight()
* @ORM\Column(name="rgt", type="integer")
*/
private $rgt;
private int $rgt;
/**
* @var \Chamilo\CoreBundle\Entity\PortfolioComment
*
* @Gedmo\TreeRoot()
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\PortfolioComment")
* @ORM\JoinColumn(name="tree_root", referencedColumnName="id", onDelete="CASCADE")
*/
private $root;
private ?PortfolioComment $root = null;
/**
* @var \Chamilo\CoreBundle\Entity\PortfolioComment|null
*
* @Gedmo\TreeParent()
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\PortfolioComment", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE")
*/
private $parent;
private ?PortfolioComment $parent;
/**
* @var \Doctrine\Common\Collections\ArrayCollection
*
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\PortfolioComment", mappedBy="parent")
* @ORM\OrderBy({"lft"="DESC"})
*/
private $children;
private Collection $children;
/**
* @var float|null
*
* @ORM\Column(name="score", type="float", nullable=true)
*/
private $score;
private ?float $score;
/**
* @var bool
*
* @ORM\Column(name="is_template", type="boolean", options={"default": false})
*/
private $isTemplate = false;
private bool $isTemplate = false;
/**
* PortfolioComment constructor.
@ -159,17 +141,11 @@ class PortfolioComment
return $this;
}
/**
* @return \Chamilo\CoreBundle\Entity\Portfolio
*/
public function getItem(): Portfolio
{
return $this->item;
}
/**
* @param \Chamilo\CoreBundle\Entity\Portfolio $item
*/
public function setItem(Portfolio $item): PortfolioComment
{
$this->item = $item;
@ -201,17 +177,11 @@ class PortfolioComment
return $this;
}
/**
* @return \Chamilo\CoreBundle\Entity\PortfolioComment|null
*/
public function getParent(): ?PortfolioComment
{
return $this->parent;
}
/**
* @param \Chamilo\CoreBundle\Entity\PortfolioComment|null $parent
*/
public function setParent(?PortfolioComment $parent): PortfolioComment
{
$this->parent = $parent;
@ -256,9 +226,6 @@ class PortfolioComment
$this->score = $score;
}
/**
* @return \Chamilo\CoreBundle\Entity\PortfolioComment
*/
public function getRoot(): PortfolioComment
{
return $this->root;

@ -13,37 +13,29 @@ use Doctrine\ORM\Mapping as ORM;
class PortfolioRelTag
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
protected $id;
protected ?int $id;
/**
* @var Tag
*
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Tag")
* @ORM\JoinColumn(name="tag_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
*/
protected $tag;
protected Tag $tag;
/**
* @var Course
*
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course")
* @ORM\JoinColumn(name="c_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
*/
protected $course;
protected Course $course;
/**
* @var Session|null
*
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Session")
* @ORM\JoinColumn(name="session_id", referencedColumnName="id", onDelete="CASCADE")
*/
protected $session;
protected ?Session $session;
public function getId(): int
{

Loading…
Cancel
Save