1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Edit link for the backend. |
5
|
|
|
*/ |
6
|
|
|
declare(strict_types=1); |
7
|
|
|
|
8
|
|
|
namespace HDNET\Autoloader\ViewHelpers\Be; |
9
|
|
|
|
10
|
|
|
use TYPO3\CMS\Backend\Routing\UriBuilder; |
11
|
|
|
use TYPO3\CMS\Backend\Utility\BackendUtility; |
12
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
13
|
|
|
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Edit link for the backend. |
17
|
|
|
*/ |
18
|
|
|
class EditLinkViewHelper extends AbstractViewHelper |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Specifies whether the escaping interceptors should be disabled or enabled for the result of renderChildren() calls within this ViewHelper. |
22
|
|
|
* |
23
|
|
|
* @see isChildrenEscapingEnabled() |
24
|
|
|
* |
25
|
|
|
* Note: If this is NULL the value of $this->escapingInterceptorEnabled is considered for backwards compatibility |
26
|
|
|
* |
27
|
|
|
* @var bool |
28
|
|
|
* |
29
|
|
|
* @api |
30
|
|
|
*/ |
31
|
|
|
protected $escapeChildren = false; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Specifies whether the escaping interceptors should be disabled or enabled for the render-result of this ViewHelper. |
35
|
|
|
* |
36
|
|
|
* @see isOutputEscapingEnabled() |
37
|
|
|
* |
38
|
|
|
* @var bool |
39
|
|
|
* |
40
|
|
|
* @api |
41
|
|
|
*/ |
42
|
|
|
protected $escapeOutput = false; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Init arguments |
46
|
|
|
*/ |
47
|
|
|
public function initializeArguments() |
48
|
|
|
{ |
49
|
|
|
parent::initializeArguments(); |
50
|
|
|
$this->registerArgument('data', 'array', 'Row of the content element', true, []); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Render a edit link for the backend preview. |
55
|
|
|
* |
56
|
|
|
* @return string |
57
|
|
|
*/ |
58
|
|
|
public function render() |
59
|
|
|
{ |
60
|
|
|
$urlParameter = [ |
61
|
|
|
'edit[tt_content][' . $this->arguments['data']['uid'] . ']' => 'edit', |
62
|
|
|
'returnUrl' => GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), |
63
|
|
|
]; |
64
|
|
|
|
65
|
|
|
return '<a href="' . $this->getModuleUrl('record_edit', $urlParameter) . '">' . $this->renderChildren() . '</a>'; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* getModuleUrl. |
70
|
|
|
* |
71
|
|
|
* @param string $moduleName |
72
|
|
|
* @param array $urlParameters |
73
|
|
|
* |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
|
|
protected function getModuleUrl(string $moduleName, array $urlParameters) |
77
|
|
|
{ |
78
|
|
|
/** @var UriBuilder $uriBuilder */ |
79
|
|
|
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); |
80
|
|
|
try { |
81
|
|
|
if (!\method_exists($uriBuilder, 'buildUriFromRoute')) { |
82
|
|
|
throw new \Exception('No method', 1238); |
83
|
|
|
} |
84
|
|
|
$uri = $uriBuilder->buildUriFromRoute($moduleName, $urlParameters); |
85
|
|
|
} catch (\Exception $ex) { |
86
|
|
|
// old TYPO3 |
87
|
|
|
$uri = BackendUtility::getModuleUrl('record_edit', $urlParameters); |
|
|
|
|
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
return (string) $uri; |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.