private function allowedToSetLink($key, Segment $segment) { if (($key !== $this->getLastKey() || !$this->skipLast) && strlen($segment->get('link')) == 0) { return true; } return false; }
/** * @Test */ public function testTogglers() { $this->segment->disable(); $this->assertEquals(true, $this->segment->get('disabled')); $this->segment->enable(); $this->assertEquals(false, $this->segment->get('disabled')); }
/** * @return void Just populates the list */ private function createSegmentList() { foreach ($this->rawInput as $title => $link) { $segment = new Segment($title); $segment->setTranslated($title); $segment->setLink($link); $this->segments[] = $segment; } }
private function appendElement(Segment $segment) { $result = ''; if ($segment->get('disabled')) { $result .= $this->getInactiveElementByFieldName($segment->get('raw'), $this->casing); } else { if (is_null($segment->get('link'))) { $result .= $this->getInactiveElementByFieldName($segment->get('translated'), $this->casing, 'current'); } else { $result .= '<li><a href="' . $segment->get('link') . '">' . $this->casing($segment->get('translated'), $this->casing) . '</a></li>'; } } return $result; }
private function appendElement($key, Segment $segment, $properties) { $result = ''; // ignore separator after the last element if ($key > 0) { $result .= $this->separator; } if ($segment->get('disabled')) { $result .= $this->getInactiveElementByFieldName($this->properties($properties), $this->casing($segment->get('raw'), $this->casing)); } elseif (is_null($segment->get('link'))) { $result .= $this->getInactiveElementByFieldName($this->properties($properties), $this->casing($segment->get('translated'), $this->casing)); } else { $result .= '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . $segment->get('link') . '" ' . $this->properties($properties) . ' itemprop="url">' . '<span itemprop="title">' . $this->casing($segment->get('translated'), $this->casing) . '</span>' . '</a></li>'; } return $result; }
private function appendElement($key, Segment $segment, $properties) { $result = ''; // ignore separator after the last element if ($key > 0) { $result .= $this->separator; } if ($segment->get('disabled')) { $result .= $this->getInactiveElementByFieldName($segment->get('raw'), $this->casing, $this->properties($properties)); } else { if (is_null($segment->get('link'))) { $result .= $this->getInactiveElementByFieldName($segment->get('translated'), $this->casing, $this->properties($properties)); } else { $result .= '<a href="' . $segment->get('link') . '" ' . $this->properties($properties) . '>' . $this->casing($segment->get('translated'), $this->casing) . '</a>'; } } return $result; }
private function appendElement($key, Segment $segment) { $result = ''; // ignore separator after the last element if ($key > 0) { $result .= ' <span class="divider">' . $this->separator . '</span></li>'; } if ($segment->get('disabled')) { $result .= $this->getInactiveElementByFieldName($segment->get('raw'), $this->casing); } else { if (is_null($segment->get('link'))) { $result .= $this->getInactiveElementByFieldName($segment->get('translated'), $this->casing); } else { $result .= '<li><a href="' . $segment->get('link') . '">' . $this->casing($segment->get('translated'), $this->casing) . '</a>'; } } return $result; }
/** * append: Appends an element to the list of Segments. Can do it from both * sides, and can mark an element as base element, which means that it'll * point to the base URL. * * Supports method chaining. * * Warning! It doesn't fix multiple "base element" issues, so it's up to the * programmer to append base elements wisely! * * @param String $raw_name Name of the appendable Segment * @param String $side Which side to place the segment in the array * @param boolean $base true if it is referring to the base url * @param mixed $translate 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 * @param bool $disabled * @throws \InvalidArgumentException * @return \Noherczeg\Breadcrumb\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; }