/** * Creates a CronJobDefinition from a Array $job * provided by the parser $parser * * @param Array $xml * @param CronJobParser $parser * * @return CronJobDefinition */ public static function fromArray(array $job, CronJobParser $parser) { // create and return object $obj = new self(); $obj->setParser($parser); $obj->setName($job["name"]); $obj->setForkable((bool) $job["forkable"]); $obj->setInterval($job["interval"]); $obj->setPath($job["path"]); $obj->setClass($job["class"]); $obj->setStartTime($job["starttime"]); $obj->setEndTime($job["endtime"]); $obj->setArguments($job["args"]); $obj->setWeekDays($job["weekdays"]); $obj->setSuspended((bool) $job["suspended"]); if (isset($job["lastrun"])) { $obj->setLastExec($job["lastrun"]); } else { $obj->setLastExec(0); } return $obj; }
/** * {@inheritdoc} */ public static function fromArray(array $values) { $message = new self(); $values = array_merge(['result' => null, 'start_time' => null, 'badges' => []], $values); $message->setResult($values['result']); $message->setStartTime($values['start_time']); foreach ($values['badges'] as $item) { $message->addBadges($item); } return $message; }