Adding the possibility to store more than 250 bytes in attribute values
This commit is contained in:
parent
683d940f94
commit
de816ce05c
2 changed files with 43 additions and 2 deletions
|
@ -17,6 +17,8 @@ use Neos\Flow\Annotations as Flow;
|
||||||
*/
|
*/
|
||||||
class AssetAttribute
|
class AssetAttribute
|
||||||
{
|
{
|
||||||
|
protected const MAX_VALUE_LENGTH = 250;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
|
@ -39,6 +41,12 @@ class AssetAttribute
|
||||||
*/
|
*/
|
||||||
protected array $replacementMap;
|
protected array $replacementMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="text", nullable=true)
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
protected ?string $longValue = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $value
|
* @param string $value
|
||||||
|
@ -47,7 +55,12 @@ class AssetAttribute
|
||||||
public function __construct(string $name, string $value, string $urlValue = '')
|
public function __construct(string $name, string $value, string $urlValue = '')
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->value = $value;
|
if (\mb_strlen($value) > self::MAX_VALUE_LENGTH) {
|
||||||
|
$this->longValue = $value;
|
||||||
|
$this->value = \mb_substr($value, 0, 250);
|
||||||
|
} else {
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
if (!$urlValue) {
|
if (!$urlValue) {
|
||||||
$urlValue = $value;
|
$urlValue = $value;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +92,7 @@ class AssetAttribute
|
||||||
*/
|
*/
|
||||||
public function getValue(): string
|
public function getValue(): string
|
||||||
{
|
{
|
||||||
return $this->value;
|
return $this->longValue ?? $this->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
28
Migrations/Mysql/Version20240625154316.php
Normal file
28
Migrations/Mysql/Version20240625154316.php
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Neos\Flow\Persistence\Doctrine\Migrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20240625154316 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||||
|
|
||||||
|
$this->addSql('ALTER TABLE digicomp_assetattributes_domain_model_assetattribute ADD longvalue LONGTEXT DEFAULT NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||||
|
|
||||||
|
$this->addSql('ALTER TABLE digicomp_assetattributes_domain_model_assetattribute DROP longvalue');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue