<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\SchoolRole;
class SchoolTeacherMapping {
/**
* @var integer
*/
private $id;
/**
* @var \App\Entity\School
*/
private $school;
/**
* @var \App\Entity\User
*/
private $user;
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $roles;
/**
* @var boolean
*/
private $isActive = true;
/**
* @var \DateTime
*/
private $createdAt;
/**
* Constructor
*/
public function __construct() {
$this->roles = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId() {
return $this->id;
}
/**
* Set isActive
*
* @param boolean $isActive
*
* @return SchoolTeacherMapping
*/
public function setIsActive($isActive) {
$this->isActive = $isActive;
return $this;
}
/**
* Get isActive
*
* @return boolean
*/
public function getIsActive() {
return $this->isActive;
}
/**
* Set createdAt
*
* @param \DateTime $createdAt
*
* @return SchoolTeacherMapping
*/
public function setCreatedAt($createdAt) {
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return \DateTime
*/
public function getCreatedAt() {
return $this->createdAt;
}
/**
* Set school
*
* @param \App\Entity\School $school
*
* @return SchoolTeacherMapping
*/
public function setSchool(\App\Entity\School $school = null) {
$this->school = $school;
return $this;
}
/**
* Get school
*
* @return \App\Entity\School
*/
public function getSchool() {
return $this->school;
}
/**
* Set user.
*
* @param \App\Entity\User|null $user
*
* @return SchoolTeacherMapping
*/
public function setUser(\App\Entity\User $user = null) {
$this->user = $user;
return $this;
}
/**
* Get user.
*
* @return \App\Entity\User|null
*/
public function getUser() {
return $this->user;
}
/**
* Add role.
*
* @param \App\Entity\SchoolRole $role
*
* @return SchoolTeacherMapping
*/
public function addRole(\App\Entity\SchoolRole $role) {
$this->roles[] = $role;
return $this;
}
/**
* Remove role.
*
* @param \App\Entity\SchoolRole $role
*
* @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
*/
public function removeRole(\App\Entity\SchoolRole $role) {
return $this->roles->removeElement($role);
}
/**
* Get roles.
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getRoles() {
return $this->roles;
}
public function hasRoleBO() {
/* @var $role SchoolRole */
foreach ($this->roles as $role) {
if ($role->getId() == 2) {
return true;
}
}
return false;
}
public function getRoleShortNames() {
$text = '';
if (count($this->roles) > 0) {
$rolesText = '';
/* @var $role SchoolRole */
foreach ($this->roles as $role) {
$rolesText .= $role->getShortName() . ', ';
}
$shortNames = substr($rolesText, 0, -2);
$text = " ($shortNames)";
}
return $text;
}
public function getRoleDescriptions() {
$text = '';
/* @var $role SchoolRole */
foreach ($this->roles as $role) {
$text .= $role->getDescription() . ', ';
}
if (strlen($text) >= 2) {
return substr($text, 0, -2);
}
return $text;
}
public function __toString() {
$data = array();
$data['id'] = $this->id;
$data['user'] = $this->user->getName();
$data['roles'] = $this->getRoleShortNames();
return implode(", ", $data);
}
}