public function _run(Result $result) { $baoName = $this->getBaoName(); $bao = new $baoName(); $result->exchangeArray(array_values($bao->fields())); // todo: custom fields // want to lose some of the cruft from v3 and key fields by name instead of custom_x }
/** * Scan all api directories to discover entities * * @param \Civi\API\Result $result */ public function _run(Result $result) { $entities = array(); foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) { $dir = \CRM_Utils_File::addTrailingSlash($path) . 'Civi/Api4'; if (is_dir($dir)) { foreach (glob("{$dir}/*.php") as $file) { $matches = array(); preg_match('/(\\w*).php/', $file, $matches); $entities[$matches[1]] = $matches[1]; } } } $result->exchangeArray(array_values($entities)); }
public function _run(Result $result) { $includePaths = array_unique(explode(PATH_SEPARATOR, get_include_path())); $entityReflection = new \ReflectionClass('\\Civi\\Api4\\' . $this->getEntity()); // First search entity-specific actions (including those provided by extensions foreach ($includePaths as $path) { $dir = \CRM_Utils_File::addTrailingSlash($path) . 'Civi/API/V4/Entity/' . $this->getEntity(); $this->scanDir($dir); } // Scan all generic actions unless this entity does not extend generic entity if ($entityReflection->getParentClass()) { foreach ($includePaths as $path) { $dir = \CRM_Utils_File::addTrailingSlash($path) . 'Civi/API/V4/Action'; $this->scanDir($dir); } } else { foreach ($entityReflection->getMethods(\ReflectionMethod::IS_STATIC) as $method) { $this->loadAction($method->getName()); } } $result->exchangeArray(array_values($this->_actions)); }
public function _run(API\Result $result) { $query = new API\Api4SelectQuery($this->getEntity(), $this->checkPermissions); $query->select = $this->select; $query->where = $this->where; $query->orderBy = $this->orderBy; $query->limit = $this->limit; $query->offset = $this->offset; $result->exchangeArray($query->run()); }