Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 82... Línea 82...
82
     * Create a new Container Instance.
82
     * Create a new Container Instance.
83
     *
83
     *
84
     * @return ContainerInterface
84
     * @return ContainerInterface
85
     */
85
     */
86
    protected static function create_container(): ContainerInterface {
86
    protected static function create_container(): ContainerInterface {
87
        global $CFG, $DB;
87
        global $CFG;
Línea 88... Línea 88...
88
 
88
 
89
        // PHP Does not support function autoloading. We must manually include the file.
89
        // PHP Does not support function autoloading. We must manually include the file.
Línea 90... Línea 90...
90
        require_once("{$CFG->libdir}/php-di/php-di/src/functions.php");
90
        require_once("{$CFG->libdir}/php-di/php-di/src/functions.php");
Línea 111... Línea 111...
111
        $builder->addDefinitions([
111
        $builder->addDefinitions([
112
            // The hook manager should be in the container.
112
            // The hook manager should be in the container.
113
            \core\hook\manager::class => $hookmanager,
113
            \core\hook\manager::class => $hookmanager,
Línea 114... Línea 114...
114
 
114
 
115
            // The database.
115
            // The database.
-
 
116
            \moodle_database::class => function(): \moodle_database {
-
 
117
                global $DB;
-
 
118
 
-
 
119
                return $DB;
Línea 116... Línea 120...
116
            \moodle_database::class => $DB,
120
            },
117
 
121
 
Línea 118... Línea 122...
118
            // The string manager.
122
            // The string manager.
119
            \core_string_manager::class => fn() => get_string_manager(),
123
            \core_string_manager::class => fn() => get_string_manager(),
120
 
124
 
-
 
125
            // The Moodle Clock implementation, which itself is an extension of PSR-20.
-
 
126
            // Alias the PSR-20 clock interface to the Moodle clock. They are compatible.
-
 
127
            \core\clock::class => function () {
-
 
128
                global $CFG;
-
 
129
 
-
 
130
                // Web requests to the Behat site can use a frozen clock if configured.
-
 
131
                if (defined('BEHAT_SITE_RUNNING') && !empty($CFG->behat_frozen_clock)) {
-
 
132
                    require_once($CFG->libdir . '/testing/classes/frozen_clock.php');
-
 
133
                    return new \frozen_clock((int)$CFG->behat_frozen_clock);
121
            // The Moodle Clock implementation, which itself is an extension of PSR-20.
134
                }
-
 
135
                return new \core\system_clock();
-
 
136
            },
-
 
137
            \Psr\Clock\ClockInterface::class => \DI\get(\core\clock::class),
122
            // Alias the PSR-20 clock interface to the Moodle clock. They are compatible.
138
 
Línea 123... Línea 139...
123
            \core\clock::class => fn() => new \core\system_clock(),
139
            // Note: libphonenumber PhoneNumberUtil uses a singleton.
124
            \Psr\Clock\ClockInterface::class => \DI\get(\core\clock::class),
140
            \libphonenumber\PhoneNumberUtil::class => fn() => \libphonenumber\PhoneNumberUtil::getInstance(),