Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAINTENANCE] Consistently use namespace declaration and avoid namespaces in code #1010

Merged
merged 5 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Classes/Command/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;

/**
Expand Down Expand Up @@ -68,7 +68,7 @@ class BaseCommand extends Command
protected $storagePid;

/**
* @var \Kitodo\Dlf\Domain\Model\Library
* @var Library
*/
protected $owner;

Expand Down Expand Up @@ -110,7 +110,7 @@ public function __construct(CollectionRepository $collectionRepository,
protected function initializeRepositories($storagePid)
{
if (MathUtility::canBeInterpretedAsInteger($storagePid)) {
$frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$frameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);

$frameworkConfiguration['persistence']['storagePid'] = MathUtility::forceIntegerInRange((int) $storagePid, 0);
$this->configurationManager->setConfiguration($frameworkConfiguration);
Expand Down
11 changes: 6 additions & 5 deletions Classes/Common/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@
use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use TYPO3\CMS\Core\Domain\Repository\PageRepository;


/**
* Helper class for the 'dlf' extension
*
Expand Down Expand Up @@ -84,14 +86,13 @@ class Helper
* @param bool $session: Should the message be saved in the user's session?
* @param string $queue: The queue's unique identifier
*
* @return \TYPO3\CMS\Core\Messaging\FlashMessageQueue The queue the message was added to
* @return FlashMessageQueue The queue the message was added to
*/
public static function addMessage($message, $title, $severity, $session = false, $queue = 'kitodo.default.flashMessages')
{
$flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
$flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($queue);
$flashMessage = GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Messaging\FlashMessage::class,
$flashMessage = GeneralUtility::makeInstance(FlashMessage::class,
$message,
$title,
$severity,
Expand Down Expand Up @@ -650,7 +651,7 @@ public static function renderFlashMessages($queue = 'kitodo.default.flashMessage
$flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
$flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($queue);
$flashMessages = $flashMessageQueue->getAllMessagesAndFlush();
$content = GeneralUtility::makeInstance(\Kitodo\Dlf\Common\KitodoFlashMessageRenderer::class)
$content = GeneralUtility::makeInstance(KitodoFlashMessageRenderer::class)
->render($flashMessages);
return $content;
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Common/IiifManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ final class IiifManifest extends AbstractDocument
protected $originalMetadataArray = [];

/**
* Holds the mime types of linked resources in the manifest (extreacted during parsing) for later use.
* Holds the mime types of linked resources in the manifest (extracted during parsing) for later use.
* @var array
* @access protected
*/
Expand Down
2 changes: 1 addition & 1 deletion Classes/Common/IiifUrlReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class IiifUrlReader implements UrlReaderInterface
/**
*
* {@inheritDoc}
* @see \Ubl\Iiif\Tools\UrlReaderInterface::getContent()
* @see UrlReaderInterface::getContent()
*/
public function getContent($url)
{
Expand Down
14 changes: 8 additions & 6 deletions Classes/Common/Indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use Kitodo\Dlf\Common\Solr\Solr;
use Kitodo\Dlf\Domain\Repository\DocumentRepository;
use Kitodo\Dlf\Domain\Model\Document;
use Solarium\Core\Query\DocumentInterface;
use Solarium\QueryType\Update\Query\Query;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Messaging\FlashMessage;
Expand Down Expand Up @@ -87,7 +89,7 @@ class Indexer
*
* @access public
*
* @param \Kitodo\Dlf\Domain\Model\Document $document: The document to add
* @param Document $document: The document to add
*
* @return bool true on success or false on failure
*/
Expand Down Expand Up @@ -296,7 +298,7 @@ protected static function loadIndexConf($pid)
*
* @access protected
*
* @param \Kitodo\Dlf\Domain\Model\Document $document: The METS document
* @param Document $document: The METS document
* @param array $logicalUnit: Array of the logical unit to process
*
* @return bool true on success or false on failure
Expand Down Expand Up @@ -425,7 +427,7 @@ protected static function processLogical(Document $document, array $logicalUnit)
*
* @access protected
*
* @param \Kitodo\Dlf\Domain\Model\Document $document: The METS document
* @param Document $document: The METS document
* @param int $page: The page number
* @param array $physicalUnit: Array of the physical unit to process
*
Expand Down Expand Up @@ -541,12 +543,12 @@ protected static function solrConnect($core, $pid = 0)
*
* @access private
*
* @param \Solarium\QueryType\Update\Query\Query $updateQuery solarium query
* @param \Kitodo\Dlf\Domain\Model\Document $document: The METS document
* @param Query $updateQuery solarium query
* @param Document $document: The METS document
* @param array $unit: Array of the logical or physical unit to process
* @param string $fullText: Text containing full text for indexing
*
* @return \Solarium\Core\Query\DocumentInterface
* @return DocumentInterface
*/
private static function getSolrDocument($updateQuery, $document, $unit, $fullText = '') {
$solrDoc = $updateQuery->createDocument();
Expand Down
3 changes: 2 additions & 1 deletion Classes/Common/KitodoFlashMessageRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace Kitodo\Dlf\Common;

use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\Renderer\FlashMessageRendererInterface;

/**
* A class representing a bootstrap flash messages.
Expand All @@ -21,7 +22,7 @@
* The created output contains all classes which are required for
* the TYPO3 backend. Any kind of message contains also a nice icon.
*/
class KitodoFlashMessageRenderer implements \TYPO3\CMS\Core\Messaging\Renderer\FlashMessageRendererInterface
class KitodoFlashMessageRenderer implements FlashMessageRendererInterface
{
/**
* @var string The message severity class names
Expand Down
11 changes: 7 additions & 4 deletions Classes/Common/Solr/Solr.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
use Kitodo\Dlf\Common\Helper;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use Solarium\Client;
use Solarium\Core\Client\Adapter\Http;
use Solarium\QueryType\Server\CoreAdmin\Result\StatusResult;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Database\ConnectionPool;
Expand Down Expand Up @@ -298,7 +301,7 @@ public static function getFields()
*
* @param mixed $core: Name or UID of the core to load or null to get core admin endpoint
*
* @return \Kitodo\Dlf\Common\Solr\Solr Instance of this class
* @return Solr Instance of this class
*/
public static function getInstance($core = null)
{
Expand Down Expand Up @@ -601,7 +604,7 @@ protected function __construct($core)
// Get Solr connection parameters from configuration.
$this->loadSolrConnectionInfo();
// Configure connection adapter.
$adapter = GeneralUtility::makeInstance(\Solarium\Core\Client\Adapter\Http::class);
$adapter = GeneralUtility::makeInstance(Http::class);
// Todo: When updating to TYPO3 >=10.x and Solarium >=6.x
// the timeout must be set with the adapter instead of the
// endpoint (see below).
Expand All @@ -627,7 +630,7 @@ protected function __construct($core)
]
];
// Instantiate Solarium\Client class.
$this->service = GeneralUtility::makeInstance(\Solarium\Client::class, $config);
$this->service = GeneralUtility::makeInstance(Client::class, $config);
$this->service->setAdapter($adapter);
// Todo: When updating to TYPO3 >=10.x and Solarium >=6.x
// $adapter and $eventDispatcher are mandatory arguments
Expand All @@ -647,7 +650,7 @@ protected function __construct($core)
if ($core !== null) {
$result = $response->getStatusResult();
if (
$result instanceof \Solarium\QueryType\Server\CoreAdmin\Result\StatusResult
$result instanceof StatusResult
&& $result->getUptime() > 0
) {
// Set core name.
Expand Down
5 changes: 3 additions & 2 deletions Classes/Controller/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\Pagination\PaginatorInterface;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;

/**
* Abstract controller class for most of the plugin controller.
Expand All @@ -32,7 +33,7 @@
* @subpackage dlf
* @access public
*/
abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController implements LoggerAwareInterface
abstract class AbstractController extends ActionController implements LoggerAwareInterface
{
use LoggerAwareTrait;

Expand All @@ -52,7 +53,7 @@ public function injectDocumentRepository(DocumentRepository $documentRepository)
/**
* This holds the current document
*
* @var \Kitodo\Dlf\Domain\Model\Document
* @var Document
* @access protected
*/
protected $document;
Expand Down
6 changes: 4 additions & 2 deletions Classes/Controller/BasketController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
use Kitodo\Dlf\Domain\Repository\MailRepository;
use Kitodo\Dlf\Domain\Repository\BasketRepository;
use Kitodo\Dlf\Domain\Repository\PrinterRepository;
use TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MailUtility;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use TYPO3\CMS\Core\Context\Context;

Expand Down Expand Up @@ -544,9 +546,9 @@ protected function sendMail()
$mailBody = $hookObj->customizeMailBody($mailText, $pdfUrl);
}
}
$from = \TYPO3\CMS\Core\Utility\MailUtility::getSystemFrom();
$from = MailUtility::getSystemFrom();
// send mail
$mail = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class);
$mail = GeneralUtility::makeInstance(MailMessage::class);
// Prepare and send the message
$mail
// subject
Expand Down
5 changes: 3 additions & 2 deletions Classes/Controller/CollectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Kitodo\Dlf\Controller;

use Kitodo\Dlf\Common\Solr\Solr;
use Kitodo\Dlf\Domain\Model\Collection;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use Kitodo\Dlf\Domain\Repository\CollectionRepository;
Expand Down Expand Up @@ -144,11 +145,11 @@ public function listAction()
*
* @access protected
*
* @param \Kitodo\Dlf\Domain\Model\Collection $collection: The collection object
* @param Collection $collection: The collection object
*
* @return void
*/
public function showAction(\Kitodo\Dlf\Domain\Model\Collection $collection)
public function showAction(Collection $collection)
{
$searchParams = $this->getParametersSafely('searchParameter');

Expand Down
3 changes: 2 additions & 1 deletion Classes/Controller/FeedsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Kitodo\Dlf\Controller;

use Kitodo\Dlf\Common\AbstractDocument;
use Kitodo\Dlf\Domain\Model\Library;
use Kitodo\Dlf\Domain\Repository\LibraryRepository;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand Down Expand Up @@ -62,7 +63,7 @@ public function mainAction()
$requestData = $this->request->getArguments();

// get library information
/** @var \Kitodo\Dlf\Domain\Model\Library|null $library */
/** @var Library|null $library */
$library = $this->libraryRepository->findByUid($this->settings['library']);

$feedMeta = [];
Expand Down
5 changes: 3 additions & 2 deletions Classes/Controller/NavigationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Kitodo\Dlf\Controller;

use Kitodo\Dlf\Domain\Model\PageSelectForm;
use TYPO3\CMS\Core\Utility\MathUtility;

/**
Expand All @@ -25,10 +26,10 @@ class NavigationController extends AbstractController
{
/**
* Method to get the page select values and use them with chash
* @param \Kitodo\Dlf\Domain\Model\PageSelectForm|NULL $pageSelectForm
* @param PageSelectForm|NULL $pageSelectForm
* @return void
*/
public function pageSelectAction(\Kitodo\Dlf\Domain\Model\PageSelectForm $pageSelectForm = NULL) {
public function pageSelectAction(PageSelectForm $pageSelectForm = NULL) {
if ($pageSelectForm) {
$uri = $this->uriBuilder->reset()
->setArguments(
Expand Down
2 changes: 1 addition & 1 deletion Classes/Controller/OaiPmhController.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ protected function verbListIdentifiers()
$this->error = 'idDoesNotExist';
return;
}
// create new and empty documentlist
// create new and empty document list
$resultSet = [];
if (is_array($documentSet)) {
$resultSet['elements'] = $documentSet;
Expand Down
3 changes: 2 additions & 1 deletion Classes/Controller/ToolboxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Kitodo\Dlf\Controller;

use Kitodo\Dlf\Common\AbstractDocument;
use Kitodo\Dlf\Common\Helper;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
Expand All @@ -29,7 +30,7 @@ class ToolboxController extends AbstractController
/**
* This holds the current document
*
* @var \Kitodo\Dlf\Common\AbstractDocument
* @var AbstractDocument
* @access private
*/
private $doc;
Expand Down
4 changes: 3 additions & 1 deletion Classes/Domain/Model/ActionLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@

namespace Kitodo\Dlf\Domain\Model;

use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;

/**
* (Basket Plugin) Action log for mails and printouts.
*
* @package TYPO3
* @subpackage dlf
* @access public
*/
class ActionLog extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
class ActionLog extends AbstractEntity
{
/**
* @var int
Expand Down
5 changes: 3 additions & 2 deletions Classes/Domain/Model/Basket.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@

namespace Kitodo\Dlf\Domain\Model;

use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;

/**
* (Basket Plugin) A basket that is bound to a frontend session.
*
* @package TYPO3
* @subpackage dlf
* @access public
*/
class Basket extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
class Basket extends AbstractEntity
{
/**
* @var string|null
Expand All @@ -41,7 +43,6 @@ class Basket extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*/
protected $sessionId;


/**
* @return string|null
*/
Expand Down
Loading