/** * Validates a single attribute. * This method should be overridden by child classes. * @param CModel $object the data object being validated * @param string $attribute the name of the attribute to be validated. */ protected function validateAttribute($object, $attribute) { $value = $object->{$attribute}; $xml = false; if ($this->useCache && !empty(self::$filesCache[$value])) { $xmlFile = self::$filesCache[$value]; } else { $xmlFile = tempnam(Yii::app()->getRuntimePath(), 'xml'); try { CurlHelper::downloadToFile($value, $xmlFile); self::$filesCache[$value] = $xmlFile; } catch (Exception $e) { } } if (file_exists($xmlFile)) { $xml = @simplexml_load_file($xmlFile); } if ($xml === false) { $message = $this->message !== null ? $this->message : Yii::t('ValidXml.app', '{attribute} doesn\'t contain valid XML.'); $this->addError($object, $attribute, $message); } }