About CiviCRMSdk
This folder is an internal SDK to provide CiviCRM data to the plugin. The data is provided through the CiviObjectsFactory. This factory provides objects, each of which provides CiviCRM data in a standard structure. The reason for this SDK is to ensure that changes to CiviCRM do not cause major rewrites of the plugin. With standard requests and responses used throughout, should anything change in CiviCRM, we need only address those changes within the CiviCrmSdk and the remainder of the plugin code remains untouched.
CiviObjectsFactory
This factory provides each Civi object, which in turn provides data from that object.
The contracts for each object follow a hierarchy, extending higher level contracts. At the highest level, the CiviObjects
contract specifies methods required by all objects. Below that, the Createable
and Retrievable
contracts specify methods required by those objects whose primary purpose is one of those. At the individual level, each object honors its own type's contract, which can specify methods unique to that object.
Wherever the factory is used, one can require the broadest (highest in the hierarchy) contract that contains all the required methods, thus providing the most flexibility in usage.
For example, if one's method is using only the getFields
method to provide field definitions, then one may use the CiviObject
contract. If one, however, is retrieving records from the object, the CiviObjectsRetrievale
contract must be specified to hold the object to that level.
CiviCRM Contracts
Each data source within the SDK has a contract defining how to access that object. These fall within one of two types - Createable and Retrievable. The Createable interface defines methods that enable writing a new record and getting the response of that request. The Retrievable interface defines methods to retrieve existing records; this is used primarily to populate data based on existing CiviCRM settings, such as Activity Types and Status, in which there are Ids defined for passing the data.
API
The API folder is a collection of Adapters. These honor the CiviCRM SDK contracts while using the objects provided by the CiviCRM plugin.