protected function execute(InputInterface $input, OutputInterface $output) { $relayRepo = new RelaySwitchRepository($this->getApplication()->getContainer()); $switches = $relayRepo->retrieveSwitches(); foreach ($switches as $switch) { if ($switch->getTimeTable()->isAutoPilot() === false) { continue; } if ($switch->getTimeTable()->isAlwaysOn() === true) { $switch->turnOn(); } foreach ($switch->getTimeTable()->getTimeTableEntries() as $timeTableEntry) { if (time() >= strtotime($timeTableEntry->getFrom()) && time() <= strtotime($timeTableEntry->getTo())) { $switch->turnOn(); } elseif (time() < strtotime($timeTableEntry->getFrom()) || time() > strtotime($timeTableEntry->getTo())) { $switch->turnOff(); } } } }
private function getRelaySwitches(Application $app) { $repo = new RelaySwitchRepository($app); return $repo->retrieveSwitches(); }