ci4

Форк
0
/
FileLocatorInterface.php 
82 строки · 2.8 Кб
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of CodeIgniter 4 framework.
7
 *
8
 * (c) CodeIgniter Foundation <admin@codeigniter.com>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace CodeIgniter\Autoloader;
15

16
/**
17
 * Allows loading non-class files in a namespaced manner.
18
 * Works with Helpers, Views, etc.
19
 */
20
interface FileLocatorInterface
21
{
22
    /**
23
     * Attempts to locate a file by examining the name for a namespace
24
     * and looking through the PSR-4 namespaced files that we know about.
25
     *
26
     * @param string                $file   The relative file path or namespaced file to
27
     *                                      locate. If not namespaced, search in the app
28
     *                                      folder.
29
     * @param non-empty-string|null $folder The folder within the namespace that we should
30
     *                                      look for the file. If $file does not contain
31
     *                                      this value, it will be appended to the namespace
32
     *                                      folder.
33
     * @param string                $ext    The file extension the file should have.
34
     *
35
     * @return false|string The path to the file, or false if not found.
36
     */
37
    public function locateFile(string $file, ?string $folder = null, string $ext = 'php');
38

39
    /**
40
     * Examines a file and returns the fully qualified class name.
41
     */
42
    public function getClassname(string $file): string;
43

44
    /**
45
     * Searches through all of the defined namespaces looking for a file.
46
     * Returns an array of all found locations for the defined file.
47
     *
48
     * Example:
49
     *
50
     *  $locator->search('Config/Routes.php');
51
     *  // Assuming PSR4 namespaces include foo and bar, might return:
52
     *  [
53
     *      'app/Modules/foo/Config/Routes.php',
54
     *      'app/Modules/bar/Config/Routes.php',
55
     *  ]
56
     */
57
    public function search(string $path, string $ext = 'php', bool $prioritizeApp = true): array;
58

59
    /**
60
     * Find the qualified name of a file according to
61
     * the namespace of the first matched namespace path.
62
     *
63
     * @return false|string The qualified name or false if the path is not found
64
     */
65
    public function findQualifiedNameFromPath(string $path);
66

67
    /**
68
     * Scans the defined namespaces, returning a list of all files
69
     * that are contained within the subpath specified by $path.
70
     *
71
     * @return list<string> List of file paths
72
     */
73
    public function listFiles(string $path): array;
74

75
    /**
76
     * Scans the provided namespace, returning a list of all files
77
     * that are contained within the sub path specified by $path.
78
     *
79
     * @return list<string> List of file paths
80
     */
81
    public function listNamespaceFiles(string $prefix, string $path): array;
82
}
83

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.