当前位置: 首页>>代码示例>>PHP>>正文


PHP core_collator::asort_objects_by_method方法代码示例

本文整理汇总了PHP中core_collator::asort_objects_by_method方法的典型用法代码示例。如果您正苦于以下问题:PHP core_collator::asort_objects_by_method方法的具体用法?PHP core_collator::asort_objects_by_method怎么用?PHP core_collator::asort_objects_by_method使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core_collator的用法示例。


在下文中一共展示了core_collator::asort_objects_by_method方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_asort_objects_by_method

 /**
  * Tests the static asort_objects_by_method method.
  */
 public function test_asort_objects_by_method()
 {
     $objects = array('b' => new string_test_class('ab'), 1 => new string_test_class('aa'), 0 => new string_test_class('cc'));
     $result = core_collator::asort_objects_by_method($objects, 'get_protected_name');
     $this->assertSame(array(1, 'b', 0), array_keys($objects));
     $this->assertSame(array('aa', 'ab', 'cc'), $this->get_ordered_names($objects, 'get_protected_name'));
     $this->assertTrue($result);
     $objects = array('b' => new string_test_class('a20'), 1 => new string_test_class('a1'), 0 => new string_test_class('a100'));
     $result = core_collator::asort_objects_by_method($objects, 'get_protected_name', core_collator::SORT_NATURAL);
     $this->assertSame(array(1, 'b', 0), array_keys($objects));
     $this->assertSame(array('a1', 'a20', 'a100'), $this->get_ordered_names($objects, 'get_protected_name'));
     $this->assertTrue($result);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:16,代码来源:collator_test.php

示例2: get_list_of_themes

/**
 * Returns a list of valid and compatible themes
 *
 * @return array
 */
function get_list_of_themes()
{
    global $CFG;
    $themes = array();
    if (!empty($CFG->themelist)) {
        // Use admin's list of themes.
        $themelist = explode(',', $CFG->themelist);
    } else {
        $themelist = array_keys(core_component::get_plugin_list("theme"));
    }
    foreach ($themelist as $key => $themename) {
        $theme = theme_config::load($themename);
        $themes[$themename] = $theme;
    }
    core_collator::asort_objects_by_method($themes, 'get_theme_name');
    return $themes;
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:22,代码来源:moodlelib.php

示例3: get_sorted_plugins

    /**
     * Sort plugins so enabled plugins are displayed first and all others are displayed in the end sorted by rank.
     * @return \core\plugininfo\media[]
     */
    protected function get_sorted_plugins() {
        $pluginmanager = core_plugin_manager::instance();

        $plugins = $pluginmanager->get_plugins_of_type('media');
        $enabledplugins = $pluginmanager->get_enabled_plugins('media');

        // Sort plugins so enabled plugins are displayed first and all others are displayed in the end sorted by rank.
        \core_collator::asort_objects_by_method($plugins, 'get_rank', \core_collator::SORT_NUMERIC);

        $order = array_values($enabledplugins);
        $order = array_merge($order, array_diff(array_reverse(array_keys($plugins)), $order));

        $sortedplugins = array();
        foreach ($order as $name) {
            $sortedplugins[$name] = $plugins[$name];
        }

        return $sortedplugins;
    }
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:23,代码来源:adminlib.php


注:本文中的core_collator::asort_objects_by_method方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。