Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 20... Línea 20...
20
use renderer_base;
20
use renderer_base;
21
use section_info;
21
use section_info;
22
use core_courseformat\stateupdates;
22
use core_courseformat\stateupdates;
23
use core_courseformat\output\local\content\section\controlmenu;
23
use core_courseformat\output\local\content\section\controlmenu;
24
use core_courseformat\base as course_format;
24
use core_courseformat\base as course_format;
-
 
25
use stdClass;
Línea 25... Línea 26...
25
 
26
 
26
/**
27
/**
27
 * Section delegate base class.
28
 * Section delegate base class.
28
 *
29
 *
Línea 56... Línea 57...
56
        }
57
        }
57
        $classname = self::get_delegate_class_name($sectioninfo->component);
58
        $classname = self::get_delegate_class_name($sectioninfo->component);
58
        if ($classname === null) {
59
        if ($classname === null) {
59
            return null;
60
            return null;
60
        }
61
        }
61
        return new $classname($sectioninfo);
62
        $instance = new $classname($sectioninfo);
-
 
63
        if (!$instance->is_enabled()) {
-
 
64
            return null;
-
 
65
        }
-
 
66
        return $instance;
62
    }
67
    }
Línea 63... Línea 68...
63
 
68
 
64
    /**
69
    /**
65
     * Return the delgate class name of a plugin, if any.
70
     * Return the delgate class name of a plugin, if any.
Línea 82... Línea 87...
82
    public static function has_delegate_class(string $pluginname): bool {
87
    public static function has_delegate_class(string $pluginname): bool {
83
        return self::get_delegate_class_name($pluginname) !== null;
88
        return self::get_delegate_class_name($pluginname) !== null;
84
    }
89
    }
Línea 85... Línea 90...
85
 
90
 
-
 
91
    /**
-
 
92
     * Check if the delegate is enabled.
-
 
93
     *
-
 
94
     * Usually this happens when the delegate plugin is disabled.
-
 
95
     * @return bool
-
 
96
     */
-
 
97
    public function is_enabled(): bool {
-
 
98
        return true;
-
 
99
    }
-
 
100
 
86
    /**
101
    /**
87
     * Define the section final name.
102
     * Define the section final name.
88
     *
103
     *
89
     * This method can process the section name and return the validated new name.
104
     * This method can process the section name and return the validated new name.
90
     *
105
     *
Línea 122... Línea 137...
122
        controlmenu $controlmenu,
137
        controlmenu $controlmenu,
123
        renderer_base $output,
138
        renderer_base $output,
124
    ): ?action_menu {
139
    ): ?action_menu {
125
        return $controlmenu->get_default_action_menu($output);
140
        return $controlmenu->get_default_action_menu($output);
126
    }
141
    }
-
 
142
 
-
 
143
    /**
-
 
144
     * Get the parent section of the current delegated section if any.
-
 
145
     *
-
 
146
     * @return section_info|null
-
 
147
     */
-
 
148
    public function get_parent_section(): ?section_info {
-
 
149
        return null;
-
 
150
    }
-
 
151
 
-
 
152
    /**
-
 
153
     * Handler executed when a section has been updated.
-
 
154
     *
-
 
155
     * This method uses a record instead of a section_info object because
-
 
156
     * section updates can be done in batch and the course_info may not be yet updated.
-
 
157
     *
-
 
158
     * This method does not need to recalculate the section_info object.
-
 
159
     *
-
 
160
     * @param stdClass $sectionrecord the new section data
-
 
161
     */
-
 
162
    public function section_updated(stdClass $sectionrecord): void {
-
 
163
        // By default, do nothing.
-
 
164
    }
127
}
165
}