private function _initCache() { if (isset($this->_themeMap)) { return; } $this->_themeMap = array(); foreach ($this->_themeRegistry->getAll() as $theme) { $this->_themeMap[$theme->getName()] = $theme; } }
/** * @return string */ public function getThemeDataAsJson() { $themes = $this->_themeRegistry->getAll(); $toReturn = array(); foreach ($themes as $theme) { $toReturn[$theme->getName()] = $this->_buildThemeData($theme); } $asJson = json_encode($toReturn); return htmlspecialchars($asJson, ENT_NOQUOTES); }
public function onAcceptableValues(tubepress_api_event_EventInterface $event) { $current = $event->getSubject(); if (!is_array($current)) { $current = array(); } $result = array(); $allThemes = $this->_themeRegistry->getAll(); foreach ($allThemes as $theme) { $result[$theme->getName()] = $theme->getTitle(); } ksort($result); $toSet = array_merge($current, $result); $event->setSubject($toSet); }
public function onPreValidationSet(tubepress_api_event_EventInterface $event) { $themeValue = $event->getArgument('optionValue'); $shouldLog = $this->_logger->isEnabled(); if (in_array($themeValue, self::$_LEGACY_THEME_VALUES)) { if ($shouldLog) { $this->_logger->debug(sprintf('Renaming theme value from %s to tubepress/legacy-%s', $themeValue, $themeValue)); } $event->setArgument('optionValue', "tubepress/legacy-{$themeValue}"); return; } $allThemes = $this->_themeRegistry->getAll(); foreach ($allThemes as $theme) { if ($theme->getName() !== "unknown/legacy-{$themeValue}") { continue; } if ($shouldLog) { $this->_logger->debug(sprintf('Renaming theme value from %s to unknown/legacy-%s', $themeValue, $themeValue)); } $event->setArgument('optionValue', "unknown/legacy-{$themeValue}"); } }