Пример #1
0
 protected function addExtraFieldsToCacheParams($extraField, $condition, $refValue)
 {
     foreach ($this->getFieldValues($extraField) as $valueIndex => $fieldValue) {
         $extraFieldType = self::getExtraFieldType($extraField);
         $extraFieldCacheKey = is_array($extraField) ? json_encode($extraField) : $extraField;
         if ($extraFieldType == self::ECF_REFERRER) {
             $strippedFieldValue = infraRequestUtils::parseUrlHost($fieldValue);
         } else {
             $strippedFieldValue = $fieldValue;
         }
         $conditionResult = $this->applyCondition($fieldValue, $condition, $refValue, $strippedFieldValue);
         $key = "___cache___{$extraFieldCacheKey}_{$valueIndex}" . $this->getConditionKey($condition, $refValue);
         $this->_params[$key] = $conditionResult;
     }
     $this->_cacheKeyDirty = true;
 }
 protected function getFieldValues($extraField)
 {
     switch ($extraField) {
         case self::ECF_REFERRER:
             $values = array();
             // a request can theoritically have more than one referrer, in case of several baseEntry.getContextData calls in a single multirequest
             foreach ($this->_referrers as $referrer) {
                 $values[] = infraRequestUtils::parseUrlHost($referrer);
             }
             return $values;
         case self::ECF_USER_AGENT:
             if (isset($_SERVER['HTTP_USER_AGENT'])) {
                 return array($_SERVER['HTTP_USER_AGENT']);
             }
             break;
         case self::ECF_COUNTRY:
             return array(self::getCountry());
         case self::ECF_IP:
             return array(self::getIp());
     }
     return array();
 }