Skip to content

Commit

Permalink
Set spec as default name for sets
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-meyer committed Jan 11, 2024
1 parent e6a4d5d commit a1160c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Console/CsvImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
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);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/Entity/Set.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,25 +166,25 @@ public function setDescription(string $description): void
/**
* 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\-_\.!~\*\'\(\)]+)*$/');
Expand Down

0 comments on commit a1160c9

Please sign in to comment.