Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Static Public Member Functions | Static Protected Member Functions | Static Protected Attributes | List of all members
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. More...
 
static get_cache_content ()
 Create cache file content. More...
 

Static Protected Member Functions

static fetch_component_source (string $key)
 Returns the component source content as loaded from /lib/components.json. More...
 
static fetch_core_version ()
 Get the core version. More...
 
static fetch_plugins ($plugintype, $fulldir)
 Returns list of plugins of given type in given directory. More...
 
static fetch_plugintypes ()
 Returns list of known plugin types. More...
 
static fetch_subsystems ()
 Returns list of core subsystems. More...
 
static fetch_subtypes ($ownerdir)
 Returns list of subtypes. More...
 
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. More...
 
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. More...
 
static init ()
 Initialise caches, always call before accessing self:: caches.
 
static is_developer ()
 Are we in developer debug mode? More...
 
static load_classes ($component, $fulldir, $namespace='')
 Find classes in directory and recurse to subdirs. More...
 
static psr_classloader ($class)
 Return the path to a class from our defined PSR-0 or PSR-4 standard namespaces on demand. More...
 

Static Protected Attributes

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 = array('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 More...
 
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. More...
 
static array $psr4namespaces
 associative array of PRS-4 namespaces and corresponding paths. More...
 
static array $subplugins = null
 subplugins
 
static array $subsystems = null
 cache of core subsystems
 
static array $supportsubplugins = array('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_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:
= array(
'Horde' => 'lib/horde/framework/Horde',
'Mustache' => 'lib/mustache/src/Mustache',
)

associative array of PSR-0 namespaces and corresponding paths.

◆ $psr4namespaces

array core_component::$psr4namespaces
staticprotected
Initial value:
= array(
'MaxMind' => 'lib/maxmind/MaxMind',
'GeoIp2' => 'lib/maxmind/GeoIp2',
'Sabberworm\\CSS' => 'lib/php-css-parser',
'MoodleHQ\\RTLCSS' => 'lib/rtlcss',
'ScssPhp\\ScssPhp' => 'lib/scssphp',
'Box\\Spout' => 'lib/spout/src/Spout',
'MatthiasMullie\\Minify' => 'lib/minify/matthiasmullie-minify/src/',
'MatthiasMullie\\PathConverter' => 'lib/minify/matthiasmullie-pathconverter/src/',
'IMSGlobal\LTI' => 'lib/ltiprovider/src',
'Phpml' => 'lib/mlbackend/php/phpml/src/Phpml',
'PHPMailer\\PHPMailer' => 'lib/phpmailer/src',
'RedeyeVentures\\GeoPattern' => 'lib/geopattern-php/GeoPattern',
'MongoDB' => 'cache/stores/mongodb/MongoDB',
'Firebase\\JWT' => 'lib/php-jwt/src',
)

associative array of PRS-4 namespaces and corresponding paths.


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