Skip to content

Commit

Permalink
feat: add IndexSchema2xDocument::setMetaBool()
Browse files Browse the repository at this point in the history
  • Loading branch information
sitepark-veltrup committed Mar 7, 2024
1 parent 5f30c8b commit c1b2473
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/Service/Indexer/IndexSchema2xDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,15 @@ class IndexSchema2xDocument extends Document implements IndexDocument

public ?string $sp_citygov_function;
/**
* @var array<string,string>
* @var array<string,string|string[]>
*/
private array $metaString = [];

/**
* @var array<string,bool>
*/
private array $metaBool = [];

/**
* @param string $name
* @param string|string[] $value
Expand All @@ -135,6 +140,11 @@ public function setMetaString(string $name, string|array $value): void
$this->metaString[$name] = $value;
}

public function setMetaBool(string $name, bool $value): void
{
$this->metaBool[$name] = $value;
}

/**
* @return array<String, mixed>
*/
Expand All @@ -161,7 +171,10 @@ static function ($value, $key) {
return false;
}

if ($key === 'metaString') {
if (
$key === 'metaString' ||
$key === 'metaBool'
) {
return false;
}
return true;
Expand All @@ -172,6 +185,10 @@ static function ($value, $key) {
$fields['sp_meta_string_' . $key] = $value;
}

foreach ($this->metaBool as $key => $value) {
$fields['sp_meta_bool_' . $key] = $value;
}

return $fields;
}
}
12 changes: 12 additions & 0 deletions test/Service/Indexer/IndexSchema2xDocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,16 @@ public function testSetMetaString(): void
'unexpected meta fields'
);
}

public function testSetMetaBool(): void
{
$doc = new IndexSchema2xDocument();
$doc->setMetaBool('myname', true);

$this->assertEquals(
['sp_meta_bool_myname' => true],
$doc->getFields(),
'unexpected meta fields'
);
}
}

0 comments on commit c1b2473

Please sign in to comment.