twig = $twig; $this->cptData = $cptData; $this->html = $markup; $this->twigVariables = []; $this->classes = $classes; } abstract protected function setTwigVariables(bool $isForValidation = false): void; abstract protected function renderTwig(bool $isForValidation = false): void; protected function getClasses(): string { $classes = ''; $classes .= $this->classes ? $this->classes . ' ' : ''; $classes .= $this->cptData->cssClasses ? $this->cptData->cssClasses . ' ' : ''; return $classes; } public function getMarkupValidationError(): string { $this->setTwigVariables(true); $this->renderTwig(true); preg_match('/(.*)$/', $this->html, $errorMessage); $errorMessage = $errorMessage[1] ?? ''; $errorMessage = str_replace('', '', $errorMessage); $errorMessage = trim($errorMessage); return $errorMessage; } public function getTwigVariablesForValidation(): array { $this->setTwigVariables(true); return $this->twigVariables; } }