/** * Checks if data is valid for current data field * * @param mixed $data * @param boolean $omitMandatoryCheck * @throws Exception */ public function checkValidity($data, $omitMandatoryCheck = false) { if (!$omitMandatoryCheck and $this->getMandatory() and empty($data)) { throw new Exception("Empty mandatory field [ " . $this->getName() . " ]"); } $dependencies = Pimcore_Tool_Text::getDependenciesOfWysiwygText($data); if (is_array($dependencies)) { foreach ($dependencies as $key => $value) { $el = Element_Service::getElementById($value['type'], $value['id']); if (!$el) { throw new Exception("invalid dependency in wysiwyg text"); } } } }
/** * @return array */ public function resolveDependencies() { return Pimcore_Tool_Text::getDependenciesOfWysiwygText($this->text); }
/** * Checks if data for this field is valid and removes broken dependencies * * @param Object_Abstract $object * @return bool */ public function sanityCheck($object) { $key = $this->getName(); $originalText = $object->{$key}; $sane = true; $dependencies = Pimcore_Tool_Text::getDependenciesOfWysiwygText($object->{$key}); $cleanedText = Pimcore_Tool_Text::cleanWysiwygTextOfDependencies($object->{$key}, $dependencies); $object->{$key} = $cleanedText; if ($originalText != $cleanedText) { $sane = false; Logger::notice("Detected insane relation, removed invalid links in html"); } return $sane; }