/** * @param array $data */ protected function runChildJobs(array $data) { foreach ($this->config->getChildJobs() as $jobId => $child) { if (!empty($child->getConfig()['recursionFilter'])) { try { $filter = Filter::create($child->getConfig()['recursionFilter']); } catch (FilterException $e) { throw new UserException($e->getMessage(), 0, $e); } } foreach ($data as $result) { if (!empty($filter) && $filter->compareObject((object) $result) == false) { continue; } // Add current result to the beginning of an array, containing all parent results $parentResults = $this->parentResults; array_unshift($parentResults, $result); $childJob = $this->createChild($child, $parentResults); $childJob->run(); } } }
public function testCompareMulti() { // & $filter = Filter::create("field1==0&field2!=0"); $object = new \stdClass(); $object->field1 = 0; $object->field2 = 1; $this->assertEquals($filter->compareObject($object), true); $object->field2 = 0; $this->assertEquals($filter->compareObject($object), false); // | $filter = Filter::create("field1==0|field2!=0"); $object = new \stdClass(); $object->field1 = 0; $object->field2 = 1; $this->assertEquals($filter->compareObject($object), true); $object->field2 = 0; $this->assertEquals($filter->compareObject($object), true); $object->field1 = 1; $object->field2 = 0; $this->assertEquals($filter->compareObject($object), false); // & + | $filter = Filter::create("a==b&c==d|e==f"); $object = new \stdClass(); $object->a = "b"; $object->c = "d"; $object->e = "nope"; $this->assertEquals($filter->compareObject($object), true); $object->a = "b"; $object->c = "nope"; $object->e = "nope"; $this->assertEquals($filter->compareObject($object), false); }