Remove custom ViewHelper to edit record

As TYPO3 master already has necessary features.
This commit is contained in:
Daniel Siepmann 2020-01-19 13:54:38 +01:00
parent 941e7c5229
commit b63ac9b93f
3 changed files with 3 additions and 93 deletions

View file

@ -1,82 +0,0 @@
<?php
namespace DanielSiepmann\DsSite\ViewHelpers\Uri;
/*
* Copyright (C) 2019 Daniel Siepmann <coding@daniel-siepmann.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
/**
* Use this ViewHelper to provide edit links (only the uri) to records. The ViewHelper will
* pass the uid and table to FormEngine.
*
* The uid must be given as a positive integer.
* For new records, use the :ref:`<be:uri.newRecord> <typo3-backend-uri-newrecord>`.
*
* Examples
* ========
*
* URI to the record-edit action passed to FormEngine::
*
* <be:uri.editRecord uid="42" table="a_table" returnUrl="foo/bar" />
*
* ``/typo3/index.php?route=/record/edit&edit[a_table][42]=edit&returnUrl=foo/bar``
*/
class EditRecordViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
public function initializeArguments()
{
$this->registerArgument('uid', 'int', 'uid of record to be edited, 0 for creation', true);
$this->registerArgument('table', 'string', 'target database table', true);
$this->registerArgument('returnUrl', 'string', '', false, '');
$this->registerArgument('columns', 'string', 'columns to show', false, '');
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
*
* @return string
* @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string
{
if ($arguments['uid'] < 1) {
throw new \InvalidArgumentException('Uid must be a positive integer, ' . $arguments['uid'] . ' given.', 1526128259);
}
if (empty($arguments['returnUrl'])) {
$arguments['returnUrl'] = GeneralUtility::getIndpEnv('REQUEST_URI');
}
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
return (string)$uriBuilder->buildUriFromRoute('record_edit', [
'edit' => [$arguments['table'] => [$arguments['uid'] => 'edit']],
'columnsOnly' => $arguments['columns'],
'returnUrl' => $arguments['returnUrl']
]);
}
}

View file

@ -1,4 +1,5 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:be="http://typo3.org/ns/TYPO3/CMS/Backend/ViewHelpers"
data-namespace-typo3-fluid="true">
<div class="t3-page-ce-wrapper t3-page-ce-empty">
<div class="t3-page-ce t3js-page-ce">
@ -49,10 +50,10 @@
</f:section>
<f:section name="Link">
{f:uri.editRecord(
{be:uri.editRecord(
uid: recordUid,
table: 'pages',
columns: field
fields: field
)}
</f:section>
</html>

View file

@ -14,15 +14,6 @@
],
],
],
'SYS' => [
'fluid' => [
'namespaces' => [
'f' => [
$extKey => 'DanielSiepmann\DsSite\ViewHelpers',
],
],
],
],
]);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig(
"@import 'EXT:ds_site/Configuration/UserTSconfig/*.tsconfig'"