/** * @return array of all the installed rule class names. */ protected static function get_rule_classes() { return get_plugin_list_with_class('quizaccess', '', 'rule.php'); }
/** * 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 = 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); } } collatorlib::asort($fileformatnames); return $fileformatnames; }
/** * Returns a lock instance ready for use. * * @param array $config * @return cache_lock_interface */ public function create_lock_instance(array $config) { if (!array_key_exists('name', $config) || !array_key_exists('type', $config)) { throw new coding_exception('Invalid cache lock instance provided'); } $name = $config['name']; $type = $config['type']; unset($config['name']); unset($config['type']); if ($this->lockplugins === null) { $this->lockplugins = get_plugin_list_with_class('cachelock', '', 'lib.php'); } if (!array_key_exists($type, $this->lockplugins)) { throw new coding_exception('Invalid cache lock type.'); } $class = $this->lockplugins[$type]; return new $class($name, $config); }
/** * 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 = 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; }