| 1 | 2 | simandl | <?php |
| 2 | | | |
| 3 | | | namespace FreenetRouter\Models\System; |
| 4 | | | |
| 5 | | | use FreenetRouter\Libraries\ServiceManagers\IServiceManager; |
| 6 | | | use Phem\Core\Object; |
| 7 | | | |
| 8 | | | /** |
| 9 | | | * @author Jakub PetrĹžĂlka <kubapet@lbcfree.net> |
| 10 | | | */ |
| 11 | | | class Service extends Object |
| 12 | | | { |
| 13 | | | |
| 14 | | | private $name; |
| 15 | | | private $caption; |
| 16 | | | private $enabled; |
| 17 | | | private $active; |
| 18 | | | private $serviceManager; |
| 19 | | | |
| 20 | | | public function __construct($name,$caption, IServiceManager $sm) |
| 21 | | | { |
| 22 | | | $this->name = $name; |
| 23 | | | $this->caption = $caption; |
| 24 | | | $this->serviceManager = $sm; |
| 25 | | | } |
| 26 | | | |
| 27 | | | public function getName() |
| 28 | | | { |
| 29 | | | return $this->name; |
| 30 | | | } |
| 31 | | | |
| 32 | | | public function getCaption() |
| 33 | | | { |
| 34 | | | return $this->caption; |
| 35 | | | } |
| 36 | | | |
| 37 | | | public function getEnabled() |
| 38 | | | { |
| 39 | | | if ($this->enabled === null) |
| 40 | | | { |
| 41 | | | $this->enabled = $this->serviceManager->isEnabled(); |
| 42 | | | } |
| 43 | | | return $this->enabled; |
| 44 | | | } |
| 45 | | | |
| 46 | | | public function getActive() |
| 47 | | | { |
| 48 | | | if ($this->active === null) |
| 49 | | | { |
| 50 | | | $this->active = $this->serviceManager->isActive(); |
| 51 | | | } |
| 52 | | | return $this->active; |
| 53 | | | } |
| 54 | | | |
| 55 | | | public function setName($name) |
| 56 | | | { |
| 57 | | | $this->name = $name; |
| 58 | | | } |
| 59 | | | |
| 60 | | | public function setCaption($caption) |
| 61 | | | { |
| 62 | | | $this->caption = $caption; |
| 63 | | | } |
| 64 | | | |
| 65 | | | public function setEnabled(boolean $enabled) |
| 66 | | | { |
| 67 | | | $this->serviceManager->setEnabled($enabled); |
| 68 | | | $this->enabled = $this->serviceManager->isEnabled(); |
| 69 | | | } |
| 70 | | | |
| 71 | | | public function setActive(boolean $active) |
| 72 | | | { |
| 73 | | | $this->serviceManager->setActive($active); |
| 74 | | | $this->active = $this->serviceManager->isActive(); |
| 75 | | | } |
| 76 | | | } |