Elgg\Database\Plugins::getMaxPriority PHP Method

getMaxPriority() public method

Returns the highest priority of the plugins
public getMaxPriority ( ) : integer
return integer
    function getMaxPriority()
    {
        $db_prefix = elgg_get_config('dbprefix');
        $priority = $this->namespacePrivateSetting('internal', 'priority');
        $plugin_subtype = get_subtype_id('object', 'plugin');
        $q = "SELECT MAX(CAST(ps.value AS unsigned)) as max\n\t\t\tFROM {$db_prefix}entities e, {$db_prefix}private_settings ps\n\t\t\tWHERE ps.name = '{$priority}'\n\t\t\tAND ps.entity_guid = e.guid\n\t\t\tAND e.type = 'object' and e.subtype = {$plugin_subtype}";
        $data = get_data($q);
        if ($data) {
            $max = $data[0]->max;
        } else {
            $max = 1;
        }
        // can't have a priority of 0.
        return $max ? $max : 1;
    }