\Charcoal\Admin\UiObjectContainerTrait

An implementation, as Trait, of the {@see \Charcoal\Admin\Ui\ObjectContainerInterface}.

Summary

Methods
Properties
Constants
setModelFactory()
setObjType()
objType()
setObjId()
objId()
objIdWithSlashes()
setObjBaseClass()
objBaseClass()
proto()
hasObj()
obj()
No public properties found
No constants found
modelFactory()
createOrLoadObj()
cloneObj()
createObjFromBluePrint()
createObj()
loadObj()
validateObjType()
validateObjBaseClass()
$objType
$objId
$objBaseClass
$obj
N/A
No private methods found
$modelFactory
N/A

Properties

$objType

$objType : string|null

Type

string|null

$objId

$objId : string|\Charcoal\Admin\Ui\numeric|null

Type

string|\Charcoal\Admin\Ui\numeric|null

$objBaseClass

$objBaseClass : string

Type

string

$obj

$obj : \Charcoal\Model\ModelInterface

Type

\Charcoal\Model\ModelInterface

$modelFactory

$modelFactory : \Charcoal\Factory\FactoryInterface

Type

\Charcoal\Factory\FactoryInterface

Methods

setModelFactory()

setModelFactory(\Charcoal\Factory\FactoryInterface  $factory) : \Charcoal\Admin\Ui\ObjectContainerInterface

Parameters

\Charcoal\Factory\FactoryInterface $factory

The model factory, to create objects.

Returns

\Charcoal\Admin\Ui\ObjectContainerInterface

Chainable

setObjType()

setObjType(string  $objType) : \Charcoal\Admin\Ui\ObjectContainerInterface

Set the object type.

Parameters

string $objType

The object type.

Throws

\InvalidArgumentException

If provided argument is not of type 'string'.

Returns

\Charcoal\Admin\Ui\ObjectContainerInterface

Chainable

objType()

objType() : string|null

Retrieve the object type.

Returns

string|null

setObjId()

setObjId(string|\Charcoal\Admin\Ui\numeric  $objId) : \Charcoal\Admin\Ui\ObjectContainerInterface

Set the object ID.

Parameters

string|\Charcoal\Admin\Ui\numeric $objId

The object ID to load.

Throws

\InvalidArgumentException

If provided argument is not of type 'scalar'.

Returns

\Charcoal\Admin\Ui\ObjectContainerInterface

Chainable

objId()

objId() : string|\Charcoal\Admin\Ui\numeric|null

Retrieve the object ID.

Returns

string|\Charcoal\Admin\Ui\numeric|null

objIdWithSlashes()

objIdWithSlashes() : string

Retrieve the object ID and addslashes.

Used in template/charcoal/admin/template/form/js.mustache to prevent problems with ID with single or double quotes.

Returns

string —

Escaped ID.

setObjBaseClass()

setObjBaseClass(string  $objBaseClass) : \Charcoal\Admin\Ui\ObjectContainerInterface

Parameters

string $objBaseClass

The base class.

Throws

\InvalidArgumentException

If provided argument is not of type 'string'.

Returns

\Charcoal\Admin\Ui\ObjectContainerInterface

Chainable

objBaseClass()

objBaseClass() : string|null

Returns

string|null

proto()

proto() : \Charcoal\Model\ModelInterface

Retrieve a singleton of the {self::$objType} for prototyping.

Throws

\RuntimeException

If the class has no object type.

Returns

\Charcoal\Model\ModelInterface

hasObj()

hasObj() : boolean

Determine if the class has a concrete object.

Returns

boolean

obj()

obj() : \Charcoal\Model\ModelInterface

Retrieve the object.

Returns

\Charcoal\Model\ModelInterface

modelFactory()

modelFactory() : \Charcoal\Factory\FactoryInterface

Throws

\Exception

If the model factory was not set before being accessed.

Returns

\Charcoal\Factory\FactoryInterface

createOrLoadObj()

createOrLoadObj() : \Charcoal\Model\ModelInterface

Create or load the object.

Returns

\Charcoal\Model\ModelInterface

cloneObj()

cloneObj() : \Charcoal\Model\ModelInterface

Throws

\Exception

If the object is not valid.

Returns

\Charcoal\Model\ModelInterface

createObjFromBluePrint()

createObjFromBluePrint() : \Charcoal\Model\ModelInterface

Throws

\Exception

If the object is not valid.

Returns

\Charcoal\Model\ModelInterface

createObj()

createObj() : \Charcoal\Model\ModelInterface

Throws

\Exception

If the object is not valid.

Returns

\Charcoal\Model\ModelInterface

loadObj()

loadObj() : \Charcoal\Model\ModelInterface

Returns

\Charcoal\Model\ModelInterface —

The loaded object

validateObjType()

validateObjType() : boolean

Throws

\RuntimeException

If the object is invalid.

Returns

boolean

validateObjBaseClass()

validateObjBaseClass(mixed  $obj) : boolean

Parameters

mixed $obj

Object to validate.

Returns

boolean