|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* (c) Kitodo. Key to digital objects e.V. <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* This file is part of the Kitodo and TYPO3 projects. |
|
6
|
|
|
* |
|
7
|
|
|
* @license GNU General Public License version 3 or later. |
|
8
|
|
|
* For the full copyright and license information, please read the |
|
9
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Kitodo\Dlf\Controller; |
|
13
|
|
|
|
|
14
|
|
|
use Kitodo\Dlf\Common\Document; |
|
15
|
|
|
use Kitodo\Dlf\Common\Helper; |
|
16
|
|
|
use Psr\Log\LoggerAwareInterface; |
|
17
|
|
|
use Psr\Log\LoggerAwareTrait; |
|
18
|
|
|
use TYPO3\CMS\Core\Database\ConnectionPool; |
|
19
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
20
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* |
|
24
|
|
|
*/ |
|
25
|
|
|
abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController implements LoggerAwareInterface |
|
|
|
|
|
|
26
|
|
|
{ |
|
27
|
|
|
use LoggerAwareTrait; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Loads the current document into $this->doc |
|
31
|
|
|
* |
|
32
|
|
|
* @access protected |
|
33
|
|
|
* |
|
34
|
|
|
* @return void |
|
35
|
|
|
*/ |
|
36
|
|
|
protected function loadDocument($requestData) |
|
37
|
|
|
{ |
|
38
|
|
|
// Check for required variable. |
|
39
|
|
|
if ( |
|
40
|
|
|
!empty($requestData['id']) |
|
41
|
|
|
&& !empty($this->settings['pages']) |
|
42
|
|
|
) { |
|
43
|
|
|
// Should we exclude documents from other pages than $this->settings['pages']? |
|
44
|
|
|
$pid = (!empty($this->settings['excludeOther']) ? intval($this->settings['pages']) : 0); |
|
45
|
|
|
// Get instance of \Kitodo\Dlf\Common\Document. |
|
46
|
|
|
$this->doc = Document::getInstance($requestData['id'], $pid); |
|
|
|
|
|
|
47
|
|
|
if (!$this->doc->ready) { |
|
48
|
|
|
// Destroy the incomplete object. |
|
49
|
|
|
$this->doc = null; |
|
50
|
|
|
$this->logger->error('Failed to load document with UID ' . $requestData['id']); |
|
|
|
|
|
|
51
|
|
|
} else { |
|
52
|
|
|
// Set configuration PID. |
|
53
|
|
|
$this->doc->cPid = $this->settings['pages']; |
|
54
|
|
|
} |
|
55
|
|
|
} elseif (!empty($requestData['recordId'])) { |
|
56
|
|
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
|
57
|
|
|
->getQueryBuilderForTable('tx_dlf_documents'); |
|
58
|
|
|
|
|
59
|
|
|
// Get UID of document with given record identifier. |
|
60
|
|
|
$result = $queryBuilder |
|
61
|
|
|
->select('tx_dlf_documents.uid AS uid') |
|
62
|
|
|
->from('tx_dlf_documents') |
|
63
|
|
|
->where( |
|
64
|
|
|
$queryBuilder->expr()->eq('tx_dlf_documents.record_id', $queryBuilder->expr()->literal($requestData['recordId'])), |
|
65
|
|
|
Helper::whereExpression('tx_dlf_documents') |
|
66
|
|
|
) |
|
67
|
|
|
->setMaxResults(1) |
|
68
|
|
|
->execute(); |
|
69
|
|
|
|
|
70
|
|
|
if ($resArray = $result->fetch()) { |
|
71
|
|
|
$requestData['id'] = $resArray['uid']; |
|
72
|
|
|
// Set superglobal $_GET array and unset variables to avoid infinite looping. |
|
73
|
|
|
$_GET[$this->prefixId]['id'] = $requestData['id']; |
|
74
|
|
|
unset($requestData['recordId'], $_GET[$this->prefixId]['recordId']); |
|
75
|
|
|
// Try to load document. |
|
76
|
|
|
$this->loadDocument(); |
|
|
|
|
|
|
77
|
|
|
} else { |
|
78
|
|
|
$this->logger->error('Failed to load document with record ID "' . $requestData['recordId'] . '"'); |
|
79
|
|
|
} |
|
80
|
|
|
} else { |
|
81
|
|
|
$this->logger->error('Invalid UID ' . $requestData['id'] . ' or PID ' . $this->settings['pages'] . ' for document loading'); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths