PHP Class OEModule\PASAPI\resources\BaseResource

ファイルを表示 Open project: openeyes/openeyes Class Usage Examples

Public Properties

Property Type Description
$errors
$id string Resource ID.
$partial_record boolean Property that will allow subset of data to be updated on the resource.
$update_only boolean Property that will prevent a model being created if its set to true.
$warn_errors boolean Flag that will force all errors on the resource to be mapped to warnings.
$warnings

Protected Properties

Property Type Description
$assignment OEModule\PASAPI\models\PasApiAssignment
$resource_type
$schema
$version

Public Methods

Method Description
__construct ( $version, array $options = [] ) BaseResource constructor.
addAuditData ( $key, $value ) Add to audit data property.
assignProperty ( $model, $model_key, $resource_key )
audit ( $audit_type, null $data = null, null $msg = null, array $properties = [] ) Wrapper for auditing calls on resource changes.
fromResourceId ( $version, $id ) : BaseResource Instantiate the resource from the external ID.
fromXml ( $version, $xml, array $options = [] ) : null | BaseResource Create an instance from an XML string.
fromXmlDom ( $version, DOMElement $element, array $options = [] ) : static instantiates a resource with the given XML Document.
getAssignedProperty ( $name )
getAssignment ( ) : PasApiAssignment
getAuditData ( ) : string Returns the json encoded audit data for logging.
getAuditTarget ( ) : string Simple wrapper to retrieve a type for auditing.
parseXml ( DOMElement $root, $options = [] ) Parses XML to define resource attributes.
remapValues ( $doc, XpathRemap[] $remaps = [] ) Update the given doc nodes as per the provided remaps.
setAssignment ( PasApiAssignment $assignment )
shouldValidateRequired ( ) : boolean
validate ( ) : boolean Base validator of resource from schema definition.

Protected Methods

Method Description
addError ( $msg ) Error logger.
addModelErrors ( $errors ) Convenience wrapper for handling model validation errors.
addWarning ( $msg ) Warning logger.
errorInit ( $version, $errors ) : static Convenience function to create a resource instance with error messages.
getInstanceForClass ( $class, $args = [] ) : mixed Abstraction for getting instance of class.
getSchema ( $version ) : mixed Get the schema for the resource type based on the given version.
startTransaction ( ) : CDbTransaction | null Wrapper for starting a transaction.

Method Details

__construct() public method

BaseResource constructor.
public __construct ( $version, array $options = [] )
$version
$options array

addAuditData() public method

Add to audit data property.
public addAuditData ( $key, $value )
$key
$value

addError() protected method

Error logger.
protected addError ( $msg )
$msg

addModelErrors() protected method

Convenience wrapper for handling model validation errors.
protected addModelErrors ( $errors )
$errors

addWarning() protected method

Warning logger.
protected addWarning ( $msg )
$msg

assignProperty() public method

public assignProperty ( $model, $model_key, $resource_key )
$model
$model_key
$resource_key

audit() public method

Wrapper for auditing calls on resource changes.
public audit ( $audit_type, null $data = null, null $msg = null, array $properties = [] )
$audit_type
$data null
$msg null
$properties array

errorInit() protected static method

Convenience function to create a resource instance with error messages.
protected static errorInit ( $version, $errors ) : static
$errors array
return static

fromResourceId() public static method

Instantiate the resource from the external ID.
public static fromResourceId ( $version, $id ) : BaseResource
$version
$id
return BaseResource

fromXml() public static method

Create an instance from an XML string.
public static fromXml ( $version, $xml, array $options = [] ) : null | BaseResource
$version
$xml
$options array
return null | BaseResource

fromXmlDom() public static method

instantiates a resource with the given XML Document.
public static fromXmlDom ( $version, DOMElement $element, array $options = [] ) : static
$version
$element DOMElement \DOMElement
$options array
return static

getAssignedProperty() public method

public getAssignedProperty ( $name )

getAssignment() public method

public getAssignment ( ) : PasApiAssignment
return OEModule\PASAPI\models\PasApiAssignment

getAuditData() public method

Returns the json encoded audit data for logging.
public getAuditData ( ) : string
return string

getAuditTarget() public method

Simple wrapper to retrieve a type for auditing.
public getAuditTarget ( ) : string
return string

getInstanceForClass() protected method

Abstraction for getting instance of class.
protected getInstanceForClass ( $class, $args = [] ) : mixed
$class
return mixed

getSchema() protected static method

Get the schema for the resource type based on the given version.
protected static getSchema ( $version ) : mixed
$version
return mixed

parseXml() public method

Parses XML to define resource attributes.
public parseXml ( DOMElement $root, $options = [] )
$root DOMElement

remapValues() public static method

Update the given doc nodes as per the provided remaps.
public static remapValues ( $doc, XpathRemap[] $remaps = [] )
$doc
$remaps OEModule\PASAPI\models\XpathRemap[]

setAssignment() public method

public setAssignment ( PasApiAssignment $assignment )
$assignment OEModule\PASAPI\models\PasApiAssignment

shouldValidateRequired() public method

public shouldValidateRequired ( ) : boolean
return boolean

startTransaction() protected method

Wrapper for starting a transaction.
protected startTransaction ( ) : CDbTransaction | null
return CDbTransaction | null

validate() public method

Base validator of resource from schema definition.
public validate ( ) : boolean
return boolean

Property Details

$assignment protected_oe property

protected PasApiAssignment,OEModule\PASAPI\models $assignment
return OEModule\PASAPI\models\PasApiAssignment

$errors public_oe property

public $errors

$id public_oe property

Resource ID.
public string $id
return string

$partial_record public_oe property

Property that will allow subset of data to be updated on the resource.
public bool $partial_record
return boolean

$resource_type protected_oe static_oe property

protected static $resource_type

$schema protected_oe property

protected $schema

$update_only public_oe property

Property that will prevent a model being created if its set to true.
public bool $update_only
return boolean

$version protected_oe property

protected $version

$warn_errors public_oe property

Flag that will force all errors on the resource to be mapped to warnings.
public bool $warn_errors
return boolean

$warnings public_oe property

public $warnings