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.
Attr. | Name / Description |
---|---|
public |
ObjectRole($context) Create an empty role object. |
Name | Description |
---|---|
EDITOR_ROLE | Constant to denote an editor role. |
PUBLIC_ROLE | Constant to denote a public role. |
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 |
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 |
Check if this role object can be inserted into the database. |
|
private |
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.
View source: Role.php line 109.
Constants
- EDITOR_ROLE
-
Constant to denote an editor role.
Inherited from \Scrivo\Role
Value: 2
View source: Role.php line 72.
- PUBLIC_ROLE
-
Constant to denote a public role.
Inherited from \Scrivo\Role
Value: 3
View source: Role.php line 67.
Members
- private \Scrivo\Context $context
-
A Scrivo context.
Inherited from \Scrivo\Role
Inital value: null
View source: Role.php line 102.
- private \Scrivo\String $description
-
A descriptive name for this role.
Inherited from \Scrivo\Role
Inital value: null
View source: Role.php line 96.
- protected int $id
-
The role id (DB key).
Inherited from \Scrivo\Role
Inital value: 0
View source: Role.php line 78.
- private \Scrivo\String $title
-
The role title.
Inherited from \Scrivo\Role
Inital value: null
View source: Role.php line 90.
- private int $type
-
The role type, \Scrivo\Role::EDITOR_ROLE or \Scrivo\Role::PUBLIC_ROLE
Inherited from \Scrivo\Role
Inital value: self::PUBLIC_ROLE
View source: Role.php line 84.
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().
View source: Role.php line 128.
- 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.
View source: Role.php line 145.
- 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. View source: Role.php line 321.
- 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.
View source: Role.php line 356.
- 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. View source: Role.php line 226.
- 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.
View source: ObjectRole.php line 55.
- 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.
View source: ObjectRole.php line 109.
- 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.
View source: Role.php line 202.
- 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.
View source: Role.php line 162.
- 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.
View source: Role.php line 193.
- 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.
View source: Role.php line 179.
- 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. View source: Role.php line 270.
- 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. View source: Role.php line 304.
- 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. View source: Role.php line 212.
- 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. View source: Role.php line 257.
Documentation generated by phpDocumentor 2.0.0a12 and ScrivoDocumentor on August 29, 2013