mirror of
https://github.com/standardebooks/web.git
synced 2025-07-15 19:06:49 -04:00
Change indexable properties to private class properties instead of public getters/setters
This commit is contained in:
parent
d05f0ea3c7
commit
388dbab1f1
1 changed files with 58 additions and 81 deletions
139
lib/Ebook.php
139
lib/Ebook.php
|
@ -43,9 +43,6 @@ use function Safe\shell_exec;
|
||||||
* @property string $TextUrl
|
* @property string $TextUrl
|
||||||
* @property string $TextSinglePageUrl
|
* @property string $TextSinglePageUrl
|
||||||
* @property string $TextSinglePageSizeFormatted
|
* @property string $TextSinglePageSizeFormatted
|
||||||
* @property ?string $IndexableText
|
|
||||||
* @property string $IndexableAuthors
|
|
||||||
* @property ?string $IndexableCollections
|
|
||||||
* @property ?EbookPlaceholder $EbookPlaceholder
|
* @property ?EbookPlaceholder $EbookPlaceholder
|
||||||
* @property array<Project> $Projects
|
* @property array<Project> $Projects
|
||||||
* @property array<Project> $PastProjects
|
* @property array<Project> $PastProjects
|
||||||
|
@ -129,9 +126,6 @@ final class Ebook{
|
||||||
protected string $_TextUrl;
|
protected string $_TextUrl;
|
||||||
protected string $_TextSinglePageUrl;
|
protected string $_TextSinglePageUrl;
|
||||||
protected string $_TextSinglePageSizeFormatted;
|
protected string $_TextSinglePageSizeFormatted;
|
||||||
protected ?string $_IndexableText = null;
|
|
||||||
protected string $_IndexableAuthors;
|
|
||||||
protected ?string $_IndexableCollections = null;
|
|
||||||
protected ?EbookPlaceholder $_EbookPlaceholder = null;
|
protected ?EbookPlaceholder $_EbookPlaceholder = null;
|
||||||
/** @var array<Project> $_Projects */
|
/** @var array<Project> $_Projects */
|
||||||
protected array $_Projects;
|
protected array $_Projects;
|
||||||
|
@ -140,6 +134,10 @@ final class Ebook{
|
||||||
protected ?Project $_ProjectInProgress;
|
protected ?Project $_ProjectInProgress;
|
||||||
protected ?Artwork $_Artwork;
|
protected ?Artwork $_Artwork;
|
||||||
|
|
||||||
|
private ?string $IndexableText = null;
|
||||||
|
private string $IndexableAuthors;
|
||||||
|
private ?string $IndexableCollections = null;
|
||||||
|
|
||||||
// *******
|
// *******
|
||||||
// GETTERS
|
// GETTERS
|
||||||
// *******
|
// *******
|
||||||
|
@ -708,64 +706,6 @@ final class Ebook{
|
||||||
return $this->_TextSinglePageSizeFormatted;
|
return $this->_TextSinglePageSizeFormatted;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function GetIndexableText(): ?string{
|
|
||||||
if(!isset($this->_IndexableText)){
|
|
||||||
$this->_IndexableText = $this->FullTitle ?? '';
|
|
||||||
|
|
||||||
$this->_IndexableText .= ' ' . $this->AlternateTitle;
|
|
||||||
|
|
||||||
foreach($this->Tags as $tag){
|
|
||||||
$this->_IndexableText .= ' ' . $tag->Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($this->LocSubjects as $subject){
|
|
||||||
$this->_IndexableText .= ' ' . $subject->Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($this->TocEntries !== null){
|
|
||||||
foreach($this->TocEntries as $item){
|
|
||||||
$this->_IndexableText .= ' ' . $item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->_IndexableText = Formatter::RemoveDiacriticsAndNonalphanumerics($this->_IndexableText);
|
|
||||||
|
|
||||||
if($this->_IndexableText == ''){
|
|
||||||
$this->_IndexableText = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->_IndexableText;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function GetIndexableAuthors(): string{
|
|
||||||
if(!isset($this->_IndexableAuthors)){
|
|
||||||
$this->_IndexableAuthors = '';
|
|
||||||
|
|
||||||
foreach($this->Authors as $author){
|
|
||||||
$this->_IndexableAuthors .= ' ' . $author->Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->_IndexableAuthors = Formatter::RemoveDiacriticsAndNonalphanumerics($this->_IndexableAuthors);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->_IndexableAuthors;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function GetIndexableCollections(): ?string{
|
|
||||||
if(!isset($this->_IndexableCollections)){
|
|
||||||
foreach($this->CollectionMemberships as $collectionMembership){
|
|
||||||
$this->_IndexableCollections .= ' ' . $collectionMembership->Collection->Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($this->_IndexableCollections)){
|
|
||||||
$this->_IndexableCollections = Formatter::RemoveDiacriticsAndNonalphanumerics($this->_IndexableCollections);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->_IndexableCollections;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function GetEbookPlaceholder(): ?EbookPlaceholder{
|
protected function GetEbookPlaceholder(): ?EbookPlaceholder{
|
||||||
if(!isset($this->_EbookPlaceholder)){
|
if(!isset($this->_EbookPlaceholder)){
|
||||||
if(!isset($this->EbookId)){
|
if(!isset($this->EbookId)){
|
||||||
|
@ -1577,27 +1517,12 @@ final class Ebook{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->IndexableText = trim($this->IndexableText ?? '');
|
$this->InitializeIndexableProperties();
|
||||||
if($this->IndexableText == ''){
|
|
||||||
$this->IndexableText = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($this->IndexableAuthors)){
|
if($this->IndexableAuthors == ''){
|
||||||
$this->IndexableAuthors = trim($this->IndexableAuthors);
|
|
||||||
|
|
||||||
if($this->IndexableAuthors == ''){
|
|
||||||
$error->Add(new Exceptions\EbookIndexableAuthorsRequiredException());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$error->Add(new Exceptions\EbookIndexableAuthorsRequiredException());
|
$error->Add(new Exceptions\EbookIndexableAuthorsRequiredException());
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->IndexableCollections = trim($this->IndexableCollections ?? '');
|
|
||||||
if($this->IndexableCollections == ''){
|
|
||||||
$this->IndexableCollections = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($this->EbookPlaceholder)){
|
if(isset($this->EbookPlaceholder)){
|
||||||
try{
|
try{
|
||||||
$this->EbookPlaceholder->Validate();
|
$this->EbookPlaceholder->Validate();
|
||||||
|
@ -1884,6 +1809,58 @@ final class Ebook{
|
||||||
return $this->WwwFilesystemPath === null;
|
return $this->WwwFilesystemPath === null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the various indexable properties that are used to search against.
|
||||||
|
*/
|
||||||
|
protected function InitializeIndexableProperties(): void{
|
||||||
|
// Initialize `IndexableText`.
|
||||||
|
$this->IndexableText = $this->FullTitle ?? '';
|
||||||
|
|
||||||
|
$this->IndexableText .= ' ' . $this->AlternateTitle;
|
||||||
|
|
||||||
|
foreach($this->Tags as $tag){
|
||||||
|
$this->IndexableText .= ' ' . $tag->Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($this->LocSubjects as $subject){
|
||||||
|
$this->IndexableText .= ' ' . $subject->Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->TocEntries !== null){
|
||||||
|
foreach($this->TocEntries as $item){
|
||||||
|
$this->IndexableText .= ' ' . $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->IndexableText = Formatter::RemoveDiacriticsAndNonalphanumerics($this->IndexableText);
|
||||||
|
|
||||||
|
if($this->IndexableText == ''){
|
||||||
|
$this->IndexableText = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize `IndexableAuthors`.
|
||||||
|
$this->IndexableAuthors = '';
|
||||||
|
|
||||||
|
foreach($this->Authors as $author){
|
||||||
|
$this->IndexableAuthors .= ' ' . $author->Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->IndexableAuthors = Formatter::RemoveDiacriticsAndNonalphanumerics($this->IndexableAuthors);
|
||||||
|
|
||||||
|
// Initialize `IndexableCollections`.
|
||||||
|
$this->IndexableCollections = '';
|
||||||
|
|
||||||
|
foreach($this->CollectionMemberships as $collectionMembership){
|
||||||
|
$this->IndexableCollections .= ' ' . $collectionMembership->Collection->Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->IndexableCollections = Formatter::RemoveDiacriticsAndNonalphanumerics($this->IndexableCollections);
|
||||||
|
|
||||||
|
if($this->IndexableCollections == ''){
|
||||||
|
$this->IndexableCollections = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the given list of elements has an element that is not `''`, return that value; otherwise, return `null`.
|
* If the given list of elements has an element that is not `''`, return that value; otherwise, return `null`.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue