Represents an entity.
Aside from being able to set entity fields via the PipelinerSales\ApiClient\Entity::setField()
method, it also
has automatic getters/setters in camel case and supports array access. These three
ways of setting a field are therefore equivalent:
$entity->setOwnerId(1);
$entity->setField('OWNER_ID', 1);
$entity['OWNER_ID'] = 1;
For standard fields, the magic getters/setters are considered the preferred method.
For a full list of supported entities and their fields, see the
API documentation.
Methods summary
public
|
#
__construct( string $type, string $dateTimeFormat )
Parameters
- $type
type of the entity, e.g. Account, see
list of entities
- $dateTimeFormat
- the format for converting DateTime objects into strings
|
public
|
|
public
PipelinerSales\ApiClient\Entity
|
#
setField( string $fieldName, mixed $value )
Sets this entity's field and adds it to the list of modified fields.
Returns $this, which allows for chaining of setters.
Sets this entity's field and adds it to the list of modified fields.
Returns $this, which allows for chaining of setters.
Parameters
- $fieldName
Name of the field to set, see
API documentation.
All standard fields are in upper-case, with underscore between the words (e.g. FORM_TYPE).
Custom fields don't have this requirement.
- $value
Value to set the fields to. DateTime objects are automatically converted
to strings according to the configured format (so calling a getter afterwards will only
return this string). Other types of values are used directly.
Returns
|
public
|
#
setFields( array $values )
Sets values of multiple fields at once. Fields not present in the array
will not be changed in any way.
Sets values of multiple fields at once. Fields not present in the array
will not be changed in any way.
Parameters
- $values
- an associative array of fields to values
|
public
PipelinerSales\ApiClient\Entity
|
#
unsetField( $fieldName )
Unsets the specified field. This means that the field will not be
changed upon saving. This affects both the "full update" and the
"modified only" update.
Unsets the specified field. This means that the field will not be
changed upon saving. This affects both the "full update" and the
"modified only" update.
Returns
|
public
mixed
|
#
getField( string $fieldName )
Returns the value of the specified field in this entity. A PHP notice will be raised
if the value hasn't been set yet.
Returns the value of the specified field in this entity. A PHP notice will be raised
if the value hasn't been set yet.
Parameters
Returns
mixed
|
public
array
|
#
getFields( )
Returns an associative array of all fields and their values
Returns an associative array of all fields and their values
Returns
array
|
public
string[]
|
#
getModifiedFields( )
Returns an associative array of fields which were modified since the entity was created/loaded,
and their values
Returns an associative array of fields which were modified since the entity was created/loaded,
and their values
Returns
string[]
|
public
boolean
|
#
isFieldSet( string $fieldName )
Returns true if this field has some configured value.
Returns true if this field has some configured value.
Parameters
Returns
boolean
|
public
string
|
#
allToJson( )
Returns a JSON-encoded string representing this entity. It will contain all
of this entity's fields.
Returns a JSON-encoded string representing this entity. It will contain all
of this entity's fields.
Returns
string
|
public
string
|
#
modifiedToJson( )
Returns a JSON-encoded string representing this entity, which will only contain
fields that have been modified since the entity was last loaded or saved.
Returns a JSON-encoded string representing this entity, which will only contain
fields that have been modified since the entity was last loaded or saved.
Returns
string
|
public
|
#
resetModified( )
Resets the list of modified fields. All fields will be considered "not modified".
RestRepository calls this automatically after successfully saving on the server.
Resets the list of modified fields. All fields will be considered "not modified".
RestRepository calls this automatically after successfully saving on the server.
|
public
string
|
#
getType( )
Returns the type of this entity.
Returns the type of this entity.
Returns
string
|
public
|
#
offsetExists( $offset )
Implementation of
ArrayAccess::offsetExists()
|
public
|
#
offsetGet( $offset )
Implementation of
ArrayAccess::offsetGet()
|
public
|
#
offsetSet( $offset, $value )
Implementation of
ArrayAccess::offsetSet()
|
public
|
#
offsetUnset( $offset )
Implementation of
ArrayAccess::offsetUnset()
|