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

Collection of components related methods. More...

Static Public Member Functions

static classloader ($classname)
 Class loader for Frankenstyle named classes in standard locations.
 
static get_cache_content ()
 Create cache file content.
 

Static Protected Member Functions

static fetch_apis ()
 Returns list of core APIs.
 
static fetch_component_source (string $key)
 Returns the component source content as loaded from /lib/components.json.
 
static fetch_core_version ()
 Get the core version.
 
static fetch_plugins ($plugintype, $fulldir)
 Returns list of plugins of given type in given directory.
 
static fetch_plugintypes ()
 Returns list of known plugin types.
 
static fetch_subsystems ()
 Returns list of core subsystems.
 
static fetch_subtypes ($ownerdir)
 Returns list of subtypes.
 
static fill_all_caches ()
 Fill all caches.
 
static fill_classmap_cache ()
 Find all classes that can be autoloaded including frankenstyle namespaces.
 
static fill_filemap_cache ()
 Fills up the cache defining what plugins have certain files.
 
static get_class_file ($class, $prefix, $path, $separators)
 Return the path to the class based on the given namespace prefix and path it corresponds to.
 
static init ()
 Initialise caches, always call before accessing self:: caches.
 
static is_developer ()
 Are we in developer debug mode?
 
static load_classes ($component, $fulldir, $namespace='')
 Find classes in directory and recurse to subdirs.
 
static psr_classloader ($class)
 Return the path to a class from our defined PSR-0 or PSR-4 standard namespaces on demand.
 

Static Protected Attributes

static array $apis = null
 cache of core APIs
 
static array $classmap = null
 list of all known classes that can be autoloaded
 
static array $classmaprenames = null
 list of all classes that have been renamed to be autoloaded
 
static object $componentsource = null
 JSON source of the component data.
 
static array $filemap = null
 list of some known files that can be included.
 
static array $filestomap = ['lib.php', 'settings.php']
 list of the files to map.
 
static array $ignoreddirs
 list of ignored directories in plugin type roots - watch out for auth/db exception
 
static array $parents = null
 subplugin type parents
 
static array $plugins = null
 cache of plugin locations
 
static array $plugintypes = null
 cache of plugin types
 
static array $psr0namespaces
 associative array of PSR-0 namespaces and corresponding paths.
 
static array< string|array< string > > $psr4namespaces
 associative array of PRS-4 namespaces and corresponding paths.
 
static array $subplugins = null
 subplugins
 
static array $subsystems = null
 cache of core subsystems
 
static array $supportsubplugins = ['mod', 'editor', 'tool', 'local']
 list plugin types that support subplugins, do not add more here unless absolutely necessary
 
static int float $version = null
 core version.
 

Detailed Description

Collection of components related methods.

Member Function Documentation

◆ classloader()

static core_component::classloader ( $classname)
static

Class loader for Frankenstyle named classes in standard locations.

Frankenstyle namespaces are supported.

The expected location for core classes is: 1/ core_xx_yy_zz ---> lib/classes/xx_yy_zz.php 2/ core\xx_yy_zz ---> lib/classes/xx_yy_zz.php 3/ core\xx\yy_zz ---> lib/classes/xx/yy_zz.php

The expected location for plugin classes is: 1/ mod_name_xx_yy_zz ---> mod/name/classes/xx_yy_zz.php 2/ mod_name\xx_yy_zz ---> mod/name/classes/xx_yy_zz.php 3/ mod_name\xx\yy_zz ---> mod/name/classes/xx/yy_zz.php

Parameters
string$classname

◆ fetch_apis()

static core_component::fetch_apis ( )
staticprotected

Returns list of core APIs.

Return values
stdClass[]

◆ fetch_component_source()

static core_component::fetch_component_source ( string $key)
staticprotected

Returns the component source content as loaded from /lib/components.json.

Return values
array

◆ fetch_core_version()

static core_component::fetch_core_version ( )
staticprotected

Get the core version.

In order for this to work properly, opcache should be reset beforehand.

Return values
floatcore version.

◆ fetch_plugins()

static core_component::fetch_plugins ( $plugintype,
$fulldir )
staticprotected

Returns list of plugins of given type in given directory.

Parameters
string$plugintype
string$fulldir
Return values
array

◆ fetch_plugintypes()

static core_component::fetch_plugintypes ( )
staticprotected

Returns list of known plugin types.

Return values
array

◆ fetch_subsystems()

static core_component::fetch_subsystems ( )
staticprotected

Returns list of core subsystems.

Return values
array

◆ fetch_subtypes()

static core_component::fetch_subtypes ( $ownerdir)
staticprotected

Returns list of subtypes.

Parameters
string$ownerdir
Return values
array

◆ fill_filemap_cache()

static core_component::fill_filemap_cache ( )
staticprotected

Fills up the cache defining what plugins have certain files.

See also
self\get_plugin_list_with_file
Return values
void

◆ get_cache_content()

static core_component::get_cache_content ( )
static

Create cache file content.

this is intended for $CFG->alternative_component_cache only.

Return values
string

◆ get_class_file()

static core_component::get_class_file ( $class,
$prefix,
$path,
$separators )
staticprotected

Return the path to the class based on the given namespace prefix and path it corresponds to.

Will return the path even if the file does not exist. Check the file esists before requiring.

Parameters
string$classthe name of the class.
string$prefixThe namespace prefix used to identify the base directory of the source files.
string$pathThe relative path to the base directory of the source files.
string[]$separatorsThe characters that should be used for separating.
Return values
string|boolThe full path to the file defining the class. Or false if it could not be resolved.

◆ is_developer()

static core_component::is_developer ( )
staticprotected

Are we in developer debug mode?

Note: You need to set "$CFG->debug = (E_ALL | E_STRICT);" in config.php, the reason is we need to use this before we setup DB connection or caches for CFG.

Return values
bool

◆ load_classes()

static core_component::load_classes ( $component,
$fulldir,
$namespace = '' )
staticprotected

Find classes in directory and recurse to subdirs.

Parameters
string$component
string$fulldir
string$namespace

◆ psr_classloader()

static core_component::psr_classloader ( $class)
staticprotected

Return the path to a class from our defined PSR-0 or PSR-4 standard namespaces on demand.

Only returns paths to files that exist.

Adapated from http://www.php-fig.org/psr/psr-4/examples/ and made PSR-0 compatible.

Parameters
string$classthe name of the class.
Return values
string|boolThe full path to the file defining the class. Or false if it could not be resolved or does not exist.

Member Data Documentation

◆ $ignoreddirs

array core_component::$ignoreddirs
staticprotected
Initial value:
= [
'CVS' => true,
'_vti_cnf' => true,
'amd' => true,
'classes' => true,
'db' => true,
'fonts' => true,
'lang' => true,
'pix' => true,
'simpletest' => true,
'templates' => true,
'tests' => true,
'yui' => true,
]

list of ignored directories in plugin type roots - watch out for auth/db exception

◆ $psr0namespaces

array core_component::$psr0namespaces
staticprotected
Initial value:
= [
'Mustache' => 'lib/mustache/src/Mustache',
'CFPropertyList' => 'lib/plist/classes/CFPropertyList',
]

associative array of PSR-0 namespaces and corresponding paths.


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