Skip to content

Commit

Permalink
[TASK] Code CleanUp and remove unused methods
Browse files Browse the repository at this point in the history
This change contains:

Clean-Ups and follow-Ups of:

* 109b203
* 776b219
  Remove `Tests/Integration/Task/IndexQueueDependencyFaker.php`


Removed methods:

* Removed unused `\ApacheSolrForTypo3\Solr\IndexQueue\Indexer::getLanguageFieldFromTable()`
* Removed deprecated `\ApacheSolrForTypo3\Solr\System\Records\Pages\PagesRepository::findAllPagesWithinNoSearchSubEntriesMarkedPagesByRootPage()`

Movements: 
* from
   `\ApacheSolrForTypo3\Solr\Domain\Site\Site::isRootPage()` 
   to 
   `\ApacheSolrForTypo3\Solr\System\Util\SiteUtility::isRootPage()`
* from
   `\ApacheSolrForTypo3\Solr\Domain\Site\Site::getRootPageIdsFromSites()`
   to
   `\ApacheSolrForTypo3\Solr\System\Util\SiteUtility::getRootPageIdsFromSites()`
* from 
   `\ApacheSolrForTypo3\Solr\Domain\Site\Site::getRootPage()`
   to
   `\ApacheSolrForTypo3\Solr\Domain\Site\Site::getRootPageRecord()`

Relates: #3376
  • Loading branch information
dkd-kaehm committed Apr 8, 2023
1 parent baed530 commit 6cffa97
Show file tree
Hide file tree
Showing 423 changed files with 2,486 additions and 8,819 deletions.
10 changes: 3 additions & 7 deletions Classes/Access/Rootline.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,11 @@ class Rootline
{
/**
* Delimiter for page and content access right elements in the rootline.
*
* @var string
*/
public const ELEMENT_DELIMITER = '/';

/**
* Storage for access rootline elements
*
* @var array
*/
protected array $rootlineElements = [];

Expand All @@ -85,7 +81,7 @@ public function __construct(string $accessRootline = null)
foreach ($rawRootlineElements as $rawRootlineElement) {
try {
$this->push(GeneralUtility::makeInstance(RootlineElement::class, /** @scrutinizer ignore-type */ $rawRootlineElement));
} catch (RootlineElementFormatException $e) {
} catch (RootlineElementFormatException) {
// just ignore the faulty element for now, might log this later
}
}
Expand Down Expand Up @@ -136,7 +132,7 @@ public static function getAccessRootlineByPageId(
$rootlineUtility = GeneralUtility::makeInstance(RootlineUtility::class, $pageId, $mountPointParameter);
try {
$rootline = $rootlineUtility->get();
} catch (RuntimeException $e) {
} catch (RuntimeException) {
$rootline = [];
}
$rootline = array_reverse($rootline);
Expand All @@ -154,7 +150,7 @@ public static function getAccessRootlineByPageId(
}
}

/** @var $pageSelector PageRepository */
/* @var PageRepository $pageSelector */
$pageSelector = GeneralUtility::makeInstance(PageRepository::class);

// current page
Expand Down
30 changes: 7 additions & 23 deletions Classes/Access/RootlineElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,62 +27,48 @@ class RootlineElement
{
/**
* Page access rootline element.
*
* @var int
*/
public const ELEMENT_TYPE_PAGE = 1;

/**
* Content access rootline element.
*
* @var int
*/
public const ELEMENT_TYPE_CONTENT = 2;

/**
* Record access rootline element.
*
* @var int
*/
public const ELEMENT_TYPE_RECORD = 3;

/**
* Delimiter between the page ID and the groups set for a page.
*
* @var string
*/
public const PAGE_ID_GROUP_DELIMITER = ':';

/**
* Access type, either page (default) or content. Depending on the type,
* access is granted differently. For pages the user must meet at least one
* group requirement, for content all group requirements must be met.
*
* @var int
*/
protected $type = self::ELEMENT_TYPE_PAGE;
protected int $type = self::ELEMENT_TYPE_PAGE;

/**
* Page Id for the element. NULL for the content type.
*
* @var int|null
*/
protected ?int $pageId = null;

/**
* Set of access groups assigned to the element.
*
* @var array
*/
protected $accessGroups = [];
protected array $accessGroups = [];

/**
* Constructor for RootlineElement.
*
* @param string $element String representation of an element in the access rootline, usually of the form pageId:commaSeparatedPageAccessGroups
* @throws RootlineElementFormatException on wrong access format.
* @throws RootlineElementFormatException on wrong access format.
*/
public function __construct($element)
public function __construct(string $element)
{
$elementAccess = explode(self::PAGE_ID_GROUP_DELIMITER, $element);

Expand Down Expand Up @@ -150,17 +136,15 @@ public function __toString()
*
* @return int ELEMENT_TYPE_PAGE for page, ELEMENT_TYPE_CONTENT for content access rootline elements
*/
public function getType()
public function getType(): int
{
return $this->type;
}

/**
* Gets the page Id for page type elements.
*
* @return int Page Id.
*/
public function getPageId()
public function getPageId(): ?int
{
return $this->pageId;
}
Expand All @@ -170,7 +154,7 @@ public function getPageId()
*
* @return array Array of user group Ids
*/
public function getGroups()
public function getGroups(): array
{
return $this->accessGroups;
}
Expand Down
4 changes: 3 additions & 1 deletion Classes/Access/RootlineElementFormatException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@

namespace ApacheSolrForTypo3\Solr\Access;

use InvalidArgumentException;

/**
* Signals a wrong format for the access definition of a page or the content.
*
* @author Ingo Renner <[email protected]>
*/
class RootlineElementFormatException extends \InvalidArgumentException
class RootlineElementFormatException extends InvalidArgumentException
{
}
29 changes: 1 addition & 28 deletions Classes/AdditionalFieldsIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,14 @@
*/
class AdditionalFieldsIndexer implements SubstitutePageIndexer
{
/**
* @var TypoScriptConfiguration
*/
protected TypoScriptConfiguration $configuration;

/**
* @var array
*/
protected array $additionalIndexingFields = [];

/**
* @var array
*/
protected array $additionalFieldNames = [];

/**
* @var ContentObjectService
*/
protected ContentObjectService $contentObjectService;

/**
* @param TypoScriptConfiguration|null $configuration
* @param ContentObjectService|null $contentObjectService
*/
public function __construct(
TypoScriptConfiguration $configuration = null,
ContentObjectService $contentObjectService = null
Expand All @@ -69,13 +53,7 @@ public function __construct(
}

/**
* Returns a substitute document for the currently being indexed page.
*
* Uses the original document and adds fields as defined in
* plugin.tx_solr.index.additionalFields.
*
* @param Document $originalPageDocument The original page document.
* @return Document A Apache Solr Document object that replace the default page document
* Returns a substituted document for the currently being indexed page.
*/
public function getPageDocument(Document $originalPageDocument): Document
{
Expand All @@ -94,8 +72,6 @@ public function getPageDocument(Document $originalPageDocument): Document

/**
* Gets the additional fields as an array mapping field names to values.
*
* @return array An array mapping additional field names to their values.
*/
protected function getAdditionalFields(): array
{
Expand All @@ -110,9 +86,6 @@ protected function getAdditionalFields(): array

/**
* Uses the page's cObj instance to resolve the additional field's value.
*
* @param string $fieldName The name of the field to get.
* @return string The field's value.
*/
protected function getFieldValue(string $fieldName): string
{
Expand Down
4 changes: 2 additions & 2 deletions Classes/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Api
* @param string $apiKey API key to check for validity
* @return bool TRUE if the API key is valid, FALSE otherwise
*/
public static function isValidApiKey($apiKey)
public static function isValidApiKey(string $apiKey): bool
{
return $apiKey === self::getApiKey();
}
Expand All @@ -38,7 +38,7 @@ public static function isValidApiKey($apiKey)
*
* @return string API key for this installation
*/
public static function getApiKey()
public static function getApiKey(): string
{
return sha1(
$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] .
Expand Down
15 changes: 1 addition & 14 deletions Classes/Backend/CoreSelectorField.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,16 @@ class CoreSelectorField
{
/**
* Site used to determine cores
*
* @var Site
*/
protected Site $site;

/**
* Form element name
*
* @var string
*/
protected string $formElementName = 'tx_solr-index-optimize-core-selector';

/**
* Selected values
*
* @var array
*/
protected array $selectedValues = [];

Expand Down Expand Up @@ -81,8 +75,6 @@ public function getFormElementName(): string

/**
* Sets the selected values.
*
* @param array $selectedValues
*/
public function setSelectedValues(array $selectedValues): void
{
Expand All @@ -91,8 +83,6 @@ public function setSelectedValues(array $selectedValues): void

/**
* Gets the selected values.
*
* @return array
*/
public function getSelectedValues(): array
{
Expand Down Expand Up @@ -159,10 +149,6 @@ protected function buildSelectorItems(array $coresToOptimize): array
}

/**
* @param array $items
* @param array $selectedValues
*
* @return string
* @throws BackendFormException
*/
protected function renderSelectCheckbox(array $items, array $selectedValues): string
Expand All @@ -175,6 +161,7 @@ protected function renderSelectCheckbox(array $items, array $selectedValues): st
'fieldTSConfig' => ['noMatchingValue_label' => ''],
];

/* @var NodeFactory $nodeFactory */
$nodeFactory = GeneralUtility::makeInstance(NodeFactory::class);
$options = [
'renderType' => 'selectCheckBox',
Expand Down
15 changes: 2 additions & 13 deletions Classes/Backend/IndexingConfigurationSelectorField.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,16 @@ class IndexingConfigurationSelectorField
{
/**
* Site used to determine indexing configurations
*
* @var Site
*/
protected Site $site;

/**
* Form element name
*
* @var string
*/
protected string $formElementName = 'tx_solr-index-queue-indexing-configuration-selector';

/**
* Selected values
*
* @var array
*/
protected array $selectedValues = [];

Expand Down Expand Up @@ -84,8 +78,6 @@ public function getFormElementName(): string

/**
* Sets the selected values.
*
* @param array $selectedValues
*/
public function setSelectedValues(array $selectedValues): void
{
Expand All @@ -95,7 +87,6 @@ public function setSelectedValues(array $selectedValues): void
/**
* Gets the selected values.
*
* @return array
* @noinspection PhpUnused
*/
public function getSelectedValues(): array
Expand Down Expand Up @@ -154,6 +145,7 @@ protected function getIndexQueueConfigurationTableMap(): array
protected function buildSelectorItems(array $tablesToIndex): array
{
$selectorItems = [];
/* @var IconRegistry $iconRegistry */
$iconRegistry = GeneralUtility::makeInstance(IconRegistry::class);
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$defaultIcon = 'mimetypes-other-other';
Expand Down Expand Up @@ -184,10 +176,6 @@ protected function buildSelectorItems(array $tablesToIndex): array
}

/**
* @param array $items
* @param array|null $selectedValues
*
* @return string
* @throws BackendFormException
*/
protected function renderSelectCheckbox(array $items, ?array $selectedValues = []): string
Expand All @@ -201,6 +189,7 @@ protected function renderSelectCheckbox(array $items, ?array $selectedValues = [
'fieldTSConfig' => ['noMatchingValue_label' => ''],
];

/* @var NodeFactory $nodeFactory */
$nodeFactory = GeneralUtility::makeInstance(NodeFactory::class);
$options = [
'type' => 'select', 'renderType' => 'selectCheckBox',
Expand Down
5 changes: 2 additions & 3 deletions Classes/Backend/SettingsPreviewOnPlugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
class SettingsPreviewOnPlugins
{
protected array $pluginsTtContentRecord;

private array $flexformData;

protected array $settings = [];

public function __construct(
Expand All @@ -52,9 +54,6 @@ public function __invoke(PageContentPreviewRenderingEvent $event): void
$event->setPreviewContent($this->getPreviewContent());
}

/**
* @return string
*/
protected function getPreviewContent(): string
{
$this->collectSummary();
Expand Down
Loading

0 comments on commit 6cffa97

Please sign in to comment.