. namespace core_courseformat; use section_info; /** * Section delegate base class. * * Plugins using delegate sections must extend this class into * their PLUGINNAME\courseformat\sectiondelegate class. * * @package core_courseformat * @copyright 2023 Ferran Recio * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ abstract class sectiondelegate { /** * Constructor. * @param section_info $sectioninfo */ public function __construct( protected section_info $sectioninfo ) { } /** * Get the section info instance if available. * * @param section_info $sectioninfo * @return section_info|null */ public static function instance(section_info $sectioninfo): ?self { if (empty($sectioninfo->component)) { return null; } $classname = $sectioninfo->component . '\courseformat\sectiondelegate'; if (!class_exists($classname)) { return null; } return new $classname($sectioninfo); } }