vendor/pimcore/pimcore/models/Document/Editable/Textarea.php line 23
<?php
declare(strict_types=1);
/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/
namespace Pimcore\Model\Document\Editable;
use Pimcore\Model;
/**
* @method \Pimcore\Model\Document\Editable\Dao getDao()
*/
class Textarea extends Model\Document\Editable implements EditmodeDataInterface
{
/**
* Contains the text
*
* @internal
*/
protected ?string $text = null;
public function getType(): string
{
return 'textarea';
}
public function getData(): mixed
{
return (string) $this->text;
}
public function getText(): string
{
return $this->getData();
}
public function frontend()
{
$config = $this->getConfig();
$text = $this->text;
if (!isset($config['htmlspecialchars']) || $config['htmlspecialchars'] !== false) {
$text = htmlspecialchars($this->text);
}
if (isset($config['nl2br']) && $config['nl2br']) {
$text = nl2br($text);
}
return $text;
}
public function getDataEditmode(): string
{
return htmlentities((string)$this->text);
}
public function setDataFromResource(mixed $data): static
{
$this->text = $data;
return $this;
}
public function setDataFromEditmode(mixed $data): static
{
$data = html_entity_decode($data, ENT_HTML5); // this is because the input is now an div contenteditable -> therefore in entities
$this->text = $data;
return $this;
}
public function isEmpty(): bool
{
return empty($this->text);
}
}