示例#1
0
 private static function prepareConfig()
 {
     $configDirectories = array(dirname(__FILE__) . '/../../config');
     $locator = new FileLocator($configDirectories);
     $loaderResolver = new LoaderResolver(array(new \App\ConfigLoader($locator)));
     $ymlConfig = $locator->locate(dirname(__FILE__) . '/../../config/config.yml', null, false);
     return $loaderResolver->resolve($ymlConfig)->load($ymlConfig);
 }
 public function testResolve()
 {
     $loader = $this->getMock('Symfony\\Component\\Config\\Loader\\LoaderInterface');
     $resolver = new LoaderResolver(array($loader));
     $this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is able to load the resource');
     $loader = $this->getMock('Symfony\\Component\\Config\\Loader\\LoaderInterface');
     $loader->expects($this->once())->method('supports')->will($this->returnValue(true));
     $resolver = new LoaderResolver(array($loader));
     $this->assertEquals($loader, $resolver->resolve(function () {
     }), '->resolve() returns the loader for the given resource');
 }
示例#3
0
<?php

require __DIR__ . '/../../vendor/autoload.php';
use Breadcrumbs\BreadcrumbFactory;
use Breadcrumbs\TrailCollection;
use Breadcrumbs\Provider;
use Breadcrumbs\Loader\PhpFileLoader;
use Breadcrumbs\Loader\YamlFileLoader;
use Breadcrumbs\Renderer\ListRenderer;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\LoaderResolver;
$resolver = new LoaderResolver();
$resolver->addLoader(new YamlFileLoader(new FileLocator(array(__DIR__ . '/../Fixtures'))));
$resolver->addLoader(new PhpFileLoader(new FileLocator(array(__DIR__ . '/../Fixtures'))));
$loader = $resolver->resolve('many_type.yml');
$collection = $loader->load('many_type.yml');
$renderer = new ListRenderer(' > ');
echo $renderer->render($collection->get('homepage')) . PHP_EOL;
echo $renderer->render($collection->get('test')) . PHP_EOL;
echo $renderer->render($collection->get('bar')) . PHP_EOL;