Add types, add docblocks, minor tweaks
This commit is contained in:
+40
-34
@@ -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;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
#[ORM\Column(type: 'string', length: 512)]
|
||||||
|
private readonly string $entityClass,
|
||||||
|
|
||||||
#[ORM\Column(type: 'integer')]
|
#[ORM\Column(type: 'integer')]
|
||||||
private $entityId;
|
private readonly int $entityId,
|
||||||
|
) {}
|
||||||
#[ORM\Column(type: 'text')]
|
|
||||||
private $data;
|
|
||||||
|
|
||||||
#[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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user