本文整理汇总了PHP中core_component::get_component_classes_in_namespace方法的典型用法代码示例。如果您正苦于以下问题:PHP core_component::get_component_classes_in_namespace方法的具体用法?PHP core_component::get_component_classes_in_namespace怎么用?PHP core_component::get_component_classes_in_namespace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_component
的用法示例。
在下文中一共展示了core_component::get_component_classes_in_namespace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_get_component_classes_int_namespace
public function test_get_component_classes_int_namespace()
{
// Unexisting.
$this->assertCount(0, core_component::get_component_classes_in_namespace('core_unexistingcomponent', 'something'));
$this->assertCount(0, core_component::get_component_classes_in_namespace('auth_cas', 'something'));
// Prefix with backslash if it doesn\'t come prefixed.
$this->assertCount(1, core_component::get_component_classes_in_namespace('auth_cas', 'task'));
$this->assertCount(1, core_component::get_component_classes_in_namespace('auth_cas', '\\task'));
// Core as a component works.
$this->assertCount(7, core_component::get_component_classes_in_namespace('core', 'update'));
// Multiple levels.
$this->assertCount(5, core_component::get_component_classes_in_namespace('core_user', '\\output\\myprofile\\'));
$this->assertCount(5, core_component::get_component_classes_in_namespace('core_user', '\\output\\myprofile'));
}
示例2: get_all_filters
/**
* Get a list of all possible filters.
*
* @return array
*/
public static function get_all_filters()
{
$filters = \core_component::get_component_classes_in_namespace('tool_usertours', 'local\\filter');
$filters = array_keys($filters);
$filters = array_filter($filters, function ($filterclass) {
$rc = new \ReflectionClass($filterclass);
return $rc->isInstantiable();
});
return $filters;
}
示例3: get_search_areas_list
/**
* Return the list of available search areas.
*
* @param bool $enabled Return only the enabled ones.
* @return \core_search\area\base[]
*/
public static function get_search_areas_list($enabled = false)
{
// Two different arrays, we don't expect these arrays to be big.
if (!$enabled && static::$allsearchareas !== null) {
return static::$allsearchareas;
} else {
if ($enabled && static::$enabledsearchareas !== null) {
return static::$enabledsearchareas;
}
}
$searchareas = array();
$plugintypes = \core_component::get_plugin_types();
foreach ($plugintypes as $plugintype => $unused) {
$plugins = \core_component::get_plugin_list($plugintype);
foreach ($plugins as $pluginname => $pluginfullpath) {
$componentname = $plugintype . '_' . $pluginname;
$searchclasses = \core_component::get_component_classes_in_namespace($componentname, 'search');
foreach ($searchclasses as $classname => $classpath) {
$areaname = substr(strrchr($classname, '\\'), 1);
$areaid = static::generate_areaid($componentname, $areaname);
$searchclass = new $classname();
if (!$enabled || $enabled && $searchclass->is_enabled()) {
$searchareas[$areaid] = $searchclass;
}
}
}
}
$subsystems = \core_component::get_core_subsystems();
foreach ($subsystems as $subsystemname => $subsystempath) {
$componentname = 'core_' . $subsystemname;
$searchclasses = \core_component::get_component_classes_in_namespace($componentname, 'search');
foreach ($searchclasses as $classname => $classpath) {
$areaname = substr(strrchr($classname, '\\'), 1);
$areaid = static::generate_areaid($componentname, $areaname);
$searchclass = new $classname();
if (!$enabled || $enabled && $searchclass->is_enabled()) {
$searchareas[$areaid] = $searchclass;
}
}
}
// Cache results.
if ($enabled) {
static::$enabledsearchareas = $searchareas;
} else {
static::$allsearchareas = $searchareas;
}
return $searchareas;
}
示例4: test_get_component_classes_int_namespace
public function test_get_component_classes_int_namespace()
{
// Unexisting.
$this->assertCount(0, core_component::get_component_classes_in_namespace('core_unexistingcomponent', 'something'));
$this->assertCount(0, core_component::get_component_classes_in_namespace('auth_cas', 'something'));
// Matches the last namespace level name not partials.
$this->assertCount(0, core_component::get_component_classes_in_namespace('auth_cas', 'tas'));
$this->assertCount(0, core_component::get_component_classes_in_namespace('core_user', 'course'));
$this->assertCount(0, core_component::get_component_classes_in_namespace('mod_forum', 'output\\emaildigest'));
$this->assertCount(0, core_component::get_component_classes_in_namespace('mod_forum', '\\output\\emaildigest'));
$this->assertCount(2, core_component::get_component_classes_in_namespace('mod_forum', 'output\\email'));
$this->assertCount(2, core_component::get_component_classes_in_namespace('mod_forum', '\\output\\email'));
$this->assertCount(2, core_component::get_component_classes_in_namespace('mod_forum', 'output\\email\\'));
$this->assertCount(2, core_component::get_component_classes_in_namespace('mod_forum', '\\output\\email\\'));
// Prefix with backslash if it doesn\'t come prefixed.
$this->assertCount(1, core_component::get_component_classes_in_namespace('auth_cas', 'task'));
$this->assertCount(1, core_component::get_component_classes_in_namespace('auth_cas', '\\task'));
// Core as a component works, the funcion can normalise the component name.
$this->assertCount(7, core_component::get_component_classes_in_namespace('core', 'update'));
$this->assertCount(7, core_component::get_component_classes_in_namespace('', 'update'));
$this->assertCount(7, core_component::get_component_classes_in_namespace('moodle', 'update'));
// Multiple levels.
$this->assertCount(5, core_component::get_component_classes_in_namespace('core_user', '\\output\\myprofile\\'));
$this->assertCount(5, core_component::get_component_classes_in_namespace('core_user', 'output\\myprofile\\'));
$this->assertCount(5, core_component::get_component_classes_in_namespace('core_user', '\\output\\myprofile'));
$this->assertCount(5, core_component::get_component_classes_in_namespace('core_user', 'output\\myprofile'));
// Without namespace it returns classes/ classes.
$this->assertCount(2, core_component::get_component_classes_in_namespace('tool_mobile', ''));
$this->assertCount(1, core_component::get_component_classes_in_namespace('tool_filetypes'));
}