<?php
namespace App\Entity\Educational;
use App\Entity\Users\Child;
use App\Entity\Users\Child as Student;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Serializer\Annotation\Groups;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Define a group of Domain allowed for a user
* aba\DomainBundle\Entity\Course
*
* @ORM\Table(name="Course")
* @ORM\Entity(repositoryClass="App\Repository\Educational\CourseRepository")
*/
class Course
{
const ID_TERMINALE = 1;
const ID_SECONDE = 2;
const ID_TROISIEME = 3;
const ID_PREMIERE = 4;
const ID_QUATRIEME = 5;
const ID_CINQUIEME = 6;
const ID_SIXIEME = 7;
const SLUG_TERMINALE = 'terminale';
const SLUG_PREMIERE = 'premiere';
const SLUG_SECONDE = 'seconde';
const SLUG_TROISIEME = 'troisieme';
const SLUG_QUATRIEME = 'quatrieme';
const SLUG_CINQUIEME = 'cinquieme';
const SLUG_SIXIEME = 'sixieme';
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @Groups({"api"})
*/
private $id;
/**
* @var string $title
*
* @ORM\Column(name="title", type="string", length=255)
* @Gedmo\Slug(fields={"slug"})
* @Assert\NotBlank()
* @Groups({"api"})
*/
private $title;
/**
* @var string $slug
*
* @ORM\Column(name="slug", type="string", length=255, unique=true)
* @Groups({"api"})
*
*/
private $slug;
/**
* @var
* @ORM\Column(name="front", type="boolean")
*/
private $front;
/**
* @var integer
* @ORM\Column(name="order",type="integer")
*/
private $order;
/**
* @var string
*
* @ORM\Column(name="description", type="text", nullable=true)
*/
private $description;
/**
* @var string
*
* @ORM\Column(name="metadescription", type="text", nullable=true)
*/
private $metadescription;
/********************** Association **************/
/*
* @ORM\ManyToOne(targetEntity="Serie",inversedBy="discipline")
* @ORM\JoinColumn(name="serie_id",referencedColumnName="id")
*
*
public $serie;
*/
/**
* @ORM\OneToMany(targetEntity="Domain", mappedBy="course")
* @ORM\OrderBy({"position" = "ASC"})
*/
private $domains;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Users\Child", mappedBy="course")
*/
private $students;
/*
* @ORM\ManyToMany(targetEntity="Bo\MediaBundle\Entity\Slideshow", mappedBy="courses")
*/
private $slideshows;
/*********************** FIN ********************/
public function __construct()
{
$this->domains = new ArrayCollection();
$this->students = new ArrayCollection();
$this->front = false;
$this->slideshows = new ArrayCollection();
}
/**
*
* Return slugs for high school
* @return array
*/
public static function getSlugHighSchool()
{
return [
self::SLUG_TERMINALE,
self::SLUG_PREMIERE,
self::SLUG_SECONDE,
];
}
/**
* Return slugs for middle school
* @return array
*/
public static function getSlugMiddleSchool()
{
return [
self::SLUG_SIXIEME,
self::SLUG_CINQUIEME,
self::SLUG_QUATRIEME,
self::SLUG_TROISIEME,
];
}
/**
*
* Return slugs for free video are forbidden
* @return array
*/
public static function getSlugFreeVideoForbidden()
{
return [
self::SLUG_TERMINALE,
self::SLUG_PREMIERE,
self::SLUG_SECONDE,
self::SLUG_TROISIEME,
self::SLUG_QUATRIEME,
self::SLUG_CINQUIEME,
self::SLUG_SIXIEME,
];
}
/**
*
* Return slugs for stage are forbidden
* @return array
*/
public static function getSlugStageForbidden()
{
return [
];
}
/**
* Return the slug for pack bac
*
* @return array
*/
public static function getSlugPackBac()
{
return [
self::SLUG_TERMINALE,
self::SLUG_PREMIERE,
];
}
/**
* Return the slug for pack brevet
*
* @return array
*/
public static function getSlugPackBrevet()
{
return [
self::SLUG_TROISIEME,
];
}
/**
* Return the slug for pack été
*
* @return array
*/
public static function getSlugPackEte()
{
return [
self::SLUG_TERMINALE,
self::SLUG_PREMIERE,
self::SLUG_SECONDE,
];
}
/**
* Return all discipline by serie, serie by course
*
* @return array
*/
public static function getAllSerieDiscipline()
{
return [
self::SLUG_TERMINALE => [
Serie::SLUG_GENERAL => [
Discipline::SLUG_MATHEMATIQUES,
Discipline::SLUG_FRANCAIS,
Discipline::SLUG_ANGLAIS,
],
/*
Serie::SLUG_S => [
Discipline::SLUG_MATHEMATIQUES,
Discipline::SLUG_FRANCAIS,
Discipline::SLUG_ANGLAIS,
],
Serie::SLUG_L => [
Discipline::SLUG_MATHEMATIQUES,
Discipline::SLUG_FRANCAIS,
Discipline::SLUG_PHILOSOPHIE,
],
Serie::SLUG_ES => [
Discipline::SLUG_MATHEMATIQUES,
Discipline::SLUG_FRANCAIS,
Discipline::SLUG_PHILOSOPHIE,
],
*/
],
self::SLUG_PREMIERE => [
Serie::SLUG_GENERAL => [
Discipline::SLUG_MATHEMATIQUES,
Discipline::SLUG_FRANCAIS,
Discipline::SLUG_ANGLAIS,
],
],
self::SLUG_SECONDE => [
Serie::SLUG_GENERAL => [
Discipline::SLUG_MATHEMATIQUES,
Discipline::SLUG_FRANCAIS,
Discipline::SLUG_ANGLAIS,
],
],
self::SLUG_TROISIEME => [
Serie::SLUG_GENERAL => [
Discipline::SLUG_MATHEMATIQUES,
Discipline::SLUG_FRANCAIS,
Discipline::SLUG_ANGLAIS,
],
],
self::SLUG_QUATRIEME => [
Serie::SLUG_GENERAL => [
Discipline::SLUG_MATHEMATIQUES,
Discipline::SLUG_FRANCAIS,
Discipline::SLUG_ANGLAIS,
],
],
self::SLUG_CINQUIEME => [
Serie::SLUG_GENERAL => [
Discipline::SLUG_MATHEMATIQUES,
Discipline::SLUG_FRANCAIS,
Discipline::SLUG_ANGLAIS,
],
],
self::SLUG_SIXIEME => [
Serie::SLUG_GENERAL => [
Discipline::SLUG_MATHEMATIQUES,
Discipline::SLUG_FRANCAIS,
Discipline::SLUG_ANGLAIS,
],
],
];
}
/**
*
* Return html color course slug
* @return array
*/
public static function getHtmlColor()
{
return [
self::SLUG_TERMINALE => ['main' => '#FF69ADE9', 'gradient' => '#FF4696E8' ],
self::SLUG_PREMIERE => ['main' => '#FFF36E88', 'gradient' => '#FFFF9CAF' ],
self::SLUG_SECONDE => ['main' => '#FFFFA924', 'gradient' => '#FFFFC63B' ],
self::SLUG_TROISIEME => ['main' => '#FFFF9F61', 'gradient' => '#FFFF854A' ],
self::SLUG_QUATRIEME => ['main' => '#FF66C36A', 'gradient' => '#FF6AD490' ],
self::SLUG_CINQUIEME => ['main' => '#FF716AE1', 'gradient' => '#FF8E88FF' ],
self::SLUG_SIXIEME => ['main' => '#FFEF513A', 'gradient' => '#FFFF8F7E' ],
];
}
/**
*
* Return course code
* @return array
*/
public static function getCodeBySlug($courseSlug, Serie $serie = null)
{
$courseCode = [
self::SLUG_PREMIERE => '1',
self::SLUG_SECONDE => '2',
self::SLUG_TROISIEME => '3',
self::SLUG_QUATRIEME => '4',
self::SLUG_CINQUIEME => '5',
self::SLUG_SIXIEME => '6',
];
if(array_key_exists($courseSlug, $courseCode) === true) {
return $courseCode[$courseSlug];
}
return $serie->getLabel();
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param int $id
*/
public function setId(int $id)
{
$this->id = $id;
}
/**
* Set title
*
* @param string $title
*/
public function setTitle($title)
{
$this->title = strtoupper($title);
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set slug
*
* @param string $slug
*/
public function setSlug($slug)
{
$this->slug = $slug;
}
/**
* Get slug
*
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* Add domains
*
* @param Domain $domains
*/
public function addDomains(Domain $domains)
{
$this->domains[] = $domains;
}
/**
* Get domains
*
* @return ArrayCollection
*/
public function getDomains()
{
return $this->domains;
}
/**
* Add user
*
* @param $student
*/
public function addStudents(Student $student)
{
$this->students[] = $student;
}
/**
* Get students
*
* @return ArrayCollection
*/
public function getStudents()
{
return $this->students;
}
/**
* @return string
*/
public function __toString()
{
if (!$this) {
return "N/A";
}
return $this->getTitle();
}
/**
* @return mixed
*/
public function getFront()
{
return $this->front;
}
/**
* @param mixed $front
*/
public function setFront($front)
{
$this->front = $front;
}
/**
* @return int
*/
public function getOrder()
{
return $this->order;
}
/**
* @param int $order
*/
public function setOrder($order)
{
$this->order = $order;
}
/**
* Add domains
*
* @param Domain $domains
* @return Course
*/
public function addDomain(Domain $domains)
{
$this->domains[] = $domains;
return $this;
}
/**
* Remove domains
*
* @param Domain $domains
*/
public function removeDomain(Domain $domains)
{
$this->domains->removeElement($domains);
}
/**
* Add students
*
* @param Child $students
* @return Course
*/
public function addStudent(Child $students)
{
$this->students[] = $students;
return $this;
}
/**
* Remove students
*
* @param \Bo\StudentBundle\Entity\Student $students
*/
public function removeStudent(Child $students)
{
$this->students->removeElement($students);
}
/**
* Add slideshows
*
* @param \Bo\MediaBundle\Entity\Slideshow $slideshows
* @return Course
*/
public function addSlideshow( $slideshows)
{
$this->slideshows[] = $slideshows;
return $this;
}
/**
* Remove slideshows
*
* @param \Bo\MediaBundle\Entity\Slideshow $slideshows
*/
public function removeSlideshow( $slideshows)
{
$this->slideshows->removeElement($slideshows);
}
/**
* Get slideshows
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getSlideshows()
{
return $this->slideshows;
}
/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* @param string $description
*/
public function setDescription($description)
{
$this->description = $description;
}
/**
* @return string
*/
public function getMetadescription()
{
return $this->metadescription;
}
/**
* @param string $metadescription
*/
public function setMetadescription( $metadescription)
{
$this->metadescription = $metadescription;
}
}