doer = $doer; } /** * We pass the doTask function an array representing one item to update. * We expect to get the same format back. * * @param \Civi\Api4\Generic\Result $result */ public function _run(Result $result) { foreach ($this->getBatchRecords() as $item) { $result[] = $this->doTask($item); } } /** * This Basic Batch class can be used in one of two ways: * * 1. Use this class directly by passing a callable ($doer) to the constructor. * 2. Extend this class and override this function. * * Either way, this function should return an array with an output record * for the item. * * @param array $item * @return array * @throws \Civi\API\Exception\NotImplementedException */ protected function doTask($item) { if (is_callable($this->doer)) { $this->addCallbackToDebugOutput($this->doer); return call_user_func($this->doer, $item, $this); } throw new NotImplementedException('Doer function not found for api4 ' . $this->getEntityName() . '::' . $this->getActionName()); } }