本文整理汇总了PHP中core_plugin_manager::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP core_plugin_manager::instance方法的具体用法?PHP core_plugin_manager::instance怎么用?PHP core_plugin_manager::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_plugin_manager
的用法示例。
在下文中一共展示了core_plugin_manager::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: definition
protected function definition()
{
global $CFG, $OUTPUT;
$mform =& $this->_form;
$indicators = $this->_customdata['indicators'];
$mform->addElement('hidden', 'id', $this->_customdata['id']);
$mform->setType('id', PARAM_INT);
// TODO: general course-level report settings.
$mform->addElement('header', 'general', get_string('pluginname', 'report_engagement'));
$mform->addElement('header', 'weightings', get_string('weighting', 'report_engagement'));
$mform->addElement('static', 'weightings_desc', get_string('indicator', 'report_engagement'));
$mform->addHelpButton('weightings_desc', 'indicator', 'report_engagement');
foreach ($indicators as $name => $path) {
$grouparray = array();
$grouparray[] =& $mform->createElement('text', "weighting_{$name}", '', array('size' => 3));
$grouparray[] =& $mform->createElement('static', '', '', '%');
$mform->addGroup($grouparray, "weight_group_{$name}", get_string('pluginname', "engagementindicator_{$name}"), ' ', false);
$mform->addHelpButton("weight_group_{$name}", 'pluginname', "engagementindicator_{$name}");
$mform->setType("weighting_{$name}", PARAM_FLOAT);
}
$pluginman = core_plugin_manager::instance();
$instances = get_plugin_list('engagementindicator');
foreach ($indicators as $name => $path) {
$plugin = $pluginman->get_plugin_info('engagementindicator_' . $name);
$file = "{$CFG->dirroot}/mod/engagement/indicator/{$name}/thresholds_form.php";
if (file_exists($file) && $plugin->is_enabled()) {
require_once $file;
$class = "engagementindicator_{$name}_thresholds_form";
$subform = new $class();
$mform->addElement('header', 'general', get_string('pluginname', "engagementindicator_{$name}"));
$subform->definition_inner($mform);
}
}
$this->add_action_buttons();
}
示例2: get_filter_options
/**
* Retrieve the list of available filter options.
*
* @return array An array whose keys are the valid options
* And whose values are the values to display
*/
public static function get_filter_options()
{
$manager = \core_plugin_manager::instance();
$themes = $manager->get_installed_plugins('theme');
$options = [];
foreach (array_keys($themes) as $themename) {
try {
$theme = \theme_config::load($themename);
} catch (Exception $e) {
// Bad theme, just skip it for now.
continue;
}
if ($themename !== $theme->name) {
// Obsoleted or broken theme, just skip for now.
continue;
}
if ($theme->hidefromselector) {
// The theme doesn't want to be shown in the theme selector and as theme
// designer mode is switched off we will respect that decision.
continue;
}
$options[$theme->name] = get_string('pluginname', "theme_{$theme->name}");
}
return $options;
}
示例3: __construct
/**
* Constructor.
* @throws Command_Exception.
*/
public function __construct()
{
global $DB, $STANDARD_PLUGIN_TYPES;
// Getting command description.
$cmd_name = vmoodle_get_string('cmdpluginsetupname', 'vmoodleadminset_plugins');
$cmd_desc = vmoodle_get_string('cmdpluginsetupdesc', 'vmoodleadminset_plugins');
$pm = \core_plugin_manager::instance();
$allplugins = $pm->get_plugins();
$pluginlist = array();
foreach ($allplugins as $type => $plugins) {
foreach ($plugins as $p) {
if (array_key_exists($type, $STANDARD_PLUGIN_TYPES)) {
$pluginlist[$type . '/' . $p->name] = $STANDARD_PLUGIN_TYPES[$type] . ' : ' . $p->displayname;
}
}
}
asort($pluginlist, SORT_STRING);
$plugin_param = new Command_Parameter('plugin', 'enum', vmoodle_get_string('pluginparamdesc', 'vmoodleadminset_plugins'), null, $pluginlist);
$states = array();
$states['enable'] = vmoodle_get_string('enable', 'vmoodleadminset_plugins');
$states['disable'] = vmoodle_get_string('disable', 'vmoodleadminset_plugins');
$state_param = new Command_Parameter('state', 'enum', vmoodle_get_string('pluginstateparamdesc', 'vmoodleadminset_plugins'), null, $states);
// Creating command.
parent::__construct($cmd_name, $cmd_desc, array($plugin_param, $state_param));
}
示例4: test_plugin_info
/**
* Tests the plugininfo class is present and working.
*/
public function test_plugin_info()
{
// This code will throw debugging information if the plugininfo class
// is missing. Unfortunately it doesn't actually cause the test to
// fail, but it's obvious when running test at least.
$pluginmanager = core_plugin_manager::instance();
$list = $pluginmanager->get_enabled_plugins('availability');
$this->assertEquals(array('completion', 'date', 'grade', 'group', 'grouping', 'profile'), array_keys($list));
}
示例5: definition
public function definition()
{
$mform = $this->_form;
/** @var \core\task\scheduled_task $task */
$task = $this->_customdata;
$plugininfo = core_plugin_manager::instance()->get_plugin_info($task->get_component());
$plugindisabled = $plugininfo && $plugininfo->is_enabled() === false && !$task->get_run_if_component_disabled();
$lastrun = $task->get_last_run_time() ? userdate($task->get_last_run_time()) : get_string('never');
$nextrun = $task->get_next_run_time();
if ($plugindisabled) {
$nextrun = get_string('plugindisabled', 'tool_task');
} else {
if ($task->get_disabled()) {
$nextrun = get_string('taskdisabled', 'tool_task');
} else {
if ($nextrun > time()) {
$nextrun = userdate($nextrun);
} else {
$nextrun = get_string('asap', 'tool_task');
}
}
}
$mform->addElement('static', 'lastrun', get_string('lastruntime', 'tool_task'), $lastrun);
$mform->addElement('static', 'nextrun', get_string('nextruntime', 'tool_task'), $nextrun);
$mform->addElement('text', 'minute', get_string('taskscheduleminute', 'tool_task'));
$mform->setType('minute', PARAM_RAW);
$mform->addHelpButton('minute', 'taskscheduleminute', 'tool_task');
$mform->addElement('text', 'hour', get_string('taskschedulehour', 'tool_task'));
$mform->setType('hour', PARAM_RAW);
$mform->addHelpButton('hour', 'taskschedulehour', 'tool_task');
$mform->addElement('text', 'day', get_string('taskscheduleday', 'tool_task'));
$mform->setType('day', PARAM_RAW);
$mform->addHelpButton('day', 'taskscheduleday', 'tool_task');
$mform->addElement('text', 'month', get_string('taskschedulemonth', 'tool_task'));
$mform->setType('month', PARAM_RAW);
$mform->addHelpButton('month', 'taskschedulemonth', 'tool_task');
$mform->addElement('text', 'dayofweek', get_string('taskscheduledayofweek', 'tool_task'));
$mform->setType('dayofweek', PARAM_RAW);
$mform->addHelpButton('dayofweek', 'taskscheduledayofweek', 'tool_task');
$mform->addElement('advcheckbox', 'disabled', get_string('disabled', 'tool_task'));
$mform->addHelpButton('disabled', 'disabled', 'tool_task');
$mform->addElement('advcheckbox', 'resettodefaults', get_string('resettasktodefaults', 'tool_task'));
$mform->addHelpButton('resettodefaults', 'resettasktodefaults', 'tool_task');
$mform->disabledIf('minute', 'resettodefaults', 'checked');
$mform->disabledIf('hour', 'resettodefaults', 'checked');
$mform->disabledIf('day', 'resettodefaults', 'checked');
$mform->disabledIf('dayofweek', 'resettodefaults', 'checked');
$mform->disabledIf('month', 'resettodefaults', 'checked');
$mform->disabledIf('disabled', 'resettodefaults', 'checked');
$mform->addElement('hidden', 'task', get_class($task));
$mform->setType('task', PARAM_RAW);
$mform->addElement('hidden', 'action', 'edit');
$mform->setType('action', PARAM_ALPHANUMEXT);
$this->add_action_buttons(true, get_string('savechanges'));
// Do not use defaults for existing values, the set_data() is the correct way.
$this->set_data(\core\task\manager::record_from_scheduled_task($task));
}
示例6: execute
public function execute()
{
$manager = \core_plugin_manager::instance();
$types = $manager->get_plugin_types();
ksort($types);
foreach ($types as $type => $directory) {
echo $type . "," . $directory . "\n";
}
}
示例7: scheduled_tasks_table
/**
* This function will render one beautiful table with all the scheduled tasks.
*
* @param \core\task\scheduled_task[] $tasks - list of all scheduled tasks.
* @return string HTML to output.
*/
public function scheduled_tasks_table($tasks)
{
global $CFG;
$table = new html_table();
$table->head = array(get_string('name'), get_string('component', 'tool_task'), get_string('edit'), get_string('lastruntime', 'tool_task'), get_string('nextruntime', 'tool_task'), get_string('taskscheduleminute', 'tool_task'), get_string('taskschedulehour', 'tool_task'), get_string('taskscheduleday', 'tool_task'), get_string('taskscheduledayofweek', 'tool_task'), get_string('taskschedulemonth', 'tool_task'), get_string('faildelay', 'tool_task'), get_string('default', 'tool_task'));
$table->attributes['class'] = 'admintable generaltable';
$data = array();
$yes = get_string('yes');
$no = get_string('no');
$never = get_string('never');
$asap = get_string('asap', 'tool_task');
$disabled = get_string('disabled', 'tool_task');
foreach ($tasks as $task) {
$customised = $task->is_customised() ? $no : $yes;
$lastrun = $task->get_last_run_time() ? userdate($task->get_last_run_time()) : $never;
$nextrun = $task->get_next_run_time();
if ($task->get_disabled()) {
$nextrun = $disabled;
} else {
if ($nextrun > time()) {
$nextrun = userdate($nextrun);
} else {
$nextrun = $asap;
}
}
if (empty($CFG->preventscheduledtaskchanges)) {
$configureurl = new moodle_url('/admin/tool/task/scheduledtasks.php', array('action' => 'edit', 'task' => get_class($task)));
$editlink = $this->action_icon($configureurl, new pix_icon('t/edit', get_string('edittaskschedule', 'tool_task', $task->get_name())));
} else {
$editlink = $this->render(new pix_icon('t/locked', get_string('scheduledtaskchangesdisabled', 'tool_task')));
}
$namecell = new html_table_cell($task->get_name() . "\n" . html_writer::tag('span', '\\' . get_class($task), array('class' => 'task-class')));
$namecell->header = true;
$component = $task->get_component();
list($type, $plugin) = core_component::normalize_component($component);
if ($type === 'core') {
$componentcell = new html_table_cell(get_string('corecomponent', 'tool_task'));
} else {
if ($plugininfo = core_plugin_manager::instance()->get_plugin_info($component)) {
$plugininfo->init_display_name();
$componentcell = new html_table_cell($plugininfo->displayname);
} else {
$componentcell = new html_table_cell($component);
}
}
$row = new html_table_row(array($namecell, $componentcell, new html_table_cell($editlink), new html_table_cell($lastrun), new html_table_cell($nextrun), new html_table_cell($task->get_minute()), new html_table_cell($task->get_hour()), new html_table_cell($task->get_day()), new html_table_cell($task->get_day_of_week()), new html_table_cell($task->get_month()), new html_table_cell($task->get_fail_delay()), new html_table_cell($customised)));
if ($task->get_disabled()) {
$row->attributes['class'] = 'disabled';
}
$data[] = $row;
}
$table->data = $data;
return html_writer::table($table);
}
示例8: create_target
/**
* Returns a target object, given a name.
*/
public static function create_target($name, $identifier = '')
{
// Sanity check.
$pluginman = \core_plugin_manager::instance();
$plugins = $pluginman->get_plugins_of_type('cattarget');
if (!isset($plugins[$name]) || $plugins[$name]->is_enabled() === false) {
throw new \moodle_exception("Invalid target.");
}
$target = "\\cattarget_{$name}\\{$name}";
return new $target($identifier);
}
示例9: create_rule
/**
* Return a rule object, given a name.
*/
public static function create_rule($name, $config = null)
{
// Sanity check.
$pluginman = \core_plugin_manager::instance();
$plugins = $pluginman->get_plugins_of_type('catrule');
if (!isset($plugins[$name]) || $plugins[$name]->is_enabled() === false) {
throw new \moodle_exception("Invalid rule.");
}
$ruletype = "\\catrule_{$name}\\{$name}";
return new $ruletype($config);
}
示例10: create_activity
/**
* Return a activity object, given a name.
*/
public static function create_activity($name, $data = '')
{
// Sanity check.
$pluginman = \core_plugin_manager::instance();
$plugins = $pluginman->get_plugins_of_type('catactivity');
if (!isset($plugins[$name]) || $plugins[$name]->is_enabled() === false) {
throw new \moodle_exception("Invalid activity.");
}
$activity = "\\catactivity_{$name}\\{$name}";
return new $activity($data);
}
示例11: create_datatype
/**
* Return a datatype object, given a name.
*/
public static function create_datatype($name, $data = '')
{
// Sanity check.
$pluginman = \core_plugin_manager::instance();
$plugins = $pluginman->get_plugins_of_type('catdatatype');
if (!isset($plugins[$name]) || $plugins[$name]->is_enabled() === false) {
throw new \moodle_exception("Invalid datatype.");
}
$datatype = "\\catdatatype_{$name}\\{$name}";
$datatype = new $datatype($data);
$datatype->name = $name;
return $datatype;
}
示例12: get_rules
/**
* Get a list of valid rules.
*
* @return array [string]
* @throws \invalid_parameter_exception
*/
public static function get_rules()
{
$pluginman = \core_plugin_manager::instance();
$plugins = $pluginman->get_plugins_of_type('catrule');
$rules = array();
foreach ($plugins as $plugin) {
if ($plugin->is_enabled() === false) {
continue;
}
$rules[$plugin->name] = get_string('prettyname', "{$plugin->type}_{$plugin->name}");
}
return $rules;
}
示例13: get_supported_activities
/**
* Return a list of datatypes this target supports.
*
* @return array An array of valid datatypes.
*/
public function get_supported_activities()
{
$pluginman = \core_plugin_manager::instance();
$plugins = $pluginman->get_plugins_of_type('catactivity');
$rules = array();
foreach ($plugins as $plugin) {
if ($plugin->is_enabled() === false) {
continue;
}
$rules[] = $plugin->name;
}
return $rules;
}
示例14: get_instantiable_plugins
/**
* Finds all plugins the user can instantiate in the context. The result may include missing plugins.
* Calls {@link \mod_dataform\plugininfo\dataformview::is_instantiable()}.
* Returns an associative list $pluginname => $pluginname, or null if no plugin is instantiable.
*
* @param context $context Either course or dataform (module) context.
* @return array|null
*/
public static function get_instantiable_plugins($context)
{
$return = array();
if (!($plugins = \core_plugin_manager::instance()->get_plugins_of_type('dataformview'))) {
return null;
}
foreach ($plugins as $name => $plugin) {
if ($plugin->is_instantiable($context)) {
$return[$name] = $name;
}
}
return $return;
}
示例15: get_services
public static function get_services($plugin)
{
$services = array();
$pluginmanager = \core_plugin_manager::instance();
$plugininfo = $pluginmanager->get_plugin_info($plugin);
if (is_null($plugininfo)) {
return;
}
$defsfile = $plugininfo->rootdir . '/db/local_nagios.php';
if (!file_exists($defsfile)) {
return;
}
include $defsfile;
return $services;
}