示例#1
0
 /**
  * @param CM_Site_Abstract $site
  * @param string           $zoneName
  * @return array
  * @throws CM_Exception_Invalid
  */
 protected function _getZoneData(CM_Site_Abstract $site, $zoneName)
 {
     $cacheKey = CM_CacheConst::AdproviderZones . '_siteId:' . $site->getId();
     $cache = CM_Cache_Local::getInstance();
     if (false === ($zones = $cache->get($cacheKey))) {
         $zones = CM_Config::get()->CM_Adprovider->zones;
         if (isset($site->getConfig()->CM_Adprovider->zones)) {
             $zones = array_merge($zones, $site->getConfig()->CM_Adprovider->zones);
         }
         $cache->set($cacheKey, $zones);
     }
     if (!array_key_exists($zoneName, $zones)) {
         return null;
     }
     return $zones[$zoneName];
 }
示例#2
0
 /**
  * @param CM_Site_Abstract $site
  * @param string           $zoneName
  * @return mixed
  * @throws CM_Exception_Invalid
  */
 protected function _getZone(CM_Site_Abstract $site, $zoneName)
 {
     $cacheKey = CM_CacheConst::AdproviderZones . '_siteId:' . $site->getId();
     $cache = CM_Cache_Local::getInstance();
     if (false === ($zones = $cache->get($cacheKey))) {
         $zones = CM_Config::get()->CM_Adprovider->zones;
         if (isset($site->getConfig()->CM_Adprovider->zones)) {
             $zones = array_merge($zones, $site->getConfig()->CM_Adprovider->zones);
         }
         $cache->set($cacheKey, $zones);
     }
     if (!array_key_exists($zoneName, $zones)) {
         throw new CM_Exception_Invalid('Zone `' . $zoneName . '` not configured.');
     }
     return $zones[$zoneName];
 }