Set spec as default name for sets

This commit is contained in:
Sebastian Meyer 2024-01-11 14:49:43 +01:00
parent e6a4d5d508
commit a1160c9cbd
2 changed files with 7 additions and 7 deletions

View File

@ -149,9 +149,9 @@ class CsvImportCommand extends Console
}
if (isset($columns['setColumn'])) {
$sets = $row[$columns['setColumn']];
foreach (explode(',', trim($sets)) as $set) {
foreach (explode(',', $sets) as $set) {
/** @var Set */
$setSpec = Database::getInstance()->getEntityManager()->getReference(Set::class, $set);
$setSpec = Database::getInstance()->getEntityManager()->getReference(Set::class, trim($set));
$record->addSet($setSpec);
}
}

View File

@ -166,25 +166,25 @@ class Set extends Entity
/**
* Set the name for this set.
*
* @param string $name The name
* @param ?string $name The name (defaults to spec)
*
* @return void
*/
public function setName(string $name): void
public function setName(?string $name): void
{
$this->name = trim($name);
$this->name = $name ?? $this->getSpec();
}
/**
* Get new entity of set.
*
* @param string $spec The set spec
* @param string $name The name of the set
* @param ?string $name The name of the set (defaults to spec)
* @param string $description The description of the set
*
* @throws ValidationFailedException
*/
public function __construct(string $spec, string $name, string $description = '')
public function __construct(string $spec, ?string $name = null, string $description = '')
{
try {
$this->spec = $this->validateRegEx($spec, '/^([A-Za-z0-9\-_\.!~\*\'\(\)])+(:[A-Za-z0-9\-_\.!~\*\'\(\)]+)*$/');