Sf4 /
Api
| 1 | <?php |
||||
| 2 | /** |
||||
| 3 | * Created by PhpStorm. |
||||
| 4 | * User: siim |
||||
| 5 | * Date: 3.03.19 |
||||
| 6 | * Time: 20:42 |
||||
| 7 | */ |
||||
| 8 | |||||
| 9 | namespace Sf4\Api\Routing; |
||||
| 10 | |||||
| 11 | use Symfony\Component\Config\Loader\Loader; |
||||
| 12 | use Symfony\Component\Routing\RouteCollection; |
||||
| 13 | |||||
| 14 | class ApiLoader extends Loader |
||||
| 15 | { |
||||
| 16 | public const TYPE = 'sf4_api'; |
||||
| 17 | |||||
| 18 | /** @var bool $isLoaded */ |
||||
| 19 | protected $isLoaded = false; |
||||
| 20 | |||||
| 21 | /** |
||||
| 22 | * @param mixed $resource |
||||
| 23 | * @param null $type |
||||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||||
| 24 | * @return RouteCollection|null |
||||
| 25 | */ |
||||
| 26 | public function load($resource, $type = null): ?RouteCollection |
||||
| 27 | { |
||||
| 28 | if (true === $this->isLoaded) { |
||||
| 29 | return null; |
||||
| 30 | } |
||||
| 31 | |||||
| 32 | $routes = new RouteCollection(); |
||||
| 33 | |||||
| 34 | $importedRoutes = $this->import( |
||||
| 35 | '@Sf4ApiBundle/Resources/config/routing.yaml', |
||||
| 36 | 'yaml' |
||||
| 37 | ); |
||||
| 38 | $routes->addCollection($importedRoutes); |
||||
|
0 ignored issues
–
show
It seems like
$importedRoutes can also be of type null; however, parameter $collection of Symfony\Component\Routin...ection::addCollection() does only seem to accept Symfony\Component\Routing\RouteCollection, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 39 | |||||
| 40 | $this->isLoaded = true; |
||||
| 41 | |||||
| 42 | return $routes; |
||||
| 43 | } |
||||
| 44 | |||||
| 45 | /** |
||||
| 46 | * @param mixed $resource |
||||
| 47 | * @param null $type |
||||
|
0 ignored issues
–
show
|
|||||
| 48 | * @return bool |
||||
| 49 | */ |
||||
| 50 | public function supports($resource, $type = null): bool |
||||
| 51 | { |
||||
| 52 | return static::TYPE === $type; |
||||
| 53 | } |
||||
| 54 | } |
||||
| 55 |