vendor/friendsofsymfony/rest-bundle/Routing/Loader/RestRouteProcessor.php line 58

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the FOSRestBundle package.
  4.  *
  5.  * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace FOS\RestBundle\Routing\Loader;
  11. use Symfony\Component\Config\Loader\FileLoader;
  12. use Symfony\Component\Config\Loader\LoaderInterface;
  13. use Symfony\Component\Routing\RouteCollection;
  14. /**
  15.  * Processes resource in provided loader.
  16.  *
  17.  * @author Donald Tyler <chekote69@gmail.com>
  18.  * @author Konstantin Kudryashov <ever.zet@gmail.com>
  19.  */
  20. class RestRouteProcessor
  21. {
  22.     /**
  23.      * Import & return routes collection from a resource.
  24.      *
  25.      * @param LoaderInterface $loader      The Loader
  26.      * @param mixed           $resource    A Resource
  27.      * @param array           $parents     Array of parent resources names
  28.      * @param string          $routePrefix Current routes prefix
  29.      * @param string          $namePrefix  Routes names prefix
  30.      * @param string          $type        The resource type
  31.      * @param string          $currentDir  Current directory of the loader
  32.      *
  33.      * @return RouteCollection A RouteCollection instance
  34.      */
  35.     public function importResource(
  36.         LoaderInterface $loader,
  37.         $resource,
  38.         array $parents = [],
  39.         $routePrefix null,
  40.         $namePrefix null,
  41.         $type null,
  42.         $currentDir null
  43.     ) {
  44.         $loader $loader->resolve($resource$type);
  45.         if ($loader instanceof FileLoader && null !== $currentDir) {
  46.             $resource $loader->getLocator()->locate($resource$currentDir);
  47.         } elseif ($loader instanceof RestRouteLoader) {
  48.             $loader->getControllerReader()->getActionReader()->setParents($parents);
  49.             $loader->getControllerReader()->getActionReader()->setRoutePrefix($routePrefix);
  50.             $loader->getControllerReader()->getActionReader()->setNamePrefix($namePrefix);
  51.         }
  52.         return $loader->load($resource$type);
  53.     }
  54. }