Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 170... Línea 170...
170
        // If the file is found, require it.
170
        // If the file is found, require it.
171
        if (!empty($file)) {
171
        if (!empty($file)) {
172
            require($file);
172
            require($file);
173
            return;
173
            return;
174
        }
174
        }
-
 
175
 
-
 
176
        if (defined('PHPUNIT_TEST') && PHPUNIT_TEST) {
-
 
177
            // For unit tests we support classes in `\frankenstyle_component\tests\` to be loaded from
-
 
178
            // `path/to/frankenstyle/component/tests/classes` directory.
-
 
179
            // Note: We do *not* support the legacy `\frankenstyle_component_tests_style_classnames`.
-
 
180
            if ($component = self::get_component_from_classname($classname)) {
-
 
181
                $pathoptions = [
-
 
182
                    '/tests/classes' => "{$component}\\tests\\",
-
 
183
                    '/tests/behat' => "{$component}\\behat\\",
-
 
184
                ];
-
 
185
                foreach ($pathoptions as $path => $testnamespace) {
-
 
186
                    if (preg_match("#^" . preg_quote($testnamespace) . "#", $classname)) {
-
 
187
                        $path = self::get_component_directory($component) . $path;
-
 
188
                        $relativeclassname = str_replace(
-
 
189
                            $testnamespace,
-
 
190
                            '',
-
 
191
                            $classname,
-
 
192
                        );
-
 
193
                        $file = sprintf(
-
 
194
                            "%s/%s.php",
-
 
195
                            $path,
-
 
196
                            str_replace('\\', '/', $relativeclassname),
-
 
197
                        );
-
 
198
                        if (!empty($file) && file_exists($file)) {
-
 
199
                            require($file);
-
 
200
                            return;
-
 
201
                        }
-
 
202
                        break;
-
 
203
                    }
-
 
204
                }
-
 
205
            }
-
 
206
        }
175
    }
207
    }
Línea 176... Línea 208...
176
 
208
 
177
    /**
209
    /**
178
     * Return the path to a class from our defined PSR-0 or PSR-4 standard namespaces on
210
     * Return the path to a class from our defined PSR-0 or PSR-4 standard namespaces on
Línea 240... Línea 272...
240
        $file = $path . str_replace($separators, '/', $relativeclass) . '.php';
272
        $file = $path . str_replace($separators, '/', $relativeclass) . '.php';
Línea 241... Línea 273...
241
 
273
 
242
        return $file;
274
        return $file;
Línea 243... Línea -...
243
    }
-
 
244
 
275
    }
245
 
276
 
246
    /**
277
    /**
247
     * Initialise caches, always call before accessing self:: caches.
278
     * Initialise caches, always call before accessing self:: caches.
248
     */
279
     */
Línea 366... Línea 397...
366
            self::invalidate_opcode_php_cache($cachefile);
397
            self::invalidate_opcode_php_cache($cachefile);
367
        }
398
        }
368
    }
399
    }
Línea 369... Línea 400...
369
 
400
 
-
 
401
    /**
-
 
402
     * Reset the initialisation of the component utility.
-
 
403
     *
-
 
404
     * Note: It should not be necessary to call this in regular code.
-
 
405
     * Please only use it where strictly required.
-
 
406
     */
-
 
407
    public static function reset(): void {
-
 
408
        // The autoloader will re-initialise if plugintypes is null.
-
 
409
        self::$plugintypes = null;
-
 
410
    }
-
 
411
 
370
    /**
412
    /**
371
     * Are we in developer debug mode?
413
     * Are we in developer debug mode?
372
     *
414
     *
373
     * Note: You need to set "$CFG->debug = (E_ALL | E_STRICT);" in config.php,
415
     * Note: You need to set "$CFG->debug = (E_ALL | E_STRICT);" in config.php,
374
     *       the reason is we need to use this before we setup DB connection or caches for CFG.
416
     *       the reason is we need to use this before we setup DB connection or caches for CFG.