Ejemplo n.º 1
0
 public function testRemove()
 {
     $node = new BreadcrumbsNode();
     $node->setPath('/');
     $node->setLabel('index');
     $this->breadcrumbs->addNode($node);
     $this->assertCount(1, $this->breadcrumbs->getNodes());
     $this->breadcrumbs->remove(0);
     $this->assertCount(0, $this->breadcrumbs->getNodes());
     $this->assertNull($this->breadcrumbs->remove(0));
 }
 /**
  * Create a breadcrumb through current request path
  *
  * @return Breadcrumbs
  */
 public function createFromRequest()
 {
     if (empty($this->matcher)) {
         $this->matcher = new TraceableUrlMatcher($this->router->getRouteCollection(), $this->router->getContext());
     }
     $breadcrumbs = new Breadcrumbs();
     $parent = null;
     $paths = $this->getBreadcrumbsPaths();
     foreach ($paths as $path) {
         if ($node = $this->createBreadcrumbsNode($path, $parent)) {
             $breadcrumbs->addNode($node);
             $parent = $path;
         }
     }
     return $breadcrumbs;
 }