Class \Scrivo\ObjectRole

Class that represents an object-role relation.

The object-role relationship is a 1 to n relation of Scrivo objects (pages or assets) and Scrivo roles.

Extends \Scrivo\Role .
Defined in: ObjectRole.php.


Constructor summary

Attr. Name / Description
public

ObjectRole($context)

Create an empty role object.

Constant summary

Name Description
EDITOR_ROLE Constant to denote an editor role.
PUBLIC_ROLE Constant to denote a public role.

Member summary

Attr. Type Name Description
private \..\Context $context A Scrivo context.
private \..\String $description A descriptive name for this role.
protected int $id The role id (DB key).
private \..\String $title The role title.
private int $type The role type, \Scrivo\Role::EDITOR_ROLE or \Scrivo\Role::PUBLIC_ROLE

Method summary

Attr. Type Name / Description
public mixed

__get($name)

Implementation of the readable properties using the PHP magic method __get().

public

__set($name, $value)

Implementation of the writable properties using the PHP magic method __set().

public static

delete($context, $id)

Delete existing role data from the database.

public static \..\Role

fetch($context, $id)

Fetch a role object from the database using its object id.

public

insert()

Insert new role object data into the database.

public static \..\ObjectRole[]

select($context, $objectId)

Select the object-roles for a given object by object id.

public static

set($context, $objectId, $roles)

Set the object roles for a given object.

private

setDescription($description)

Set the descriptive name for this role.

protected

setFields($context, $rd)

Convenience method to set the fields of a role object from an array (result set row).

private

setTitle($title)

Set the role title.

private

setType($type)

Set the role's type, \Scrivo\Role::EDITOR_ROLE or \Scrivo\Role::PUBLIC_ROLE.

public

update()

Update existing role object data in the database.

private static

validateDelete($context, $id)

Check if deletion of role object data does not violate any business rules.

private

validateInsert()

Check if this role object can be inserted into the database.

private

validateUpdate()

Check if this role object can be updated in the database.

 


Constructor

public ObjectRole(\Scrivo\Context $context=null)

Create an empty role object.

Inherited from \Scrivo\Role

Parameters:

Type Name Def. Description
\Scrivo\Context $context null

A Scrivo context.


Constants

EDITOR_ROLE

Constant to denote an editor role.

Inherited from \Scrivo\Role

Value: 2

PUBLIC_ROLE

Constant to denote a public role.

Inherited from \Scrivo\Role

Value: 3


Members


				
private \Scrivo\Context $context

A Scrivo context.

Inherited from \Scrivo\Role

Inital value: null


				
private \Scrivo\String $description

A descriptive name for this role.

Inherited from \Scrivo\Role

Inital value: null


				
protected int $id

The role id (DB key).

Inherited from \Scrivo\Role

Inital value: 0


				
private \Scrivo\String $title

The role title.

Inherited from \Scrivo\Role

Inital value: null


				
private int $type

The role type, \Scrivo\Role::EDITOR_ROLE or \Scrivo\Role::PUBLIC_ROLE

Inherited from \Scrivo\Role

Inital value: self::PUBLIC_ROLE


Methods

public mixed __get(string $name)

Implementation of the readable properties using the PHP magic method __get().

Inherited from \Scrivo\Role

Parameters:

Type Name Def. Description
string $name

The name of the property to get.

Returns:

mixed Implementation of the readable properties using the PHP magic method __get().

public __set(string $name, mixed $value)

Implementation of the writable properties using the PHP magic method __set().

Inherited from \Scrivo\Role

Parameters:

Type Name Def. Description
string $name

The name of the property to set.

mixed $value

The value of the property to set.

public static delete(\Scrivo\Context $context, int $id)

Delete existing role data from the database.

First it is is checked if it's possible to delete role data, then the role data including its dependecies is deleted from the database.

Inherited from \Scrivo\Role

Parameters:

Type Name Def. Description
\Scrivo\Context $context

A Scrivo context.

int $id

The object id of the role to select.

Throws:

Exception Type Description
\Scrivo\ApplicationException If the data is not accessible or if it is not possible to delete the role data.
public static \Scrivo\Role fetch(\Scrivo\Context $context, int $id)

Fetch a role object from the database using its object id.

Inherited from \Scrivo\Role

Parameters:

Type Name Def. Description
\Scrivo\Context $context

A Scrivo context.

int $id

The object id of the role to select.

Returns:

\Scrivo\Role Fetch a role object from the database using its object id.

public insert()

Insert new role object data into the database.

First it is checked if the data of this role object can be inserted into the database, then the data is inserted into the database. If no id was set a new object id is generated.

Inherited from \Scrivo\Role

Throws:

Exception Type Description
\Scrivo\ApplicationException If the data is not accessible or one or more of the fields contain invalid data.
public static \Scrivo\ObjectRole[roleId] select(\Scrivo\Context $context, int $objectId)

Select the object-roles for a given object by object id.

Depending on the given arguments the public or editor roles can be retrieved.

Parameters:

Type Name Def. Description
\Scrivo\Context $context

A Scrivo context.

int $objectId

An id of an object to create the object-roles for.

Returns:

\Scrivo\ObjectRole[roleId] Select the object-roles for a given object by object id.

public static set(\Scrivo\Context $context, int $objectId, \Scrivo\ObjectRole[] $roles)

Set the object roles for a given object.

The object roles to set is either an array of ObjectRole or stdObject objects. stdObject need to contain the member roleId.

Note: this sets all the roles for the object at once. So not giving the the roles effectivily clears the roles for the given object.

TODO: does noet clear the cache propery

Parameters:

Type Name Def. Description
\Scrivo\Context $context

A Scrivo context.

int $objectId

An id of an object to set the object-roles for.

\Scrivo\ObjectRole[] $roles

A new set of object-roles for the given object.

private setDescription(\Scrivo\String $description)

Set the descriptive name for this role.

Inherited from \Scrivo\Role

Parameters:

Type Name Def. Description
\Scrivo\String $description

A descriptive name for this role.

protected setFields(\Scrivo\Context $context, array $rd)

Convenience method to set the fields of a role object from an array (result set row).

Inherited from \Scrivo\Role

Parameters:

Type Name Def. Description
\Scrivo\Context $context

A Scrivo context.

array $rd

An array containing the field data using the database field names as keys.

private setTitle(\Scrivo\String $title)

Set the role title.

Inherited from \Scrivo\Role

Parameters:

Type Name Def. Description
\Scrivo\String $title

The role's title.

private setType(int $type)

Set the role's type, \Scrivo\Role::EDITOR_ROLE or \Scrivo\Role::PUBLIC_ROLE.

Inherited from \Scrivo\Role

Parameters:

Type Name Def. Description
int $type

The role's type, \Scrivo\Role::EDITOR_ROLE or \Scrivo\Role::PUBLIC_ROLE.

public update()

Update existing role object data in the database.

First it is checked if the data of this role object can be updated in the database, then the data is updated in the database.

Inherited from \Scrivo\Role

Throws:

Exception Type Description
\Scrivo\ApplicationException If the data is not accessible or one or more of the fields contain invalid data.
private static validateDelete(\Scrivo\Context $context, int $id)

Check if deletion of role object data does not violate any business rules.

Inherited from \Scrivo\Role

Parameters:

Type Name Def. Description
\Scrivo\Context $context

A Scrivo context.

int $id

The object id of the role to select.

Throws:

Exception Type Description
\Scrivo\ApplicationException If the data is not accessible or if it is not possible to delete the language data.
private validateInsert()

Check if this role object can be inserted into the database.

Inherited from \Scrivo\Role

Throws:

Exception Type Description
\Scrivo\ApplicationException If the data is not accessible or one or more of the fields contain invalid data.
private validateUpdate()

Check if this role object can be updated in the database.

Inherited from \Scrivo\Role

Throws:

Exception Type Description
\Scrivo\ApplicationException If the data is not accessible or one or more of the fields contain invalid data.

Documentation generated by phpDocumentor 2.0.0a12 and ScrivoDocumentor on August 29, 2013