3
0

Add types, add docblocks, minor tweaks

This commit is contained in:
brabli
2026-05-07 17:10:54 +01:00
parent 3a0cb87d37
commit 45ed9329da
+40 -34
View File
@@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace Pcm\SearchBundle\Entity; namespace Pcm\SearchBundle\Entity;
use Pcm\SearchBundle\Repository\SearchIndexRepository; use Pcm\SearchBundle\Repository\SearchIndexRepository;
@@ -7,67 +9,71 @@ use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: SearchIndexRepository::class)] #[ORM\Entity(repositoryClass: SearchIndexRepository::class)]
#[ORM\Index(name: "idx_data_fulltext", columns: ["data"], flags: ["fulltext"])] #[ORM\Index(name: "idx_data_fulltext", columns: ["data"], flags: ["fulltext"])]
class SearchIndex final class SearchIndex
{ {
#[ORM\Id] #[ORM\Id]
#[ORM\GeneratedValue] #[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')] #[ORM\Column(type: 'integer')]
private $id; private ?int $id = null;
#[ORM\Column(name: 'data', type: 'text')]
private string $searchText;
#[ORM\Column(type: 'string', length: 255)] #[ORM\Column(type: 'string', length: 255)]
private $entityClass; private string $title;
#[ORM\Column(type: 'integer')] public function __construct(
private $entityId; #[ORM\Column(type: 'string', length: 512)]
private readonly string $entityClass,
#[ORM\Column(type: 'text')] #[ORM\Column(type: 'integer')]
private $data; private readonly int $entityId,
) {}
#[ORM\Column(type: 'string', length: 255)]
private $title;
/**
* The primary key of this index row. Null until the row is persisted.
*/
public function getId(): ?int public function getId(): ?int
{ {
return $this->id; return $this->id;
} }
public function getEntityClass(): ?string /**
* The fully-qualified class name of the indexed entity.
*/
public function getEntityClass(): string
{ {
return $this->entityClass; return $this->entityClass;
} }
public function setEntityClass(string $entityClass): self /**
{ * The primary key of the indexed entity within its own table.
$this->entityClass = $entityClass; */
public function getEntityId(): int
return $this;
}
public function getEntityId(): ?int
{ {
return $this->entityId; return $this->entityId;
} }
public function setEntityId(int $entityId): self /**
* The concatenated searchable text for this entity. This is the value
* the fulltext index is matched against.
*/
public function getSearchText(): string
{ {
$this->entityId = $entityId; return $this->searchText;
}
public function setSearchText(string $searchText): self
{
$this->searchText = $searchText;
return $this; return $this;
} }
public function getData(): ?string /**
{ * The human-readable title to display for this hit in search results.
return $this->data; */
} public function getTitle(): string
public function setData(string $data): self
{
$this->data = $data;
return $this;
}
public function getTitle(): ?string
{ {
return $this->title; return $this->title;
} }