Example #1
0
 /**
  * Create an instance of config from config assoc. array
  * @param array $config
  *     example:
  *         [
  *            'id' => 'id',
  *            'endpoint' => ...
  *        ]
  * where accountId is a placeholder used as {accountId} in child job's endpoint
  * and account_id points to a key in a single response object (within an array)
  * @param array $configs Array of all configs to create recursion
  * @return JobConfig
  */
 public static function create(array $config)
 {
     if (empty($config['id'])) {
         // This'll change if the job settings change FIXME
         $config['id'] = md5(serialize($config));
     }
     if (empty($config['endpoint'])) {
         throw new UserException("'endpoint' must be set in each job!", 0, null, [$config]);
     }
     $job = new self($config['id'], $config);
     if (!empty($config['children'])) {
         foreach ($config['children'] as $child) {
             $job->addChildJob(self::create($child));
         }
     }
     return $job;
 }