Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
repository_type Class Reference

This class is used to manage repository plugins. More...

Inheritance diagram for repository_type:
cacheable_object

Public Member Functions

 __construct ($typename='', $typeoptions=array(), $visible=true, $sortorder=0)
 repository_type constructor
 
 create ($silent=false)
 Create a repository type (the type name must not already exist)
 
 delete ($downloadcontents=false)
 Delete a repository_type (general options are removed from config_plugin table, and all instances are deleted)
 
 get_contextvisibility ($context)
 Return if the instance is visible in a context.
 
 get_options ()
 Return general options.
 
 get_readablename ()
 Return a human readable and user-friendly type name.
 
 get_sortorder ()
 Return order / position of display in the file picker.
 
 get_typename ()
 Get the type name (no whitespace) For a human readable name, use get_readablename()
 
 get_visible ()
 Return visibility.
 
 move_order ($move)
 Change order of the type with its adjacent upper or downer type (database fields are updated) Algorithm details:
 
 prepare_to_cache ()
 Prepares the repository type to be cached.
 
 update_options ($options=null)
 Update plugin options into the config_plugin table.
 
 update_visibility ($visible=null)
 

Static Public Member Functions

static wake_from_cache ($data)
 Restores repository type from cache.
 

Detailed Description

This class is used to manage repository plugins.

A repository_type is a repository plug-in. It can be Box.net, Flick-r, ... A repository type can be edited, sorted and hidden. It is mandatory for an administrator to create a repository type in order to be able to create some instances of this type. Coding note:

  • a repository_type object is mapped to the "repository" database table
  • "typename" attibut maps the "type" database field. It is unique.
  • general "options" for a repository type are saved in the config_plugin table
  • when you delete a repository, all instances are deleted, and general options are also deleted from database
  • When you create a type for a plugin that can't have multiple instances, a instance is automatically created.
License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

repository_type::__construct ( $typename = '',
$typeoptions = array(),
$visible = true,
$sortorder = 0 )

repository_type constructor

Parameters
int$typename
array$typeoptions
bool$visible
int$sortorder(don't really need set, it will be during create() call)

Member Function Documentation

◆ create()

repository_type::create ( $silent = false)

Create a repository type (the type name must not already exist)

Parameters
bool$silentthrow exception?
Return values
mixedreturn int if create successfully, return false if

◆ delete()

repository_type::delete ( $downloadcontents = false)

Delete a repository_type (general options are removed from config_plugin table, and all instances are deleted)

Parameters
bool$downloadcontentsdownload external contents if exist
Return values
bool

◆ get_contextvisibility()

repository_type::get_contextvisibility ( $context)

Return if the instance is visible in a context.

Todo
check if the context visibility has been overwritten by the plugin creator (need to create special functions to be overvwritten in repository class)
Parameters
stdClass$contextcontext
Return values
bool

◆ get_options()

repository_type::get_options ( )

Return general options.

Return values
arraythe general options

◆ get_readablename()

repository_type::get_readablename ( )

Return a human readable and user-friendly type name.

Return values
stringuser-friendly type name

◆ get_sortorder()

repository_type::get_sortorder ( )

Return order / position of display in the file picker.

Return values
int

◆ get_typename()

repository_type::get_typename ( )

Get the type name (no whitespace) For a human readable name, use get_readablename()

Return values
stringthe type name

◆ get_visible()

repository_type::get_visible ( )

Return visibility.

Return values
bool

◆ move_order()

repository_type::move_order ( $move)

Change order of the type with its adjacent upper or downer type (database fields are updated) Algorithm details:

  1. retrieve all types in an array. This array is sorted by sortorder, and the array keys start from 0 to X (incremented by 1)
  2. switch sortorder values of this type and its adjacent type
Parameters
string$move"up" or "down"

◆ prepare_to_cache()

repository_type::prepare_to_cache ( )

Prepares the repository type to be cached.

Implements method from cacheable_object interface.

Return values
array

Implements cacheable_object.

◆ update_options()

repository_type::update_options ( $options = null)

Update plugin options into the config_plugin table.

Parameters
array$options
Return values
bool

◆ update_visibility()

repository_type::update_visibility ( $visible = null)
  1. Change visibility to the value chosen
  2. Update the type
Parameters
bool$visible
Return values
bool

◆ wake_from_cache()

static repository_type::wake_from_cache ( $data)
static

Restores repository type from cache.

Implements method from cacheable_object interface.

Return values
array

Implements cacheable_object.


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