/**
* Returns validated content.
*
* @param string $content
* @param string $locale
*
* @return string
*/
private function validate($content, $locale)
{
$validation = $this->markupParser->validate($content, $locale);
$regex = sprintf(self::INVALID_REGEX, $this->markupNamespace, $this->markupNamespace);
foreach ($validation as $tag => $state) {
if (false === strpos($tag, 'sulu:validation-state="' . $state . '"')) {
$newTag = preg_replace($regex, '$1 sulu:validation-state="' . $state . '"$2', $tag);
$content = str_replace($tag, $newTag, $content);
}
}
return $content;
}