Ejemplo n.º 1
0
 /**
  * Parses a trail and adds it to the TrailCollection.
  *
  * @param TrailCollection $collection A TrailCollection instance
  * @param string          $name       Trail name
  * @param array           $config     Trail definition
  * @param string          $file       A Yaml file path
  *
  * @throws \InvalidArgumentException When config pattern is not defined for the given route
  */
 protected function parseTrail(TrailCollection $collection, $name, $config, $file)
 {
     if (!isset($config['crumbs']) && !is_array($config['crumbs'])) {
         throw new \InvalidArgumentException(sprintf('You must define an array of crumbs for the "%s" route.', $name));
     }
     $trail = new Trail();
     foreach ($config['crumbs'] as $c) {
         if (!isset($c['title'])) {
             throw new \InvalidArgumentException(sprintf('You must define a "title" for the "%s" route.', $name));
         }
         $uri = isset($c['uri']) ? $c['uri'] : null;
         $attributes = isset($c['attributes']) ? $c['attributes'] : array();
         $trail->add(new Crumb($c['title'], $uri, $attributes));
     }
     $collection->add($name, $trail);
 }
Ejemplo n.º 2
0
<?php

require __DIR__ . '/../../vendor/autoload.php';
use Breadcrumbs\TrailCollection;
use Breadcrumbs\BreadcrumbFactory;
use Breadcrumbs\Renderer\ListRenderer;
$factory = BreadcrumbFactory::create();
$collection = new TrailCollection();
$collection->add('homepage', $factory->createTrail()->add($factory->createCrumb('Homepage', '/')));
$collection->add('foo', $factory->createTrail()->add($factory->createCrumb('Foo', '/foo')));
$collection->add('bar', $factory->createTrail()->add($factory->createCrumb('Bar', '/bar')), 'homepage');
return $collection;
Ejemplo n.º 3
0
<?php

require __DIR__ . '/../../vendor/autoload.php';
use Breadcrumbs\TrailCollection;
use Breadcrumbs\BreadcrumbFactory;
use Breadcrumbs\Renderer\ListRenderer;
$factory = BreadcrumbFactory::create();
$collection = new TrailCollection();
$collection->add('test', $factory->createTrail()->add($factory->createCrumb('Test', '/test')));
return $collection;
Ejemplo n.º 4
0
<?php

require __DIR__ . '/../vendor/autoload.php';
use Breadcrumbs\BreadcrumbFactory;
use Breadcrumbs\Crumb;
use Breadcrumbs\TrailCollection;
use Breadcrumbs\Renderer\ListRenderer;
$factory = BreadcrumbFactory::create();
$collection = new TrailCollection();
$collection->add('homepage', $factory->createTrail()->add($factory->createCrumb('Homepage', '/', array('class' => 'foo', 'id' => 'home'))));
$collection->add('foo', $factory->createTrail()->add($factory->createCrumb('Foo', '/foo')));
$renderer = new ListRenderer(' &gt; ');
echo $renderer->render($collection->get('homepage')) . PHP_EOL;
echo $renderer->render($collection->get('foo')) . PHP_EOL;