divineniiquaye /
rade-di
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /* |
||
| 6 | * This file is part of DivineNii opensource projects. |
||
| 7 | * |
||
| 8 | * PHP version 7.4 and above required |
||
| 9 | * |
||
| 10 | * @author Divine Niiquaye Ibok <[email protected]> |
||
| 11 | * @copyright 2021 DivineNii (https://divinenii.com/) |
||
| 12 | * @license https://opensource.org/licenses/BSD-3-Clause License |
||
| 13 | * |
||
| 14 | * For the full copyright and license information, please view the LICENSE |
||
| 15 | * file that was distributed with this source code. |
||
| 16 | */ |
||
| 17 | |||
| 18 | namespace Rade\DI\Loader; |
||
| 19 | |||
| 20 | use Rade\DI\ContainerBuilder; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * GlobFileLoader loads files from a glob pattern. |
||
| 24 | * |
||
| 25 | * @author Divine Niiquaye Ibok <[email protected]> |
||
| 26 | */ |
||
| 27 | class GlobFileLoader extends FileLoader |
||
| 28 | { |
||
| 29 | /** |
||
| 30 | * {@inheritdoc} |
||
| 31 | */ |
||
| 32 | 1 | public function load($resource, string $type = null): void |
|
| 33 | { |
||
| 34 | 1 | foreach ($this->glob($resource, false, $globResource) as $path => $info) { |
|
| 35 | 1 | $this->import($path); |
|
| 36 | } |
||
| 37 | |||
| 38 | 1 | if ($this->container instanceof ContainerBuilder) { |
|
| 39 | 1 | $this->container->addResource($globResource); |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 40 | } |
||
| 41 | 1 | } |
|
| 42 | |||
| 43 | /** |
||
| 44 | * {@inheritdoc} |
||
| 45 | */ |
||
| 46 | 2 | public function supports($resource, string $type = null) |
|
| 47 | { |
||
| 48 | 2 | return 'glob' === $type; |
|
| 49 | } |
||
| 50 | } |
||
| 51 |