<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */


class DataMenuMainTopLeftCached extends DataMenuMainTopLeft
{
  public function mainmenu()
  {
    $cacheKey = $this->getCacheKey();
    
    $cache = Kufer\Web\KuferWEB\Api\HtmlCacheFile::getInstance();
    if ($cacheKey) {
      $content = $cache->get($cacheKey);
    } else {
      $content = null;
    }
    if (is_null($content)) {
      ob_start();
      parent::mainmenu();
      $content = ob_get_contents();
      ob_end_clean();
      try {
        $cache->set($cacheKey, $content, $this->getTtl());
      } catch (\InvalidArgumentException $e) {
        Logger::logg('Dem HtmlCache wurde kein gültiger cacheKey übergeben (' . $cacheKey . ')', 4400);
      }
    }
    echo $content;
  }

  
  protected function getCacheKey()
  {
    return false;
  }

  
  protected function getTtl()
  {
    return null;
  }
}