Stud.IP  4.0
 All Data Structures Namespaces Files Functions Variables Groups
ResourceCategory Class Reference
Inheritance diagram for ResourceCategory:
SimpleORMap

Public Member Functions

 hasResources ()
 
 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 (string $name, User $user, $resource=null)
 
 getIcon ($role=Icon::ROLE_INFO)
 
- 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 exists ($id)
 
static countBySql ($sql= '1', $params=[])
 
static create ($data)
 
static buildExisting ($data)
 
static import ($data)
 
static findBySQL ($sql, $params=[])
 
static findOneBySQL ($where, $params=[])
 
static findThru ($foreign_key_value, $options)
 
static findEachBySQL ($callable, $sql, $params=[])
 
static findMany ($pks=[], $order= '', $order_params=[])
 
static findEachMany ($callable, $pks=[], $order= '', $order_params=[])
 
static findAndMapBySQL ($callable, $where, $params=[])
 
static findAndMapMany ($callable, $pks=[], $order= '', $order_params=[])
 
static deleteBySQL ($where, $params=[])
 
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)
 
 cbAutoIncrementColumn ($type)
 
 cbAutoKeyCreation ()
 
 cbNotificationMapper ($cb_type)
 
 cbAfterInitialize ($cb_type)
 
 setSerializedValue ($field, $value)
 
 setI18nValue ($field, $value)
 

Static Protected Member Functions

static configure ($config=[])
 
- Static Protected Member Functions inherited from SimpleORMap
static db_table ()
 
static db_fields ()
 
static pk ()
 
static default_values ()
 
static serialized_fields ()
 
static alias_fields ()
 
static i18n_fields ()
 
static additional_fields ()
 
static has_many ()
 
static has_one ()
 
static belongs_to ()
 
static has_and_belongs_to_many ()
 
static registered_callbacks ()
 
static known_slots ()
 
static notification_map ()
 
static getter_setter_map ()
 
static configure ($config=[])
 
static config ($key)
 
static registerCallback ($types, $cb)
 
static unregisterCallback ($types, $cb)
 

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 = []
 
 $content_db = []
 
 $is_new = true
 
 $is_deleted = false
 
 $relations = []
 
 $additional_data = []
 
- Static Protected Attributes inherited from SimpleORMap
static $config = []
 
static $reserved_slots = ['value','newid','iterator','tablemetadata', 'relationvalue','wherequery','relationoptions','data','new','id']
 
static $performs_batch_operation = false
 

Member Function Documentation

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.
string$write_permission_level
Returns
ResourceCategoryProperty The created or updated resource category property.
Exceptions
ResourcePropertyDefinitionExceptionIf the property definition cannot be created.
ResourcePropertyExceptionIf the property cannot be created.
static configure (   $config = [])
staticprotected
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.
Returns
ResourceProperty A ResourceProperty object for the given Resource object.
Exceptions
ResourcePropertyExceptionIf the name of the resource property is not defined for this resource category.
InvalidResourceCategoryExceptionIf this resource category doesn't match the category of the resource object.
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.
Returns
ResourceRequestProperty A ResourceProperty object for the given Resource object.
Exceptions
ResourcePropertyExceptionIf the name of the resource property is not defined for the resource category of the resource request.
InvalidResourceCategoryExceptionIf this resource category doesn't match the resource category of the resource request object.
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.
Returns
Resource New Resource object which is a member of this resource category.
Exceptions
InvalidResourceExceptionif the resource cannot be stored.
ResourcePropertyExceptionIf the name of the resource property is not defined for this resource category.
InvalidResourceCategoryExceptionif the class_name attribute of the resource category contains a class name of a class which is not derived from the Resource class.
static find (   $id)
static
static findAll (   $force_reload = false)
static

Retrieves all resource categories from the database.

Parameters
bool$force_reload
Returns
ResourceCategory[] An array of ResourceCategory objects or an empty array if no resource categories are defined.
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.
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 => [ ... ] ]
getIcon (   $role = Icon::ROLE_INFO)

Get the icon of a category

Parameters
string$role
Returns
Icon
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.
getRequestableProperties ( )
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.
hasResources ( )
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.
userHasPropertyWritePermissions ( string  $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.
Returns
bool True, if the user has write permissions, false otherwise.
Exceptions
ResourcePropertyDefinitionExceptionIf no property is found.

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