Ejemplo n.º 1
0
 /**
  * Test report_log_supports_logstore.
  */
 public function test_report_participation_supports_logstore()
 {
     $logmanager = get_log_manager();
     $allstores = \core_component::get_plugin_list_with_class('logstore', 'log\\store');
     $supportedstores = array('logstore_legacy' => '\\logstore_legacy\\log\\store', 'logstore_standard' => '\\logstore_standard\\log\\store');
     // Make sure all supported stores are installed.
     $expectedstores = array_keys(array_intersect($allstores, $supportedstores));
     $stores = $logmanager->get_supported_logstores('report_outline');
     $stores = array_keys($stores);
     foreach ($expectedstores as $expectedstore) {
         $this->assertContains($expectedstore, $stores);
     }
 }
 /**
  * Returns an array of lock plugins for which we can add an instance.
  *
  * Suitable for use within an mform select element.
  *
  * @return array
  */
 public static function get_addable_lock_options()
 {
     $plugins = core_component::get_plugin_list_with_class('cachelock', '', 'lib.php');
     $options = array();
     $len = strlen('cachelock_');
     foreach ($plugins as $plugin => $class) {
         $method = "{$class}::can_add_instance";
         if (is_callable($method) && !call_user_func($method)) {
             // Can't add an instance of this plugin.
             continue;
         }
         $options[substr($plugin, $len)] = get_string('pluginname', $plugin);
     }
     return $options;
 }
Ejemplo n.º 3
0
/**
 * Get list of available import or export formats
 * @param string $type 'import' if import list, otherwise export list assumed
 * @return array sorted list of import/export formats available
 */
function get_import_export_formats($type)
{
    global $CFG;
    require_once $CFG->dirroot . '/question/format.php';
    $formatclasses = core_component::get_plugin_list_with_class('qformat', '', 'format.php');
    $fileformatname = array();
    foreach ($formatclasses as $component => $formatclass) {
        $format = new $formatclass();
        if ($type == 'import') {
            $provided = $format->provide_import();
        } else {
            $provided = $format->provide_export();
        }
        if ($provided) {
            list($notused, $fileformat) = explode('_', $component, 2);
            $fileformatnames[$fileformat] = get_string('pluginname', $component);
        }
    }
    core_collator::asort($fileformatnames);
    return $fileformatnames;
}
Ejemplo n.º 4
0
 /**
  * Intended for store management, do not use from reports.
  *
  * @return store[] Returns list of available store plugins.
  */
 public static function get_store_plugins()
 {
     return \core_component::get_plugin_list_with_class('logstore', 'log\\store');
 }
Ejemplo n.º 5
0
/**
 * Get a list of all the plugins of a given type that define a certain class
 * in a certain file. The plugin component names and class names are returned.
 *
 * @deprecated since 2.6, use core_component::get_plugin_list_with_class()
 *
 * @param string $plugintype the type of plugin, e.g. 'mod' or 'report'.
 * @param string $class the part of the name of the class after the
 *      frankenstyle prefix. e.g 'thing' if you are looking for classes with
 *      names like report_courselist_thing. If you are looking for classes with
 *      the same name as the plugin name (e.g. qtype_multichoice) then pass ''.
 * @param string $file the name of file within the plugin that defines the class.
 * @return array with frankenstyle plugin names as keys (e.g. 'report_courselist', 'mod_forum')
 *      and the class names as values (e.g. 'report_courselist_thing', 'qtype_multichoice').
 */
function get_plugin_list_with_class($plugintype, $class, $file)
{
    // NOTE: do not add any other debugging here, keep forever.
    return core_component::get_plugin_list_with_class($plugintype, $class, $file);
}
Ejemplo n.º 6
0
 /**
  * @return array of all the installed rule class names.
  */
 protected static function get_rule_classes()
 {
     return core_component::get_plugin_list_with_class('quizaccess', '', 'rule.php');
 }