The sole job of this class is to properly translate (or not) the given value according to the configurations.
Esempio n. 1
0
 /**
  * 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;
 }
Esempio n. 2
0
 public function testGeneric()
 {
     $this->tran->loadDictionary();
 }