foreach ($entityReflection->getMethods(\ReflectionMethod::IS_STATIC | \ReflectionMethod::IS_PUBLIC) as $method) {
$actionName = $method->getName();
if ($actionName != 'permissions' && $actionName[0] != '_') {
- $this->loadAction($actionName);
+ $this->loadAction($actionName, $method);
}
}
if (!$this->_actionsToGet || count($this->_actionsToGet) > count($this->_actions)) {
/**
* @param $actionName
+ * @param \ReflectionMethod $method
*/
- private function loadAction($actionName) {
+ private function loadAction($actionName, $method = NULL) {
try {
if (!isset($this->_actions[$actionName]) && (!$this->_actionsToGet || in_array($actionName, $this->_actionsToGet))) {
$action = ActionUtil::getAction($this->getEntityName(), $actionName);
if (is_object($action)) {
$this->_actions[$actionName] = ['name' => $actionName];
- if ($this->_isFieldSelected('description', 'comment')) {
- $actionReflection = new \ReflectionClass($action);
- $actionInfo = ReflectionUtils::getCodeDocs($actionReflection);
- unset($actionInfo['method']);
- $this->_actions[$actionName] += $actionInfo;
+ if ($this->_isFieldSelected('description', 'comment', 'see')) {
+ // Docblock from action class
+ $actionDocs = ReflectionUtils::getCodeDocs($action->reflect());
+ unset($actionDocs['method']);
+ // Docblock from action factory function in entity class. This takes precedence since most action classes are generic.
+ if ($method) {
+ $methodDocs = ReflectionUtils::getCodeDocs($method, 'Method');
+ $actionDocs = $methodDocs + $actionDocs;
+ }
+ $this->_actions[$actionName] += $actionDocs;
}
if ($this->_isFieldSelected('params')) {
$this->_actions[$actionName]['params'] = $action->getParamInfo();
return [
[
'name' => 'name',
- 'data_type' => 'String',
+ 'description' => 'Action name',
],
[
'name' => 'description',
- 'data_type' => 'String',
+ 'description' => 'Description from docblock',
],
[
'name' => 'comment',
- 'data_type' => 'String',
+ 'description' => 'Comments from docblock',
+ ],
+ [
+ 'name' => 'see',
+ 'data_type' => 'Array',
+ 'description' => 'Any @see annotations from docblock',
],
[
'name' => 'params',
+ 'description' => 'List of all accepted parameters',
'data_type' => 'Array',
],
];
*/
class Contact extends Generic\DAOEntity {
+ /**
+ * @return \Civi\Api4\Action\Contact\GetFields|Generic\DAOGetFieldsAction
+ */
public static function getFields() {
return new Action\Contact\GetFields(__CLASS__, __FUNCTION__);
}
+ /**
+ * @return \Civi\Api4\Action\Contact\GetChecksum
+ */
public static function getChecksum() {
return new Action\Contact\GetChecksum(__CLASS__, __FUNCTION__);
}
+ /**
+ * @return \Civi\Api4\Action\Contact\ValidateChecksum
+ */
public static function validateChecksum() {
return new Action\Contact\ValidateChecksum(__CLASS__, __FUNCTION__);
}
use Civi\Api4\Utils\ActionUtil;
/**
- * Get fields for an entity.
+ * Get information about an entity's fields.
+ *
+ * This field information is also known as "metadata."
+ *
+ * Note that different actions may support different lists of fields.
+ * By default this will fetch the field list relevant to Get,
+ * but a different list may be returned if you specify another action.
*
* @method $this setLoadOptions(bool $value)
* @method bool getLoadOptions()