fieldModel = $fieldModel; $this->commentId = $commentId; } /** * @param string $for * * @return string|null */ public function render($for = "frontEnd") { $field = $this->getCommentMetaField(); if ($field) { $render = $field->render(); if ($for === "backEnd") { return $render; } return preg_replace('/width: \d+\%\;|width: \d+\%/', '', $render); } return null; } /** * @return AbstractField|null */ public function getCommentMetaField() { $notAllowed = []; if (in_array($this->fieldModel->getType(), $notAllowed)) { return null; } $className = 'ACPT_Lite\\Core\\Generators\\Meta\\Fields\\'.$this->fieldModel->getType().'Field'; $commentId = $this->commentId ? $this->commentId : 0; if (class_exists($className)) { /** @var AbstractField $instance */ $instance = new $className($this->fieldModel, MetaTypes::COMMENT, $commentId); return $instance; } return null; } }