63 lines
1.1 KiB
PHP
63 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Trinity\Bundle\DashBoardBundle\DashBoard;
|
|
|
|
use Trinity\Bundle\DashBoardBundle\Zone\Zone;
|
|
use Trinity\Bundle\DashBoardBundle\Exception\DashBoardException;
|
|
|
|
class DashBoard
|
|
{
|
|
protected $name = null;
|
|
protected $zones = array();
|
|
|
|
public function __construct($name)
|
|
{
|
|
$this->name = $name;
|
|
}
|
|
|
|
public function setName($name)
|
|
{
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getName()
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
public function setZones($zones)
|
|
{
|
|
$this->zones = $zones;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getZones()
|
|
{
|
|
return $this->zones;
|
|
}
|
|
|
|
public function addZone(Zone $zone)
|
|
{
|
|
$this->zones[] = $zone;
|
|
}
|
|
|
|
public function getZone($zone_id)
|
|
{
|
|
foreach ($this->zones as $zone) {
|
|
if ($zone->getId() === $zone_id) {
|
|
return $zone;
|
|
}
|
|
}
|
|
|
|
throw new DashBoardException(sprintf('The zone "%s" is not found.', $zone_id));
|
|
}
|
|
|
|
public function get($zone_id)
|
|
{
|
|
return $this->getZone($zone_id);
|
|
}
|
|
}
|