public static function load_default_models_for_component(string $componentname): array {

        $dir = \core_component::get_component_directory($componentname);

        if (!$dir) {
            // This is either an invalid component, or a core subsystem without its own root directory.
            return [];
        }

        $file = $dir . '/' . self::ANALYTICS_FILENAME;

        if (!is_readable($file)) {
            return [];
        }

        $models = null;
        include($file);

        if (!isset($models) || !is_array($models) || empty($models)) {
            return [];
        }

        foreach ($models as &$model) {
            if (!isset($model['enabled'])) {
                $model['enabled'] = false;
            } else {
                $model['enabled'] = clean_param($model['enabled'], PARAM_BOOL);
            }
        }

        static::validate_models_declaration($models);

        return $models;
    }
public static function load_default_models_for_component(string $componentname): array {

        $dir = \core_component::get_component_directory($componentname);

        if (!$dir) {
            // This is either an invalid component, or a core subsystem without its own root directory.
            return [];
        }

        $file = $dir . '/' . self::ANALYTICS_FILENAME;

        if (!is_readable($file)) {
            return [];
        }

        $models = null;
        include($file);

        if (!isset($models) || !is_array($models) || empty($models)) {
            return [];
        }

        foreach ($models as &$model) {
            if (!isset($model['enabled'])) {
                $model['enabled'] = false;
            } else {
                $model['enabled'] = clean_param($model['enabled'], PARAM_BOOL);
            }
        }

        static::validate_models_declaration($models);

        return $models;
    }
public static function load_default_models_for_component ( string $ componentname ) : array { $ dir = \ core_component :: get_component_directory ( $ componentname ) ; if ( ! $ dir ) { // This is either an invalid component, or a core subsystem without its own root directory. return [ ] ; } $ file = $ dir . '/' . self :: ANALYTICS_FILENAME ; if ( ! is_readable ( $ file ) ) { return [ ] ; } $ models = null ; include ( $ file ) ; if ( ! isset ( $ models ) || ! is_array ( $ models ) || empty ( $ models ) ) { return [ ] ; } foreach ( $ models as & $ model ) { if ( ! isset ( $ model [ 'enabled' ] ) ) { $ model [ 'enabled' ] = false ; } else { $ model [ 'enabled' ] = clean_param ( $ model [ 'enabled' ] , PARAM_BOOL ) ; } } static :: validate_models_declaration ( $ models ) ; return $ models ; }
Return the list of models declared by the given component.

@param string $componentname The name of the component to load models for.
@throws \coding_exception Exception thrown in case of invalid syntax.
@return array The $models description array.
Return the list of models declared by the given component .