Exemplo n.º 1
0
 /**
  *
  * @param string $string
  * @param string $language
  * @return string
  */
 public function translate($string, $language)
 {
     $key = "{$string}-to-{$language}";
     if ($this->cache->exists($key)) {
         return $this->cache->load($key);
     }
     if ($this->hasTranslate($string, $language)) {
         $strings = $this->getDBStrings($language);
         $string = $strings[$string];
         $this->cache->save($key, $string);
     }
     return $string;
 }
Exemplo n.º 2
0
 /**
  *
  * @param  $menu
  * @param AbstractMenuRenderer $renderer
  * @return string
  */
 public function buildAndRender(AbstractMenuRenderer $renderer)
 {
     $keyStorage = 'menu_html_' . $this->role;
     if ($this->cache->exists($keyStorage)) {
         return $this->cache->load($keyStorage);
     }
     $this->build();
     $html = $this->render($this->getUserMenu(), $renderer);
     if (null == $renderer) {
         $this->cache->save($keyStorage, $html);
     }
     return $html;
 }
Exemplo n.º 3
0
 /**
  * Exists
  * @param string
  * @return boolean
  */
 public function exists($key)
 {
     return $this->primaryStorage->exists($key) || $this->secondaryStorage->exists($key);
 }