public function removeFromCache() { Cache::remove((string) $this->request->key); $alert = new AlertControl(null, 'alert'); $alert->setAltertClass(AlertControl::ALERT_DANGER); $alert->setText('Eintrag wurde entfernt'); $this->ajaxResponse = $alert->toHtml(); $this->request->view = null; }
/** * Startet das Debugging. In diesem Modus werden alle Fehler * ausgegeben. Der Symfony-Debugger wird aktiviert und der * Cache wird deaktiviert */ public function start() { Logging::info('Debug: ON'); $this->active = true; $_SESSION['DEBUG'] = true; // Error-Ausgabe einschalten ini_set('display_errors', 1); ini_set('error_reporting', E_ALL); // Symfony Debugging aktivieren \Symfony\Component\Debug\Debug::enable(); Cache::disable(); Profiler::setActive(true); }
/** * Diese Methode lädt den Inhalt einer Skin-Datei in die Skin-Property der * Klasse. Dabei wird zuerst geschaut, ob es im aktuellen Template-Verzeichnis * eine entsprechende Datei gibt. Wenn nicht wird das Default-Skin geladen. * Die Skin eines Controls wird im Cache hinterlegt, um die Festplattten- * zugriffe zu minimieren. Dies kann zu Problemem führen, wenn im gleichen * Request zwei verschiedene Templates angesprochen werden. Aktuell ist dies * nicht vorgesehen. */ protected function loadSkin() { // 1. Schritt -> Versuch aus Template zu lesen // 2. Schritt -> Default lesen if ($this->skin === null) { $this->skin = Cache::get($this->getCacheId(), Template::loadSkin($this)); if ($this->skin === null && $this->defaultSkinFile !== '') { $this->skin = file_get_contents($this->defaultSkinFile); } Cache::set($this->getCacheId(), $this->skin); } }
public function flushCache() { Cache::removePrefixed('pages.'); }
/** * @return ListViewControl * @throws \Exception */ private function showTabInfo() { $table = new ListViewControl(null, 'tableCache'); $table->setSkin('<div id="cacheTarget"></div> <table class="table table-hover table-striped"> <thead> <tr> <th>Schlüssel</th> <th>Wert</th> <th></th> </tr> </thead> <tbody> {controls} </tbody> </table>'); $table->setItemSkin('<tr> <td>{key}</td> <td>{value}</td> <td> <a class="btn btn-xs btn-danger nfs-ajax" data-target="cacheTarget" href="{site.scriptUrl}/Debug/removeFromCache/key/{url_key}">Löschen</a> </td> </tr>'); $table->addItems(Cache::dump()); return $table; }
/** * Lädt das Modul mit dem übergebenen Namen * @param $name * @return Module|null */ public function getModule($name) { if ($name === '') { Logging::warning('Leeres Modul sollte geladen werden.'); return null; } $name = ucfirst($name); // Aus dem Cache holen $cacheId = 'module.' . $name; if (array_key_exists($cacheId, $this->internalCache)) { return $this->internalCache[$cacheId]; } $result = Cache::get($cacheId, null); if ($result !== null) { $this->internalCache[$cacheId] = $result; return $result; } Profiler::startSection('module.load', $name); Logging::debug("Modul '{$name}' wird geladen"); // Generieren der Klassendefinition für den Controller um dann via // Reflection die Datei und damit das Verzeichnis herauszubekommen. $naming = new ModuleNaming(); $classOfController = $naming->getControllerClassFromCamelCase($name); if (class_exists($classOfController)) { $reflector = new ReflectionClass($classOfController); $directory = dirname($reflector->getFileName()); $filename = $directory . '/Module.xml'; if (file_exists($filename)) { $file = simplexml_load_file($filename); $result = $this->createByXml($file, $directory); unset($file); } else { Logging::error("Modul [{$name}] konnte in Pfad {$directory} nicht gefunden werden"); } } else { Logging::warning("Controller für Modul [{$name}] konnte nicht gefunden werden [{$classOfController}]"); } Cache::set($cacheId, $result); $this->internalCache[$cacheId] = $result; Profiler::endSection('module.load'); return $result; }
/** * Änderung an den Modulstammdaten speichern */ public function endEditModule() { if (!$this->request->present('name')) { $create = new CodeCreation(); $this->current = $create->createModule($this->request->namespace, $this->request); } else { $this->current = Modules::getModule($this->request->qualifiedName); } $this->current->description = $this->request->description; $this->current->author = $this->request->author; $this->current->version = $this->request->version; $this->current->save(); Cache::remove($this->current->getCacheId()); $this->request->id = $this->current->qualifiedName; FlashMessage::success(Strings::GESPEICHERT); }
/** * Diese Methode lädt die Seiten dieses Menüs, basierend * auf einer Root-Seite und dem angemeldeten Benutzer. Die * geladenen Seiten werden im $pages Property abgelegt. * * @return Page[] * @throws Exception */ public function loadChildrenForCurrentUser() { if (!$this->hasChildren()) { return []; } // Versuch es aus dem Cache zu lesen $this->pages = Cache::get($this->getCacheId(), null); if ($this->pages === null) { $this->pages = []; $sql = "\n select seiten.*, text.*\n from\n\n (select distinct pa_id, pa_site, pa_parent, pa_bezeichnung, pa_link, pa_pos, pa_title, pa_module,\n pa_action, pa_css, pa_innertemplate, pa_parameter, pa_haschildren, pa_icon from pages\n join rechte on re_element = CONCAT('pages.', pa_id) and re_recht = 1 and re_rolle in {$_SESSION['rollen']}\n where pa_site = :site and pa_parent = :parent and (pa_ausblenden != 1) ) seiten\n\n left outer join texte text on text.te_element = CONCAT('pages.', pa_id) and text.te_sprache = :sprache\n\n order by pa_pos\n\n\t\t "; $sql = "\nselect distinct \n\tpa_id, pa_site, pa_parent, pa_bezeichnung, pa_link, pa_pos, pa_title, pa_module, pa_action, pa_css, pa_innertemplate, pa_parameter, \n\tpa_haschildren, pa_icon, text.* \n\nfrom pages \n\tjoin rechte on re_element = CONCAT('pages.', pa_id) and re_recht = 1 and re_rolle in {$_SESSION['rollen']}\n join texte text on text.te_element = CONCAT('pages.', pa_id) and text.te_sprache = :sprache \n\nwhere pa_site = :site and pa_parent = :parent and (pa_ausblenden != 1) order by pa_pos \n "; $this->db->query($sql, ['site' => $this->pa_site, 'parent' => $this->id, 'sprache' => $_SESSION['sp_id']]); $results = $this->db->fetchAll(); foreach ($results as $row) { $item = new Page(); $item->loadFromRow($row); $item->loadTextFromRow($row); $this->pages[] = $item; } Cache::set($this->getCacheId(), $this->pages); } return $this->pages; }