/** * Extends the found ColorIds * * @param string $websiteId * * @return callback */ protected function getCleaningColorIdCallback($websiteId) { if (isset($this->cleaningColorIdCallbacks[$websiteId]) && is_callable($this->cleaningColorIdCallbacks[$websiteId])) { return $this->cleaningColorIdCallbacks[$websiteId]; } $website = $this->getWebsiteService()->getById($websiteId); $colorscheme = $website->getColorscheme(); $colors = array(); // decode colorscheme if (is_string($colorscheme)) { try { // JSON decodieren und Array aufbereiten $colorscheme = \Zend_Json::decode($colorscheme); } catch (\Exception $e) { // Fehler Registry::getLogger()->log(__CLASS__, __METHOD__, 'Farbeschema konnte nicht erstellt werden: ' . $e->errorMessage, \Zend_Log::WARN); } } // create color values if (is_array($colorscheme)) { foreach ($colorscheme as $colorValue) { $nextColor = new DataColorItem($colorValue); $colors[$nextColor->getBaseId()] = $nextColor; } } // create callback $this->cleaningColorIdCallbacks[$websiteId] = function ($matches) use($colors) { $orgColorId = $matches[0]; $baseColorId = WebsiteColor::getBaseIdFromColorId($matches[0]); if (isset($colors[$baseColorId])) { // return base colorId return $baseColorId; } // return original colorId return $orgColorId; }; return $this->cleaningColorIdCallbacks[$websiteId]; }
public function getIdWithFallbackColor() { return WebsiteColor::extendIdWithFallbackColor($this->getId(), $this->getValue()); }