/**
* @ORM\Entity
+ * @ORM\InheritanceType(value="JOINED")
+ * @ORM\DiscriminatorColumn(name="type", type="text", length=30)
+ * @ORM\DiscriminatorMap({
+ * "place" = "ResourcePlace",
+ * "computer" = "ResourceComputer",
+ * "zone" = "ResourceZone"
+ * })
*/
class Resource
{
- /**
+ const STATUS_ACTIVE = 1;
+ const STATUS_INACTIVE = 0;
+
+ /**
* @var integer $id
- *
+ *
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $description;
- /**
- * @ORM\Column(type="text", length=30)
- */
protected $type;
/**
- * @ORM\Column(type="text", length=30)
+ * @ORM\Column(type="integer")
*/
protected $status;
# Seule manière d'attribuer une valeur par défaut
public function __construct()
{
- $this->setType('lieu');
- $this->setStatus('actif');
+ $this->status = self::STATUS_ACTIVE;
}
-
+
public function getId()
{
return $this->id;
{
$list = array(null=>null);
$resources = $em->getRepository('EpnadminCoreBundle:Resource')->findBy(
- array('status'=>'actif','parent'=>null),
+ array('status'=>self::STATUS_ACTIVE,'parent'=>null),
array('name'=>'ASC')
);
foreach($resources as $resource)
/**
* Get sessions
*
- * @return Doctrine\Common\Collections\Collection
+ * @return Doctrine\Common\Collections\Collection
*/
public function getSessions()
{
return $this->sessions;
}
+
+ public function activate()
+ {
+ $this->status = self::STATUS_ACTIVE;
+ }
+
+ public function inactivate()
+ {
+ $this->status = self::STATUS_INACTIVE;
+ }
+
+ public function isBookable()
+ {
+ return $this->status == self::STATUS_ACTIVE;
+ }
}