Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api4 - improve docblocks & display links in explorer #16373

Merged
merged 2 commits into from
Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Civi/Api4/ACL.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@
namespace Civi\Api4;

/**
* ACL Entity.
* ACL (Access Control List).
*
* This entity holds the ACL informatiom. With this entity you add/update/delete an ACL permission which consists of
* an Operation (e.g. 'View' or 'Edit'), a set of Data that the operation can be performed on (e.g. a group of contacts),
* and a Role that has permission to do this operation. For more info refer to
* https://docs.civicrm.org/user/en/latest/initial-set-up/permissions-and-access-control for more info.
* An ACL record consists of:
*
* Creating a new ACL requires at minimum a entity table, entity ID and object_table
* - an Operation (e.g. 'View' or 'Edit')
* - a set of Data that the operation can be performed on (e.g. a group of contacts)
* - and a Role that has permission to do this operation.
*
* Creating a new ACL requires at minimum a entity table, entity ID and object_table.
*
* @see https://docs.civicrm.org/user/en/latest/initial-set-up/permissions-and-access-control
* @package Civi\Api4
*/
class ACL extends Generic\DAOEntity {
Expand Down
6 changes: 5 additions & 1 deletion Civi/Api4/Action/Entity/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function getRecords() {
&& is_a('\Civi\Api4\\' . $matches[1], '\Civi\Api4\Generic\AbstractEntity', TRUE)
) {
$entity = ['name' => $matches[1]];
if ($this->_isFieldSelected('description') || $this->_isFieldSelected('comment')) {
if ($this->_isFieldSelected('description') || $this->_isFieldSelected('comment') || $this->_isFieldSelected('see')) {
$this->addDocs($entity);
}
$entities[$matches[1]] = $entity;
Expand Down Expand Up @@ -95,6 +95,10 @@ private function addCustomEntities(&$entities) {
$entities[$fieldName] = [
'name' => $fieldName,
'description' => $customEntity['title'] . ' custom group - extends ' . $customEntity['extends'],
'see' => [
'https://docs.civicrm.org/user/en/latest/organising-your-data/creating-custom-fields/#multiple-record-fieldsets',
'\\Civi\\Api4\\CustomGroup',
],
];
if (!empty($customEntity['help_pre'])) {
$entities[$fieldName]['comment'] = $this->plainTextify($customEntity['help_pre']);
Expand Down
1 change: 1 addition & 0 deletions Civi/Api4/ActionSchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
*
* Creating a new ActionSchedule requires at minimum a title, mapping_id and entity_value.
*
* @see https://docs.civicrm.org/user/en/latest/email/scheduled-reminders/
* @package Civi\Api4
*/
class ActionSchedule extends Generic\DAOEntity {
Expand Down
1 change: 1 addition & 0 deletions Civi/Api4/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
*
* An activity is a record of some type of interaction with one or more contacts.
*
* @see https://docs.civicrm.org/user/en/latest/organising-your-data/activities/
* @package Civi\Api4
*/
class Activity extends Generic\DAOEntity {
Expand Down
1 change: 1 addition & 0 deletions Civi/Api4/ActivityContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*
* Creating a new ActivityContact requires at minimum a contact_id and activity_id.
*
* @see \Civi\Api4\Activity
* @package Civi\Api4
*/
class ActivityContact extends Generic\DAOEntity {
Expand Down
1 change: 1 addition & 0 deletions Civi/Api4/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
/**
* Campaign entity.
*
* @see https://docs.civicrm.org/user/en/latest/campaign/what-is-civicampaign/
* @package Civi\Api4
*/
class Campaign extends Generic\DAOEntity {
Expand Down
1 change: 1 addition & 0 deletions Civi/Api4/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*
* Creating a new contact requires at minimum a name or email address.
*
* @see https://docs.civicrm.org/user/en/latest/organising-your-data/contacts/
* @package Civi\Api4
*/
class Contact extends Generic\DAOEntity {
Expand Down
2 changes: 2 additions & 0 deletions Civi/Api4/ContactType.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
*
* Creating a new contact type requires at minimum a label and parent_id.
*
* @see https://docs.civicrm.org/user/en/latest/organising-your-data/contacts/#contact-subtypes
* @see \Civi\Api4\Contact
* @package Civi\Api4
*/
class ContactType extends Generic\DAOEntity {
Expand Down
2 changes: 2 additions & 0 deletions Civi/Api4/CustomField.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
/**
* CustomField entity.
*
* @see https://docs.civicrm.org/user/en/latest/organising-your-data/creating-custom-fields/
*
* @package Civi\Api4
*/
class CustomField extends Generic\DAOEntity {
Expand Down
2 changes: 2 additions & 0 deletions Civi/Api4/CustomGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
/**
* CustomGroup entity.
*
* @see https://docs.civicrm.org/user/en/latest/organising-your-data/creating-custom-fields/
*
* @package Civi\Api4
*/
class CustomGroup extends Generic\DAOEntity {
Expand Down
2 changes: 2 additions & 0 deletions Civi/Api4/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
/**
* Domains - multisite instances of CiviCRM.
*
* @see https://docs.civicrm.org/sysadmin/en/latest/setup/multisite/
*
* @package Civi\Api4
*/
class Domain extends Generic\DAOEntity {
Expand Down
2 changes: 2 additions & 0 deletions Civi/Api4/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
/**
* Retrieves information about all Api4 entities.
*
* @see \Civi\Api4\Generic\AbstractEntity
*
* @package Civi\Api4
*/
class Entity extends Generic\AbstractEntity {
Expand Down
3 changes: 2 additions & 1 deletion Civi/Api4/EntityTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
*
*/


namespace Civi\Api4;

/**
* EntityTag - links tags to contacts, activities, etc.
*
* @see \Civi\Api4\Tag
*
* @package Civi\Api4
*/
class EntityTag extends Generic\DAOEntity {
Expand Down
2 changes: 2 additions & 0 deletions Civi/Api4/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
/**
* Event entity.
*
* @see https://docs.civicrm.org/user/en/latest/events/what-is-civievent/
*
* @package Civi\Api4
*/
class Event extends Generic\DAOEntity {
Expand Down
2 changes: 1 addition & 1 deletion Civi/Api4/Event/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Events {
* Prepare the specification for a request. Fired from within a request to
* get fields.
*
* @see GetSpecEvent
* @see \Civi\Api4\Event\GetSpecEvent
*/
const GET_SPEC = 'civi.api.get_spec';

Expand Down
3 changes: 2 additions & 1 deletion Civi/Api4/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
*
*/


namespace Civi\Api4;

/**
* Group entity.
*
* @see https://docs.civicrm.org/user/en/latest/organising-your-data/groups-and-tags/#groups
*
* @package Civi\Api4
*/
class Group extends Generic\DAOEntity {
Expand Down
3 changes: 2 additions & 1 deletion Civi/Api4/GroupContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*
*/


namespace Civi\Api4;

/**
Expand All @@ -27,6 +26,8 @@
* A contact can either be "Added" "Removed" or "Pending" in a group.
* CiviCRM only considers them to be "in" a group if their status is "Added".
*
* @see \Civi\Api4\Group
*
* @package Civi\Api4
*/
class GroupContact extends Generic\DAOEntity {
Expand Down
2 changes: 2 additions & 0 deletions Civi/Api4/GroupNesting.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
/**
* GroupNesting entity.
*
* @see \Civi\Api4\Group
*
* @package Civi\Api4
*/
class GroupNesting extends Generic\DAOEntity {
Expand Down
3 changes: 3 additions & 0 deletions Civi/Api4/GroupOrganization.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
/**
* GroupOrganization entity.
*
* Relates groups to organizations.
*
* @see \Civi\Api4\Group
* @package Civi\Api4
*/
class GroupOrganization extends Generic\DAOEntity {
Expand Down
1 change: 0 additions & 1 deletion Civi/Api4/Mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*
*/


namespace Civi\Api4;

/**
Expand Down
3 changes: 2 additions & 1 deletion Civi/Api4/MappingField.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
*
*/


namespace Civi\Api4;

/**
* MappingField entity.
*
* This represents one field in a Mapping collection.
*
* @see \Civi\Api4\Mapping
*
* @package Civi\Api4
*/
class MappingField extends Generic\DAOEntity {
Expand Down
1 change: 0 additions & 1 deletion Civi/Api4/Navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*
*/


namespace Civi\Api4;

/**
Expand Down
1 change: 1 addition & 0 deletions Civi/Api4/OptionGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
/**
* OptionGroup entity.
*
* @see \Civi\Api4\OptionValue
* @package Civi\Api4
*/
class OptionGroup extends Generic\DAOEntity {
Expand Down
1 change: 1 addition & 0 deletions Civi/Api4/OptionValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
/**
* OptionValue entity.
*
* @see \Civi\Api4\OptionGroup
* @package Civi\Api4
*/
class OptionValue extends Generic\DAOEntity {
Expand Down
1 change: 0 additions & 1 deletion Civi/Api4/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*
*/


namespace Civi\Api4;

/**
Expand Down
2 changes: 2 additions & 0 deletions Civi/Api4/PaymentProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
/**
* Payment Processor entity.
*
* @see https://docs.civicrm.org/sysadmin/en/latest/setup/payment-processors/
*
* @package Civi\Api4
*/
class PaymentProcessor extends Generic\DAOEntity {
Expand Down
2 changes: 2 additions & 0 deletions Civi/Api4/PaymentProcessorType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
/**
* Payment Processor Type entity.
*
* @see \Civi\Api4\PaymentProcessor
*
* @package Civi\Api4
*/
class PaymentProcessorType extends Generic\DAOEntity {
Expand Down
2 changes: 1 addition & 1 deletion Civi/Api4/Provider/ActionObjectProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function invoke($action) {
// Load result class based on @return annotation in the execute() method.
$reflection = new \ReflectionClass($action);
$doc = ReflectionUtils::getCodeDocs($reflection->getMethod('execute'), 'Method');
$resultClass = \CRM_Utils_Array::value('return', $doc, '\\Civi\\Api4\\Generic\\Result');
$resultClass = $doc['return'][0] ?? '\\Civi\\Api4\\Generic\\Result';
$result = new $resultClass();
$result->action = $action->getActionName();
$result->entity = $action->getEntityName();
Expand Down
2 changes: 2 additions & 0 deletions Civi/Api4/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
/**
* Relationship entity.
*
* @see https://docs.civicrm.org/user/en/latest/organising-your-data/relationships/
*
* @package Civi\Api4
*/
class Relationship extends Generic\DAOEntity {
Expand Down
2 changes: 2 additions & 0 deletions Civi/Api4/RelationshipType.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
/**
* RelationshipType entity.
*
* @see \Civi\Api4\Relationship
*
* @package Civi\Api4
*/
class RelationshipType extends Generic\DAOEntity {
Expand Down
11 changes: 11 additions & 0 deletions Civi/Api4/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@

use Civi\Api4\Generic\BasicGetFieldsAction;

/**
* CiviCRM menu route.
*
* Provides page routes registered in the CiviCRM menu system.
*
* Note: this is a read-only api as routes are set via xml files and hooks.
*
* @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterMenu/
*
* @package Civi\Api4
*/
class Route extends \Civi\Api4\Generic\AbstractEntity {

/**
Expand Down
2 changes: 1 addition & 1 deletion Civi/Api4/Service/Spec/SpecGatherer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SpecGatherer {
/**
* Returns a RequestSpec with all the fields available. Uses spec providers
* to add or modify field specifications.
* For an example @see CustomFieldSpecProvider.
* @see \Civi\Api4\Service\Spec\Provider\CustomFieldCreationSpecProvider
*
* @param string $entity
* @param string $action
Expand Down
1 change: 1 addition & 0 deletions Civi/Api4/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*
* Used to read/write persistent setting data from CiviCRM.
*
* @see \Civi\Core\SettingsBag
* @package Civi\Api4
*/
class Setting extends Generic\AbstractEntity {
Expand Down
2 changes: 2 additions & 0 deletions Civi/Api4/StatusPreference.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
namespace Civi\Api4;

/**
* StatusPreference entity.
*
* For setting "hush" preferences for system check alerts.
*
* @package Civi\Api4
Expand Down
1 change: 1 addition & 0 deletions Civi/Api4/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* Tags in CiviCRM are used for Contacts, Activities, Cases & Attachments.
* They are connected to those entities via the EntityTag table.
*
* @see https://docs.civicrm.org/user/en/latest/organising-your-data/groups-and-tags/#tags
* @package Civi\Api4
*/
class Tag extends Generic\DAOEntity {
Expand Down
1 change: 1 addition & 0 deletions Civi/Api4/UFField.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
/**
* UFField entity - aka profile fields.
*
* @see \Civi\Api4\UFGroup
* @package Civi\Api4
*/
class UFField extends Generic\DAOEntity {
Expand Down
1 change: 1 addition & 0 deletions Civi/Api4/UFGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
/**
* UFGroup entity - AKA profiles.
*
* @see https://docs.civicrm.org/user/en/latest/organising-your-data/profiles/
* @package Civi\Api4
*/
class UFGroup extends Generic\DAOEntity {
Expand Down
1 change: 1 addition & 0 deletions Civi/Api4/UFJoin.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
/**
* UFJoin entity - links profiles to the components/extensions they are used for.
*
* @see \Civi\Api4\UFGroup
* @package Civi\Api4
*/
class UFJoin extends Generic\DAOEntity {
Expand Down
Loading