Stud.IP  jlu_4.3 Revision 64286
ResourceCategory Class Reference
Inheritance diagram for ResourceCategory:
Inheritance graph
Collaboration diagram for ResourceCategory:
Collaboration graph

Public Member Functions

 getPropertyDefinitions ($excluded_properties=[])
 
 getGroupedPropertyDefinitions ($excluded_properties=[])
 
 addProperty ( $name='', $type='bool', $requestable=false, $protected=false, $write_permission_level='autor')
 
 createResource ( $name='', $description='', $parent_id='', $properties=[], $ignore_invalid=false)
 
 createDefinedResourceProperty (Resource $resource, $name, $state=null)
 
 createDefinedResourceRequestProperty (ResourceRequest $request, $name, $state=null)
 
 getRequestableProperties ()
 
 hasProperty ($name='', $type=null)
 
 userHasPropertyWritePermissions ($name='', User $user, $resource=null)
 
 getIconUrl ()
 
- Public Member Functions inherited from SimpleORMap
 __construct ($id=null)
 
 __clone ()
 
 getRelationOptions ($relation)
 
 getTableMetadata ()
 
 hasAutoIncrementColumn ()
 
 setId ($id)
 
 getId ()
 
 getNewId ()
 
 toArray ($only_these_fields=null)
 
 toRawArray ($only_these_fields=null)
 
 toArrayRecursive ($only_these_fields=null)
 
 getValue ($field)
 
 getRelationValue ($relation, $field)
 
 getDefaultValue ($field)
 
 setValue ($field, $value)
 
 __get ($field)
 
 __set ($field, $value)
 
 __isset ($field)
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 getIterator ()
 
 count ()
 
 isField ($field)
 
 isAdditionalField ($field)
 
 isAliasField ($field)
 
 isI18nField ($field)
 
 setData ($data, $reset=false)
 
 isNew ()
 
 isDeleted ()
 
 setNew ($is_new)
 
 getWhereQuery ()
 
 restore ()
 
 store ()
 
 triggerChdate ()
 
 delete ()
 
 isDirty ()
 
 isFieldDirty ($field)
 
 revertValue ($field)
 
 getPristineValue ($field)
 
 initRelation ($relation)
 
 resetRelation ($relation)
 
 cleanup ()
 

Static Public Member Functions

static findAll ($force_reload=false)
 
static find ($id)
 
static getClassNameById ($category_id)
 
- Static Public Member Functions inherited from SimpleORMap
static tableScheme ($db_table)
 
static expireTableScheme ()
 
static find ($id)
 
static exists ($id)
 
static countBySql ($sql=1, $params=array())
 
static create ($data)
 
static build ($data, $is_new=true)
 
static buildExisting ($data)
 
static import ($data)
 
static findBySQL ($sql, $params=array())
 
static findOneBySQL ($where, $params=array())
 
static findThru ($foreign_key_value, $options)
 
static findEachBySQL ($callable, $sql, $params=array())
 
static findMany ($pks=array(), $order='', $order_params=array())
 
static findEachMany ($callable, $pks=array(), $order='', $order_params=array())
 
static findAndMapBySQL ($callable, $where, $params=array())
 
static findAndMapMany ($callable, $pks=array(), $order='', $order_params=array())
 
static deleteBySQL ($where, $params=array())
 
static toObject ($id_or_object)
 
static __callStatic ($name, $arguments)
 

Protected Member Functions

 setPropertyDefaultState (ResourcePropertyDefinition $definition)
 
- Protected Member Functions inherited from SimpleORMap
 _getId ($field)
 
 _setId ($field, $value)
 
 _getAdditionalValueFromRelation ($field)
 
 _setAdditionalValueFromRelation ($field, $value)
 
 _getAdditionalValue ($field)
 
 _setAdditionalValue ($field, $value)
 
 parseRelationOptions ($type, $name, $options)
 
 storeRelations ($only_these=null)
 
 deleteRelations ()
 
 initializeContent ()
 
 applyCallbacks ($type)
 
 registerCallback ($types, $cb)
 
 unregisterCallback ($types, $cb)
 
 cbAutoIncrementColumn ($type)
 
 cbAutoKeyCreation ()
 
 cbNotificationMapper ($cb_type)
 
 cbAfterInitialize ($cb_type)
 
 setSerializedValue ($field, $value)
 
 setI18nValue ($field, $value)
 
 cbI18N ($type)
 

Static Protected Member Functions

static configure ($config=[])
 
- Static Protected Member Functions inherited from SimpleORMap
static configure ($config=array())
 
static config ($key)
 

Additional Inherited Members

- Data Fields inherited from SimpleORMap
const ID_SEPARATOR = '_'
 
- Static Public Attributes inherited from SimpleORMap
static $schemes = null
 
- Protected Attributes inherited from SimpleORMap
 $content = array()
 
 $content_db = array()
 
 $is_new = true
 
 $is_deleted = false
 
 $db_table = ''
 
 $db_fields = null
 
 $pk = null
 
 $default_values = array()
 
 $serialized_fields = array()
 
 $alias_fields = array()
 
 $i18n_fields = array()
 
 $additional_fields = array()
 
 $relations = array()
 
 $has_many = array()
 
 $has_one = array()
 
 $belongs_to = array()
 
 $has_and_belongs_to_many = array()
 
 $registered_callbacks = array()
 
 $known_slots = array()
 
 $notification_map = array()
 
 $additional_data = array()
 
 $getter_setter_map = array()
 
- Static Protected Attributes inherited from SimpleORMap
static $config = array()
 
static $reserved_slots = array('value','newid','iterator','tablemetadata', 'relationvalue','wherequery','relationoptions','data','new','id')
 

Detailed Description

The ResourceCategory class can be used as a Factory for Resource objects.

Member Function Documentation

◆ addProperty()

addProperty (   $name = '',
  $type = 'bool',
  $requestable = false,
  $protected = false,
  $write_permission_level = 'autor' 
)

Adds a property to this category. If the property doesn't exist it will be created.

Parameters
string$nameThe name of the property.
string$typeThe type of the property.
bool$requestableWhether the property is requestable or not. Defaults to false.
bool$protectedWhether the property is protected or not. Defaults to false.
Exceptions
ResourcePropertyExceptionIf the property cannot be created.
ResourcePropertyDefinitionExceptionIf the property definition cannot be created.
Returns
ResourceCategoryProperty The created or updated resource category property.
Here is the call graph for this function:

◆ configure()

static configure (   $config = [])
staticprotected

set configuration data from subclass

Parameters
array$configconfiguration data
Returns
void

Reimplemented from SimpleORMap.

◆ createDefinedResourceProperty()

createDefinedResourceProperty ( Resource  $resource,
  $name,
  $state = null 
)

Creates a ResourceProperty object for a specified Resource object.

Parameters
Resource$resourceThe resource for which the ResourceProperty object shall be built.
string$nameThe name of the property.
string$stateThe value of the property.
Exceptions
InvalidResourceCategoryExceptionIf this resource category doesn't match the category of the resource object.
ResourcePropertyExceptionIf the name of the resource property is not defined for this resource category.
Returns
ResourceProperty A ResourceProperty object for the given Resource object.
Here is the call graph for this function:

◆ createDefinedResourceRequestProperty()

createDefinedResourceRequestProperty ( ResourceRequest  $request,
  $name,
  $state = null 
)

Creates a ResourceRequestProperty object for a specified ResourceRequest object.

Parameters
ResourceRequest$requestThe resource request for which the ResourceRequestProperty object shall be built.
string$nameThe name of the property.
string$stateThe value of the property.
Exceptions
InvalidResourceCategoryExceptionIf this resource category doesn't match the resource category of the resource request object.
ResourcePropertyExceptionIf the name of the resource property is not defined for the resource category of the resource request.
Returns
ResourceProperty A ResourceProperty object for the given Resource object.
Here is the call graph for this function:

◆ createResource()

createResource (   $name = '',
  $description = '',
  $parent_id = '',
  $properties = [],
  $ignore_invalid = false 
)

Creates a resource object which belongs to this category. All properties which are mandatory for resources of this category are set to default values unless they are specified in the properties array.

Parameters
string$nameThe name of the new resource.
string$descriptionThe description of the new resource.
string$parent_idThe parent resource's ID (if any).
array$propertiesAn associative array in the form [$key] = $value containing the defined properties which can be set to this resource.
bool$ignore_invalidIf set to true, invalid values or invalid property names are ignored and no exception is thrown if an invalid value or property name occurs. Instead an invalid valud will be replaced with a default value and an invalid property name will not result in a set property.
Exceptions
InvalidResourceCategoryExceptionif the class_name attribute of the resource category contains a class name of a class which is not derived from the Resource class.
InvalidResourceExceptionif the resource cannot be stored.
ResourcePropertyExceptionIf the name of the resource property is not defined for this resource category.
Returns
New Resource object which is a member of this resource category.

◆ find()

static find (   $id)
static

returns new instance for given key when found in db, else null

Parameters
stringprimary key
Returns
SimpleORMap|NULL

Reimplemented from SimpleORMap.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findAll()

static findAll (   $force_reload = false)
static

Retrieves all resource categories from the database.

Returns
ResourceCategory[] An array of ResourceCategory objects or an empty array if no resource categories are defined.
Here is the caller graph for this function:

◆ getClassNameById()

static getClassNameById (   $category_id)
static

"Converts" a category-ID to a class name by looking up the class name of a specified category.

Parameters
string$category_idThe category-ID of the specified category.
Returns
string The class name field of the category which is specified by $category_id. In case no category could be found, an empty string is returned.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getGroupedPropertyDefinitions()

getGroupedPropertyDefinitions (   $excluded_properties = [])

This method returns the same properties as getPropertyDefinitions, but grouped and ordered by the property groups and the position of the property in that group.

Returns
Array An array with the group names as keys and the properties in the second array dimension. The structure of the array is as follows: [ group1 name => [ property1, property2, ... ], group2 name => [ ... ] ]
Here is the call graph for this function:

◆ getIconUrl()

getIconUrl ( )
Here is the call graph for this function:

◆ getPropertyDefinitions()

getPropertyDefinitions (   $excluded_properties = [])

Retrieves the definitions of all properties that are available for this resource category.

Parameters
string[]excluded_properties An array with the names of the properties that shall be excluded from the result set.
Returns
ResourcePropertyDefinition[] An array of resource property definitions.
Here is the call graph for this function:

◆ getRequestableProperties()

getRequestableProperties ( )

◆ hasProperty()

hasProperty (   $name = '',
  $type = null 
)

Determines if this resource category has a property with the specified name and type.

Parameters
string$nameThe requested property name.
string$typeThe requested property type (optional).
Returns
bool True, if a property with the specified name and type exists, false otherwise.
Here is the call graph for this function:

◆ setPropertyDefaultState()

setPropertyDefaultState ( ResourcePropertyDefinition  $definition)
protected

Returns the default state for a resource property. Depending on the type of the resource property different state is returned.

Parameters
ResourcePropertyDefinition$definitionThe definition of a resource property whose default state shall be returned.
Returns
mixed The default state for the property type, specified by the given property definition.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ userHasPropertyWritePermissions()

userHasPropertyWritePermissions (   $name = '',
User  $user,
  $resource = null 
)

Determines if the user has write permissions for the resource property specified by its name.

Parameters
stringThe name of the resource property definition.
User$userThe user whose permissions shall be checked.
Resource | null$resourceAn optional resource that shall be used to check for non-global permissions.
Exceptions
ResourcePropertyDefinitionExceptionIf no property is found.
Returns
bool True, if the user has write permissions, false otherwise.
Here is the call graph for this function:

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