TYPO3CMS
9.5
Main Page
Related Pages
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Variables
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
Files
File List
File Members
All
$
d
e
r
u
Functions
Variables
$
e
r
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Pages
SoftReferenceParserHook.php
Go to the documentation of this file.
1
<?php
2
namespace
TYPO3\CMS\Form\Hooks
;
3
4
/*
5
* This file is part of the TYPO3 CMS project.
6
*
7
* It is free software; you can redistribute it and/or modify it under
8
* the terms of the GNU General Public License, either version 2
9
* of the License, or any later version.
10
*
11
* For the full copyright and license information, please read the
12
* LICENSE.txt file that was distributed with this source code.
13
*
14
* The TYPO3 project - inspiring people to share!
15
*/
16
17
use
TYPO3\CMS\Core\Database\SoftReferenceIndex
;
18
use
TYPO3\CMS\Core\Resource\ResourceFactory
;
19
use
TYPO3\CMS\Core\Utility\GeneralUtility
;
20
30
class
SoftReferenceParserHook
extends
SoftReferenceIndex
31
{
44
public
function
findRef
($table, $field, $uid, $content, $spKey, $spParams, $structurePath =
''
)
45
{
46
$this->tokenID_basePrefix = $table .
':'
. $uid .
':'
. $field .
':'
. $structurePath .
':'
. $spKey;
47
$tokenId = $this->
makeTokenID
($content);
48
49
$resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class);
50
51
try
{
52
$file = $resourceFactory->retrieveFileOrFolderObject($content);
53
}
catch
(\
Exception
$e) {
54
// Top level catch to ensure useful following exception handling, because FAL throws top level exceptions.
55
// TYPO3\CMS\Core\Database\ReferenceIndex::getRelations() will check the return value of this hook with is_array()
56
// so we return false to tell getRelations() to do nothing.
57
return
false
;
58
}
59
60
if
($file ===
null
) {
61
return
false
;
62
}
63
64
return
[
65
'content'
=>
'{softref:'
. $tokenId .
'}'
,
66
'elements'
=> [
67
$tokenId => [
68
'matchString'
=> $content,
69
'subst'
=> [
70
'type'
=>
'db'
,
71
'recordRef'
=>
'sys_file:'
. $file->getUid(),
72
'tokenID'
=> $tokenId,
73
'tokenValue'
=> $content
74
],
75
]
76
]
77
];
78
}
79
}
TYPO3\CMS\Form\Hooks\SoftReferenceParserHook
Definition:
SoftReferenceParserHook.php:31
TYPO3\CMS\Core\Database\SoftReferenceIndex\makeTokenID
string makeTokenID($index='')
Definition:
SoftReferenceIndex.php:699
TYPO3\CMS\Form\Hooks
Definition:
DataStructureIdentifierHook.php:3
TYPO3\CMS\Core\Resource\ResourceFactory
Definition:
ResourceFactory.php:33
TYPO3\CMS\Core\Error\Exception
Definition:
Exception.php:21
TYPO3\CMS\Form\Hooks\SoftReferenceParserHook\findRef
array bool findRef($table, $field, $uid, $content, $spKey, $spParams, $structurePath='')
Definition:
SoftReferenceParserHook.php:44
TYPO3\CMS\Core\Utility\GeneralUtility
Definition:
GeneralUtility.php:45
TYPO3\CMS\Core\Database\SoftReferenceIndex
Definition:
SoftReferenceIndex.php:80
doxygen
typo3
sysext
form
Classes
Hooks
SoftReferenceParserHook.php
Generated on Tue Oct 5 2021 01:57:40 for TYPO3CMS by
1.8.18