dolibarr 23.0.3
ObjectLinks Class Reference
Inheritance diagram for ObjectLinks:
Collaboration diagram for ObjectLinks:

Public Member Functions

 __construct ()
 Constructor of the class.
 
 getById ($id)
 Get properties of a ObjectLink object.
 
 create ($request_data=null)
 Create object link.
 
 deleteById ($id)
 Delete an object link.
 
 getByValues ($fk_source, $sourcetype, $fk_target, $targettype, $relationtype=null)
 GET object link(s) By Values, not id.
 
 deleteByValues ($fk_source, $sourcetype, $fk_target, $targettype, $relationtype=null, $notrigger=0)
 Delete object link By Values, not id.
 
- Public Member Functions inherited from DolibarrApi
 __construct ($db, $cachedir='', $refreshCache=false)
 Constructor.
 

Protected Member Functions

 _cleanObjectDatas ($object)
 Clean sensible object datas @phpstan-template T.
 
- Protected Member Functions inherited from DolibarrApi
 _checkValForAPI ($field, $value, $object)
 Check and convert a string depending on its type/name.
 
 _filterObjectProperties ($object, $properties)
 Filter properties that will be returned on object.
 
 _checkFilters ($sqlfilters, &$error='')
 Return if a $sqlfilters parameter is valid Function no more used.
 

Private Member Functions

 _setObjectLinkField ($field, $value)
 Set a field of $this->objectlink, with proper type.
 
 _fetch ($id)
 Get properties of an object link.
 
 _validate ($data)
 Validate fields before create or update object.
 

Additional Inherited Members

- Static Protected Member Functions inherited from DolibarrApi
static _checkAccessToResource ($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
 Check access by user to a given resource.
 
static _forge_criteria_callback ($matches)
 Function to forge a SQL criteria from a Generic filter string.
 

Detailed Description

Definition at line 33 of file api_objectlinks.class.php.

Member Function Documentation

◆ _cleanObjectDatas()

ObjectLinks::_cleanObjectDatas ( $object)
protected

Clean sensible object datas @phpstan-template T.

Parameters
Object$objectObject to clean @phan-param ObjectLink $object @phpstan-param T $object
Returns
Object Object with cleaned properties @phan-return ObjectLink @phpstan-return T

Reimplemented from DolibarrApi.

Definition at line 421 of file api_objectlinks.class.php.

References $object.

Referenced by _fetch(), and getByValues().

◆ _fetch()

ObjectLinks::_fetch ( $id)
private

Get properties of an object link.

Return an array with object links

Parameters
int$idID of objectlink
Returns
Object Object with cleaned properties @phan-return ObjectLink @phpstan-return ObjectLink
Exceptions
RestException403
RestException404

Definition at line 383 of file api_objectlinks.class.php.

References $id, and _cleanObjectDatas().

Referenced by getById().

◆ _setObjectLinkField()

ObjectLinks::_setObjectLinkField ( $field,
$value )
private

Set a field of $this->objectlink, with proper type.

Parameters
string$fieldThe field to set
string | float$valueThe "unclean" value
Returns
void No return value, but field is set in $this->objectlink

Fields that are of integer type, used for casting during object creation and update

Definition at line 95 of file api_objectlinks.class.php.

References DolibarrApi\_checkValForAPI().

Referenced by create(), deleteByValues(), and getByValues().

◆ _validate()

ObjectLinks::_validate ( $data)
private

Validate fields before create or update object.

Parameters
?array<string,null|int|string>$data Data to validate
Returns
array<string,null|int|string> Return array with validated mandatory fields and their value @phan-return array<string,?int|?string> Return array with validated mandatory fields and their value
Exceptions
RestException400

Definition at line 517 of file api_objectlinks.class.php.

Referenced by create(), deleteByValues(), and getByValues().

◆ create()

ObjectLinks::create ( $request_data = null)

Create object link.

Examples: Only set "notrigger": 1 because 0 is the default value. Linking subscriptions for when you sell membership as part of another sale {"fk_source":"1679","sourcetype":"propal","fk_target":"1233","targettype":"commande"} {"fk_source":"167","sourcetype":"facture","fk_target":"123","targettype":"subscription"}

Parameters
array$request_dataRequest data, see Example above for required parameters. Currently unused is relationtype. notrigger is default 0, which means to trigger, else set notrigger: 1 @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data
Returns
array @phan-return array<array<string,int|string>> @phpstan-return array<array<string,int|string>>

@url POST

Exceptions
RestException304
RestException403
RestException500

Definition at line 137 of file api_objectlinks.class.php.

References _setObjectLinkField(), and _validate().

◆ deleteById()

ObjectLinks::deleteById ( $id)

Delete an object link.

Parameters
int$idobject link ID
Returns
array @phan-return array<array<string,int|string>> @phpstan-return array<array<string,int|string>>

@url DELETE {id}

Exceptions
RestException403
RestException404
RestException500

Definition at line 198 of file api_objectlinks.class.php.

References $id.

◆ deleteByValues()

ObjectLinks::deleteByValues ( $fk_source,
$sourcetype,
$fk_target,
$targettype,
$relationtype = null,
$notrigger = 0 )

Delete object link By Values, not id.

Parameters
int$fk_sourcesource id of object we link from
string$sourcetypetype of the source object
int$fk_targettarget id of object we link to
string$targettypetype of the target object
string$relationtypetype of the relation, usually null
int$notrigger1=Does not execute triggers, 0=execute triggers {@choice 0,1}
Returns
array @phan-return array<array<string,int|string>> @phpstan-return array<array<string,int|string>>

@url DELETE

Exceptions
RestException403
RestException404
RestException500

Definition at line 315 of file api_objectlinks.class.php.

References _setObjectLinkField(), and _validate().

◆ getById()

ObjectLinks::getById ( $id)

Get properties of a ObjectLink object.

Return an array with object link information

Parameters
int$idID of objectlink
Returns
Object Object with cleaned properties @phan-return ObjectLink @phpstan-return ObjectLink

@url GET {id}

Exceptions
RestException403
RestException404

Definition at line 81 of file api_objectlinks.class.php.

References $id, and _fetch().

◆ getByValues()

ObjectLinks::getByValues ( $fk_source,
$sourcetype,
$fk_target,
$targettype,
$relationtype = null )

GET object link(s) By Values, not id.

Parameters
int$fk_sourcesource id of object we link from
string$sourcetypetype of the source object
int$fk_targettarget id of object we link to
string$targettypetype of the target object
string$relationtypetype of the relation, usually null
Returns
Object @phan-return ObjectLink @phpstan-return ObjectLink

@url GET

Exceptions
RestException403
RestException404
RestException500

Definition at line 251 of file api_objectlinks.class.php.

References _cleanObjectDatas(), _setObjectLinkField(), and _validate().


The documentation for this class was generated from the following file: