COAR Notify
 
Loading...
Searching...
No Matches
coarnotify\core\notify\NotifyBase Class Reference
Inheritance diagram for coarnotify\core\notify\NotifyBase:
coarnotify\core\notify\NotifyPattern coarnotify\core\notify\NotifyPatternPart coarnotify\patterns\accept\Accept coarnotify\patterns\announce_endorsement\AnnounceEndorsement coarnotify\patterns\announce_relationship\AnnounceRelationship coarnotify\patterns\announce_review\AnnounceReview coarnotify\patterns\announce_service_result\AnnounceServiceResult coarnotify\patterns\reject\Reject coarnotify\patterns\request_endorsement\RequestEndorsement coarnotify\patterns\request_review\RequestReview coarnotify\patterns\tentatively_accept\TentativelyAccept coarnotify\patterns\tentatively_reject\TentativelyReject coarnotify\patterns\undo_offer\UndoOffer coarnotify\patterns\unprocessable_notification\UnprocessableNotification coarnotify\core\notify\NotifyActor coarnotify\core\notify\NotifyItem coarnotify\core\notify\NotifyObject coarnotify\core\notify\NotifyService

Public Member Functions

 __construct ($stream=null, $validate_stream_on_construct=true, $validate_properties=true, $validators=null, $validation_context=null)
 
 getValidateProperties ()
 
 getValidateStreamOnConstruct ()
 
 getValidators ()
 
 getDoc ()
 
 getId ()
 
 setId ($value)
 
 getType ()
 
 setType ($types)
 
 getProperty ($prop_name)
 
 setProperty ($prop_name, $value)
 
 validate ()
 
 validateProperty ($prop_name, $value, $force_validate=false, $raise_error=true)
 
 toJSONLD ()
 

Protected Member Functions

 _registerPropertyValidationError (ValidationError $ve, $prop_name, $value)
 
 required (ValidationError $ve, $prop_name, $value)
 
 requiredAndValidate (ValidationError $ve, $prop_name, $value)
 
 optionalAndValidate (ValidationError $ve, $prop_name, $value)
 

Static Protected Member Functions

static deepCopy ($array)
 

Protected Attributes

 $validateStreamOnConstruct
 
 $validateProperties
 
 $validators
 
 $validationContext
 
 $stream
 

Detailed Description

Base class from which all Notify objects extend.

There are two kinds of Notify objects:

  1. Patterns, which are the notifications themselves
  2. Pattern Parts, which are nested elements in the Patterns, such as objects, contexts, actors, etc

This class forms the basis for both of those types, and provides essential services, such as construction, accessors and validation, as well as supporting the essential properties "id" and "type"

Constructor & Destructor Documentation

◆ __construct()

coarnotify\core\notify\NotifyBase::__construct ( $stream = null,
$validate_stream_on_construct = true,
$validate_properties = true,
$validators = null,
$validation_context = null )

Base constructor that all subclasses should call

Parameters
mixed$streamThe activity stream object, or an array from which one can be created
bool$validate_stream_on_constructShould the incoming stream be validated at construction-time
bool$validate_propertiesShould individual properties be validated as they are set
Validator | null$validatorsThe validator object for this class and all nested elements
string | array | null$validation_contextThe context in which this object is being validated

Reimplemented in coarnotify\core\notify\NotifyPattern, and coarnotify\core\notify\NotifyPatternPart.

Member Function Documentation

◆ _registerPropertyValidationError()

coarnotify\core\notify\NotifyBase::_registerPropertyValidationError ( ValidationError $ve,
$prop_name,
$value )
protected

Force validate the property and if an error is found, add it to the validation error

Parameters
ValidationError$ve
$prop_name
$value
Returns
void
Exceptions
ValueError

◆ getDoc()

coarnotify\core\notify\NotifyBase::getDoc ( )

The underlying activity stream document for this Notify object.

Returns
array|\coarnotify\core\activitystreams2\ActivityStream

◆ getProperty()

coarnotify\core\notify\NotifyBase::getProperty ( $prop_name)

Generic property getter. It is strongly recommended that all accessors proxy for this function as this mediates directly with the underlying activity stream object.

Parameters
$prop_name
Returns
mixed|null

◆ getValidateProperties()

coarnotify\core\notify\NotifyBase::getValidateProperties ( )

Are properties being validated on set?

Returns
bool

◆ getValidateStreamOnConstruct()

coarnotify\core\notify\NotifyBase::getValidateStreamOnConstruct ( )

Is the stream validated on construction?

Returns
bool

◆ getValidators()

coarnotify\core\notify\NotifyBase::getValidators ( )

The validator object for this instance

Returns
Validator

◆ optionalAndValidate()

coarnotify\core\notify\NotifyBase::optionalAndValidate ( ValidationError $ve,
$prop_name,
$value )
protected

Validate the value if it is not null, but do not raise a validation error if it is null

Parameters
ValidationError$ve
$prop_name
$value
Returns
void
Exceptions
ValueError

◆ required()

coarnotify\core\notify\NotifyBase::required ( ValidationError $ve,
$prop_name,
$value )
protected

Add a required error to the validation error if the value is null

Parameters
ValidationError$ve
$prop_name
$value
Returns
void

◆ requiredAndValidate()

coarnotify\core\notify\NotifyBase::requiredAndValidate ( ValidationError $ve,
$prop_name,
$value )
protected

Add a required error to the validation error if the value is null, and then validate the value if not.

Any error messages are added to the ValidationError object

Parameters
ValidationError$ve
$prop_name
$value
Returns
void
Exceptions
ValueError

◆ setProperty()

coarnotify\core\notify\NotifyBase::setProperty ( $prop_name,
$value )

Generic property setter. It is strongly recommended that all accessors proxy for this function as this mediates directly with the underlying activity stream object.

Parameters
$prop_name
$value
Returns
void
Exceptions
ValueError

◆ validate()

◆ validateProperty()

coarnotify\core\notify\NotifyBase::validateProperty ( $prop_name,
$value,
$force_validate = false,
$raise_error = true )

Validate a single property. This is used internally by setProperty

If the object has validate_properties set to false then that behaviour may be overridden by setting force_validate to true

The validator applied to the property will be determined according to the validators property of the object and the validation_context of the object.

Parameters
$prop_name
$value
$force_validate
$raise_error
Returns
array
Exceptions
ValueError

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