Example #1
0
 public function testFilterItems()
 {
     $filters = new Menu\FilterRepository();
     $item = new Menu\Items\Item($filters);
     $filters->addFilter(function ($item) {
     });
     $filters->addFilter(function ($item) {
         $item->remove();
     }, 'bar');
     $this->assertTrue($item->exists());
     $filters->filter($item);
     $this->assertTrue($item->exists());
     $filters->filter($item, 'bar');
     $this->assertFalse($item->exists());
 }
Example #2
0
 /**
  * Remove the current item, or remove a sub-item.
  *
  * @param  string  $item
  * @return void
  */
 public function remove($name = null)
 {
     // Remove the current item if no name was inputted.
     if (is_null($name)) {
         // Remove the item from its parent, if it has one.
         if (!is_null($this->parent)) {
             $this->parent->remove($this->name);
         }
         $this->hasBeenRemoved = true;
     } else {
         $this->items[$name]->hasBeenRemoved = true;
         unset($this->items[$name]);
     }
 }