Skip to content
2 changes: 2 additions & 0 deletions Classes/Controller/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ protected function loadDocument(string $documentId = ''): void
// Sanitize FlexForm settings to avoid later casting.
$this->sanitizeSettings();

$this->documentRepository->setStoragePid($this->settings['storagePid']);

// Get document ID from request data if not passed as parameter.
if (!$documentId && !empty($this->requestData['id'])) {
$documentId = $this->requestData['id'];
Expand Down
23 changes: 22 additions & 1 deletion Classes/Controller/BasketController.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ public function injectActionLogRepository(ActionLogRepository $actionLogReposito
*/
public function basketAction(): ResponseInterface
{
$this->setStoragePid();

$basket = $this->getBasketData();

// action remove from basket
Expand Down Expand Up @@ -168,6 +170,8 @@ public function basketAction(): ResponseInterface
*/
public function addAction(): ResponseInterface
{
$this->setStoragePid();

$basket = $this->getBasketData();

if (
Expand All @@ -189,6 +193,8 @@ public function addAction(): ResponseInterface
*/
public function mainAction(): ResponseInterface
{
$this->setStoragePid();

$basket = $this->getBasketData();

$countDocs = 0;
Expand All @@ -197,7 +203,7 @@ public function mainAction(): ResponseInterface
}
$this->view->assign('countDocs', $countDocs);

$allMails = $this->mailRepository->findAllWithPid($this->settings['storagePid']);
$allMails = $this->mailRepository->findAll();

$mailSelect = [];
if (iterator_count($allMails) > 0) {
Expand Down Expand Up @@ -726,4 +732,19 @@ protected function isUserLoggedIn(): bool
$context = GeneralUtility::makeInstance(Context::class);
return $context->getPropertyFromAspect('frontend.user', 'isLoggedIn');
}

/**
* Set storage pid for repositories.
*
* @access private
*
* @return void
*/
private function setStoragePid(): void
{
$this->actionLogRepository->setStoragePid($this->settings['storagePid']);
$this->basketRepository->setStoragePid($this->settings['storagePid']);
$this->mailRepository->setStoragePid($this->settings['storagePid']);
$this->printerRepository->setStoragePid($this->settings['storagePid']);
}
}
4 changes: 4 additions & 0 deletions Classes/Controller/CalendarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public function calendarAction(): ResponseInterface
return $this->htmlResponse();
}

$this->structureRepository->setStoragePid($this->settings['storagePid']);

$calendarData = $this->buildCalendar();

// Prepare list as alternative view.
Expand Down Expand Up @@ -159,6 +161,8 @@ public function yearsAction(): ResponseInterface
return $this->htmlResponse();
}

$this->structureRepository->setStoragePid($this->settings['storagePid']);

// Get all children of anchor. This should be the year anchor documents
$documents = $this->documentRepository->getChildrenOfYearAnchor(
$this->document->getUid(),
Expand Down
3 changes: 3 additions & 0 deletions Classes/Controller/CollectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public function listAction(): ResponseInterface
return $this->htmlResponse();
}

$this->collectionRepository->setStoragePid($this->settings['storagePid']);
$this->metadataRepository->setStoragePid($this->settings['storagePid']);

// Sort collections according to order in plugin flexform configuration
if ($this->settings['collections']) {
$sortedCollections = [];
Expand Down
2 changes: 2 additions & 0 deletions Classes/Controller/FeedsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public function mainAction(): ResponseInterface
// access to GET parameter tx_dlf_feeds['collection']
$requestData = $this->request->getArguments();

$this->libraryRepository->setStoragePid($this->settings['storagePid']);

// get library information
/** @var \Kitodo\Dlf\Domain\Model\Library|null $library */
$library = $this->libraryRepository->findByUid($this->settings['library']);
Expand Down
3 changes: 3 additions & 0 deletions Classes/Controller/ListViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public function mainAction(): ResponseInterface
{
$this->search = $this->getArrayParameterSafely('search');

$this->collectionRepository->setStoragePid($this->settings['storagePid']);
$this->metadataRepository->setStoragePid($this->settings['storagePid']);

// extract collection(s) from collection parameter
$collections = [];
if (array_key_exists('collection', $this->search)) {
Expand Down
4 changes: 4 additions & 0 deletions Classes/Controller/MetadataController.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ public function mainAction(): ResponseInterface

$this->setPage();

$this->collectionRepository->setStoragePid($this->settings['storagePid']);
$this->metadataRepository->setStoragePid($this->settings['storagePid']);
$this->structureRepository->setStoragePid($this->settings['storagePid']);

$this->currentDocument = $this->document->getCurrentDocument();
$this->useOriginalIiifManifestMetadata = $this->settings['originalIiifMetadata'] == 1 && $this->currentDocument instanceof IiifManifest;

Expand Down
4 changes: 4 additions & 0 deletions Classes/Controller/OaiPmhController.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ public function mainAction(): ResponseInterface
// Get allowed GET and POST variables.
$this->getUrlParams($this->request);

$this->collectionRepository->setStoragePid((int) $this->settings['storagePid']);
$this->libraryRepository->setStoragePid((int) $this->settings['storagePid']);
$this->tokenRepository->setStoragePid((int) $this->settings['storagePid']);

// Delete expired resumption tokens.
$this->deleteExpiredTokens();

Expand Down
3 changes: 3 additions & 0 deletions Classes/Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ public function mainAction(): ResponseInterface
return $this->htmlResponse();
}

$this->collectionRepository->setStoragePid($this->settings['storagePid']);
$this->metadataRepository->setStoragePid($this->settings['storagePid']);

$this->addFieldsForExtendedSearch();

$this->enableSuggester();
Expand Down
46 changes: 46 additions & 0 deletions Classes/Domain/Repository/AbstractRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/**
* (c) Kitodo. Key to digital objects e.V. <contact@kitodo.org>
*
* This file is part of the Kitodo and TYPO3 projects.
*
* @license GNU General Public License version 3 or later.
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/

namespace Kitodo\Dlf\Domain\Repository;

use TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface;
use TYPO3\CMS\Extbase\Persistence\Repository;

/**
* Abstract Repository for allowing setting the storage pid.
*
* @package TYPO3
* @subpackage dlf
*
* @access public
*
* @template T of DomainObjectInterface
* @extends Repository<T>
*/
class AbstractRepository extends Repository
{
/**
* Sets the storage pid for the repository.
*
* @access public
*
* @param int $storagePid
*
* @return void
*/
public function setStoragePid(int $storagePid): void
{
$querySettings = $this->createQuery()->getQuerySettings();
$querySettings->setStoragePageIds([$storagePid]);
$this->setDefaultQuerySettings($querySettings);
}
}
5 changes: 2 additions & 3 deletions Classes/Domain/Repository/ActionLogRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
namespace Kitodo\Dlf\Domain\Repository;

use Kitodo\Dlf\Domain\Model\ActionLog;
use TYPO3\CMS\Extbase\Persistence\Repository;

/**
* (Basket Plugin) Action log repository for mails and printouts.
Expand All @@ -23,8 +22,8 @@
*
* @access public
*
* @extends Repository<ActionLog>
* @extends AbstractRepository<ActionLog>
*/
class ActionLogRepository extends Repository
class ActionLogRepository extends AbstractRepository
{
}
5 changes: 2 additions & 3 deletions Classes/Domain/Repository/BasketRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
namespace Kitodo\Dlf\Domain\Repository;

use Kitodo\Dlf\Domain\Model\Basket;
use TYPO3\CMS\Extbase\Persistence\Repository;

/**
* (Basket Plugin) Basket repository.
Expand All @@ -25,8 +24,8 @@
*
* @method Basket|null findOneBy(array $criteria) Get a basket by criteria
*
* @extends Repository<Basket>
* @extends AbstractRepository<Basket>
*/
class BasketRepository extends Repository
class BasketRepository extends AbstractRepository
{
}
5 changes: 2 additions & 3 deletions Classes/Domain/Repository/CollectionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Kitodo\Dlf\Domain\Model\Collection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\Repository;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;

Expand All @@ -31,9 +30,9 @@
*
* @method Collection|null findOneBy(array $criteria) Get a collection by criteria
*
* @extends Repository<Collection>
* @extends AbstractRepository<Collection>
*/
class CollectionRepository extends Repository
class CollectionRepository extends AbstractRepository
{
/**
* @access protected
Expand Down
5 changes: 2 additions & 3 deletions Classes/Domain/Repository/DocumentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Extbase\Persistence\Repository;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;

Expand All @@ -39,9 +38,9 @@
* @method Document|null findByUid(int|null $uid) Get a document by its UID
* @method Document|null findOneBy(array $criteria) Get a document by criteria
*
* @extends Repository<Document>
* @extends AbstractRepository<Document>
*/
class DocumentRepository extends Repository
class DocumentRepository extends AbstractRepository
{
/**
* @access protected
Expand Down
5 changes: 2 additions & 3 deletions Classes/Domain/Repository/FormatRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
namespace Kitodo\Dlf\Domain\Repository;

use Kitodo\Dlf\Domain\Model\Format;
use TYPO3\CMS\Extbase\Persistence\Repository;

/**
* Format repository.
Expand All @@ -23,8 +22,8 @@
*
* @access public
*
* @extends Repository<Format>
* @extends AbstractRepository<Format>
*/
class FormatRepository extends Repository
class FormatRepository extends AbstractRepository
{
}
5 changes: 2 additions & 3 deletions Classes/Domain/Repository/LibraryRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
namespace Kitodo\Dlf\Domain\Repository;

use Kitodo\Dlf\Domain\Model\Library;
use TYPO3\CMS\Extbase\Persistence\Repository;

/**
* Library repository.
Expand All @@ -26,8 +25,8 @@
* @method Library|null findByUid(int|null $uid) Get a library by its UID
* @method Library|null findOneBy(array $criteria) Get a library by criteria
*
* @extends Repository<Library>
* @extends AbstractRepository<Library>
*/
class LibraryRepository extends Repository
class LibraryRepository extends AbstractRepository
{
}
27 changes: 2 additions & 25 deletions Classes/Domain/Repository/MailRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
namespace Kitodo\Dlf\Domain\Repository;

use Kitodo\Dlf\Domain\Model\Mail;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;
use TYPO3\CMS\Extbase\Persistence\Repository;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;

/**
* Mail repository.
Expand All @@ -26,28 +22,9 @@
*
* @access public
*
* @extends Repository<Mail>
* @extends AbstractRepository<Mail>
*/
class MailRepository extends Repository
class MailRepository extends AbstractRepository
{
/**
* Find all mails by pid.
*
* @access public
*
* @param int $pid
*
* @return array<Mail>|QueryResultInterface<int, Mail>
*/
public function findAllWithPid(int $pid): array|QueryResultInterface
{
/** @var Typo3QuerySettings $querySettings */
$querySettings = GeneralUtility::makeInstance(Typo3QuerySettings::class);

$querySettings->setStoragePageIds([$pid]);

$this->setDefaultQuerySettings($querySettings);

return $this->findAll(); // @phpstan-ignore-line
}
}
5 changes: 2 additions & 3 deletions Classes/Domain/Repository/MetadataFormatRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
namespace Kitodo\Dlf\Domain\Repository;

use Kitodo\Dlf\Domain\Model\MetadataFormat;
use TYPO3\CMS\Extbase\Persistence\Repository;

/**
* Metadata format repository.
Expand All @@ -23,8 +22,8 @@
*
* @access public
*
* @extends Repository<MetadataFormat>
* @extends AbstractRepository<MetadataFormat>
*/
class MetadataFormatRepository extends Repository
class MetadataFormatRepository extends AbstractRepository
{
}
5 changes: 2 additions & 3 deletions Classes/Domain/Repository/MetadataRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
namespace Kitodo\Dlf\Domain\Repository;

use Kitodo\Dlf\Domain\Model\Metadata;
use TYPO3\CMS\Extbase\Persistence\Repository;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;

Expand All @@ -25,9 +24,9 @@
*
* @access public
*
* @extends Repository<Metadata>
* @extends AbstractRepository<Metadata>
*/
class MetadataRepository extends Repository
class MetadataRepository extends AbstractRepository
{
/**
* Finds all collection for the given settings
Expand Down
Loading
Loading