Skip to content

Commit

Permalink
Merge pull request #246 from beatrycze-volk/fix-sru
Browse files Browse the repository at this point in the history
Compatibility fixes in SruController
  • Loading branch information
beatrycze-volk authored Oct 26, 2023
2 parents a3db8fa + 1e0dff2 commit fd421d0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
1 change: 0 additions & 1 deletion Build/phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
parameters:
ignoreErrors:
- '#Call to an undefined method Kitodo\\Dlf\\Domain\\Model\\Document::getCurrentDocument\(\)\.#'
- '#Parameter \#1 \$documentId of method Kitodo\\Dlf\\Controller\\AbstractController::loadDocument\(\) expects int, array given\.#'
level: 5
paths:
- ../Classes/
Expand Down
25 changes: 14 additions & 11 deletions Classes/Controller/SruController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

namespace Slub\Dfgviewer\Controller;

use Kitodo\Dlf\Domain\Model\Document;
use Kitodo\Dlf\Common\MetsDocument;
use Kitodo\Dlf\Domain\Repository\StructureRepository;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand All @@ -14,22 +12,27 @@
* Checks if the METS document contains a link to an SRU endpoint, and if so,
* adds a search form to the pageview.
*
* @package TYPO3
* @subpackage tx_dfgviewer
* @access public
* @package TYPO3
* @subpackage tx_dfgviewer
* @access public
*/
class SruController extends \Kitodo\Dlf\Controller\AbstractController
{
/**
* The main method of the controller
*
* @return void
*/
public function mainAction()
{
// Load current document.
$this->loadDocument($this->requestData);
$this->loadDocument();
if (
$this->isDocMissing()
|| !$this->document->getCurrentDocument() instanceof MetsDocument
) {
// Quit without doing anything if required variables are not set.
return '';
return;
}

// Get digital provenance information.
Expand All @@ -45,8 +48,8 @@ public function mainAction()
}

if (empty($sruLink)) {
// Quit without doing anything if required variables are not set.
return '';
// Quit without doing anything if link is not set.
return;
}

$actionUrl = $this->uriBuilder->reset()
Expand Down Expand Up @@ -81,7 +84,7 @@ protected function addSruResultsJS()
}
$javascriptFooter .= '})';

$pageRenderer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Page\PageRenderer::class);
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->addJsFooterInlineCode('tx-dfgviewer-footer', $javascriptFooter);
}
}
Expand Down

0 comments on commit fd421d0

Please sign in to comment.