Noherczeg\Breadcrumb\Breadcrumb::append PHP Метод

append() публичный Метод

Supports method chaining. Warning! It doesn't fix multiple "base element" issues, so it's up to the programmer to append base elements wisely!
public append ( String $raw_name = null, String $side = 'right', boolean $base = false, mixed $translate = true, boolean $disabled = false ) : Breadcrumb
$raw_name String Name of the appendable Segment
$side String Which side to place the segment in the array
$base boolean true if it is referring to the base url
$translate mixed Set to true if you want to use the provided dictionary, set to false if you want to skip translation, or set to a specific string to assign that value
$disabled boolean
Результат Breadcrumb
    public function append($raw_name = null, $side = 'right', $base = false, $translate = true, $disabled = false)
    {
        $this->checkAppendArgs($raw_name, $side);
        $segment = new Segment($raw_name, $base, $disabled);
        // if translation is set
        if ($translate) {
            if (is_string($translate) && strlen($translate) > 0) {
                // we can set(override) the value manually
                $segment->setTranslated($translate);
            } elseif (is_bool($translate)) {
                // or use the translator service to do it from a selected Dictionary
                $segment->setTranslated($this->translator->translate($raw_name));
            }
        } else {
            $segment->setTranslated($raw_name);
        }
        $this->appendToSide($segment, $side);
        return $this;
    }

Usage Example

Пример #1
0
 /**
  * @Test
  */
 public function testRemoveWithReorder()
 {
     $this->bread->append('one');
     $this->bread->append('two');
     $this->bread->remove(0, true);
     $this->assertEquals('two', $this->bread->segment(0)->get('raw'));
 }