php Symfony-Component-Routing-Loader-YamlFileLoader类(方法)实例源码

下面列出了php Symfony-Component-Routing-Loader-YamlFileLoader 类(方法)源码代码实例,从而了解它的用法。

作者:phpwa    项目:cor   
/**
  * Boots the current kernel.
  *
  * @api
  */
 public function boot()
 {
     if (true === $this->booted) {
         return;
     }
     // Setup Routes
     $this->router = new RouteCollection();
     $locator = new FileLocator([$this->get_root_dir() . '/config/']);
     try {
         $loader = new PhpFileLoader($locator);
         $this->router->addCollection($loader->load('routes.php'));
         $loader = new YamlFileLoader($locator);
         $this->router->addCollection($loader->load('routes.yml'));
     } catch (\InvalidArgumentException $e) {
     }
     // Load configuration
     try {
         $this->config = new Configuration();
         $this->config->add_resource($this->get_root_dir() . '/config/');
         $this->config->add_config($this->config->get("config_" . $this->get_environment()));
     } catch (\Exception $e) {
     }
     // init bundles
     $this->initialize_bundles();
     foreach ($this->get_bundles() as $bundle) {
         $bundle->set_application($this);
         $bundle->boot();
     }
     $this->booted = true;
 }

作者:erp    项目:harserve   
public function createRouteCollection()
 {
     $locator = new FileLocator([__DIR__]);
     $loader = new YamlFileLoader($locator);
     $collection = $loader->load('routing.yml');
     return $collection;
 }

作者:jeanpasqualini-lesso    项目:lesson-routin   
public function runTest()
 {
     $locator = new FileLocator(array(__DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "config"));
     $loader = new YamlFileLoader($locator);
     $routes = $loader->load("routing.yml");
     $validator = new RouteValidator(new UrlMatcher($routes, new RequestContext("/")));
     $validator->validate();
 }

作者:RubenCo    项目:Symfony_Web-Mobil   
/**
  * Get an object instance of UrlGenerator class.
  * 
  * @return UrlGenerator
  */
 public static function getInstance()
 {
     $configDirectory = new YamlFileLoader(new FileLocator(array(__DIR__ . '/../../Resources/config')));
     $captchaRoutes = $configDirectory->load('routing.yml');
     $requestContext = new RequestContext();
     $requestContext->fromRequest(Request::createFromGlobals());
     return new SymfonyUrlGenerator($captchaRoutes, $requestContext);
 }

作者:pavgr    项目:2nova-tes   
/**
  * @param ControllerResolver $resolver
  */
 public function __construct($resolver)
 {
     // Load routes list
     $locator = new FileLocator([__DIR__]);
     $loader = new YamlFileLoader($locator);
     $this->routes = $loader->load('routes.yml');
     // Set ControllerResolver
     $this->resolver = $resolver;
 }

作者:kirkegaar    项目:silex-bootstra   
private function initRoutes()
 {
     $this["routes"] = $this->extend("routes", function (RouteCollection $routes, Application $this) {
         $loader = new YamlFileLoader(new FileLocator($this->base . 'etc'));
         $collection = $loader->load('routes.yml');
         $routes->addCollection($collection);
         return $routes;
     });
 }

作者:JoshuaReneDalle    项目:ph   
static function configure($app)
 {
     $app["routes"] = $app->extend("routes", function (RouteCollection $routes, Application $app) {
         $loader = new YamlFileLoader(new FileLocator(__DIR__ . "/../config"));
         $collection = $loader->load("routes.yml");
         $routes->addCollection($collection);
         return $routes;
     });
 }

作者:justinpoct    项目:roadi   
/**
  * {@inheritdoc}
  */
 public static function getRoutes()
 {
     $locator = new FileLocator([ROADIZ_ROOT . '/src/Roadiz/CMS/Resources']);
     if (file_exists(ROADIZ_ROOT . '/src/Roadiz/CMS/Resources/assetsRoutes.yml')) {
         $loader = new YamlFileLoader($locator);
         return $loader->load('assetsRoutes.yml');
     }
     return null;
 }

作者:dbiag    项目:grigoros-boilerplat   
private function configureRoutes()
 {
     $this['routes'] = $this->extend('routes', function (RouteCollection $routes, Application $app) {
         $loader = new YamlFileLoader(new FileLocator($app->getConfigDir()));
         $collection = $loader->load('routes.yml');
         $routes->addCollection($collection);
         return $routes;
     });
 }

作者:Tarenda    项目:spring-websit   
/**
  * Find a list of controllers
  *
  * @param string $base_path Base path to prepend to file paths
  * @return provider
  */
 public function find($base_path = '')
 {
     $this->routes = new RouteCollection();
     foreach ($this->routing_files as $file_path) {
         $loader = new YamlFileLoader(new FileLocator(phpbb_realpath($base_path)));
         $this->routes->addCollection($loader->load($file_path));
     }
     return $this;
 }

作者:broklyngaga    项目:jaz   
/**
  * {@inheritDoc}
  */
 public function register(Application $app)
 {
     $app->extend('routes', function (RouteCollection $routes, Application $app) {
         $loader = new YamlFileLoader(new FileLocator(JAZZ_CONFIG_DIR));
         $collection = $loader->load('routing.yml');
         $routes->addCollection($collection);
         return $routes;
     });
 }

作者:nexher    项目:muffi   
public static function generateURI($tag, $args = NULL)
 {
     $request = Request::createFromGlobals();
     $locator = new FileLocator(array(__DIR__));
     $loader = new YamlFileLoader($locator);
     $routes = $loader->load('../config/routes.yml');
     $context = new RequestContext($request->getBaseUrl());
     $generator = new UrlGenerator($routes, $context);
     $url = $generator->generate($tag);
     return $url;
 }

作者:chenze    项目:custom-framewor   
protected function parseYmlFile()
 {
     $finder = new Finder();
     $finder->files()->in(__DIR__ . '/../config/routing');
     $locator = new FileLocator(array(__DIR__ . '/../config/routing'));
     $loader = new YamlFileLoader($locator);
     foreach ($finder as $file) {
         $subCollection = $loader->load($file->getRelativePathname());
         $this->routes->addCollection($subCollection);
     }
 }

作者:bonswoua    项目:FMElfinderBundl   
/**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->twig = new \Twig_Environment(new \Twig_Loader_Filesystem(array(__DIR__ . '/../../../Resources/views/Elfinder/helper')));
     $this->extension = new FMElfinderTinymceExtension($this->twig);
     $this->twig->addExtension($this->extension);
     $loader = new YamlFileLoader(new FileLocator(__DIR__ . '/../../../Resources/config'));
     $routes = new RouteCollection();
     $collection = $loader->load('routing.yml');
     $routes->addCollection($collection);
     $this->twig->addExtension(new RoutingExtension(new UrlGenerator($routes, new RequestContext())));
 }

作者:mbabenko2    项目:likedimion-serve   
protected function routing()
 {
     $routesDir = StringCommon::replaceKeyWords($this->_config["router"]["routes_dir"]);
     $routesFile = $this->_config["router"]["routes_file"];
     $loader = new YamlFileLoader(new FileLocator($routesDir));
     $loader->load($routesFile);
     $context = new RequestContext();
     $context->fromRequest(Request::createFromGlobals());
     //$matcher = new UrlMatcher($collection, $context);
     $router = new Router($loader, $routesFile);
     $this->action($router, $context);
 }

作者:dongw    项目:silex-base-cor   
public function clean()
 {
     $locator = new FileLocator($this->app['config_path']);
     $loader = new YamlFileLoader($locator);
     $resources = [];
     $routeCollection = new RouteCollection();
     foreach ($this->finder as $file) {
         $resources[] = new FileResource($file->getRealpath());
         $routeCollection->addCollection($loader->load($file->getRealpath()));
     }
     $this->routesCache->write(\serialize($routeCollection), $resources);
 }

作者:tpoboz    项目:symfony3-legac   
protected function boot()
 {
     $dispatcher = new EventDispatcher($this->container);
     $resolver = new ControllerResolver($this->container);
     $this->httpKernel = new HttpKernel($dispatcher, $resolver);
     $this->legacyKernel = new LegacyIntranetKernel($dispatcher);
     $locator = new FileLocator(array(__DIR__ . '/config'));
     $loader = new YamlFileLoader($locator);
     $collection = $loader->load('routes.yml');
     $context = new RequestContext();
     $matcher = new UrlMatcher($collection, $context);
     $dispatcher->addSubscriber(new RouterListener($matcher, $context));
 }

作者:bilgorajski    项目:YamlRoute   
public function register(Container $app)
 {
     $app['routes'] = $app->extend('routes', function (RouteCollection $routes, Application $app) {
         $file_locator = $app['router.path'] ? $app['router.path'] : __DIR__ . '/../config/routes.yml';
         $file_locator = explode(DIRECTORY_SEPARATOR, $file_locator);
         $file_name = end($file_locator);
         unset($file_locator[count($file_locator) - 1]);
         $file_locator = implode(DIRECTORY_SEPARATOR, $file_locator);
         $loader = new YamlFileLoader(new FileLocator($file_locator));
         $collection = $loader->load($file_name);
         $routes->addCollection($collection);
         return $routes;
     });
 }

作者:c4d3    项目:mcsuite-application-eyeofende   
public function load($resource, $type = null)
 {
     if (true === $this->loaded) {
         throw new \RuntimeException('Do not add this loader twice');
     }
     $collection = new RouteCollection();
     $resource = __DIR__ . '/../Resources/config';
     $locator = new FileLocator($resource);
     $loader = new YamlFileLoader($locator);
     $collection->addCollection($loader->load('routing.yml'));
     $collection->addCollection($loader->load('routing_admin.yml'));
     $this->loaded = true;
     return $collection;
 }

作者:yash    项目:generato   
public function testLoadWithResource()
 {
     $loader = new YamlFileLoader(new FileLocator(array(__DIR__ . '/../Fixtures')));
     $routeCollection = $loader->load('validresource.yml');
     $routes = $routeCollection->all();
     $this->assertCount(2, $routes, 'Two routes are loaded');
     $this->assertContainsOnly('Symfony\\Component\\Routing\\Route', $routes);
     foreach ($routes as $route) {
         $this->assertSame('/{foo}/blog/{slug}', $route->getPath());
         $this->assertSame('123', $route->getDefault('foo'));
         $this->assertSame('\\d+', $route->getRequirement('foo'));
         $this->assertSame('bar', $route->getOption('foo'));
         $this->assertSame('', $route->getHost());
     }
 }


问题


面经


文章

微信
公众号

扫码关注公众号