Skip to content

Commit

Permalink
[TASK] Various cleanups regarding comments and API calls
Browse files Browse the repository at this point in the history
This patch is a small summary of clean ups in various
places of TYPO3 Core.

- EditDocumentController can be simplified to retrieve the closeUrl()
- Comment adaptions in GeneralUtility
- Comment adaptions and code simplification in ContentObjectRenderer
- HMENU debug option can be fetched from TSFE TypoScript directly
- TypoLinkBuilder can use "TSFE->initTemplate()" directly
  to instantiate the TemplateService, and should hand over
  proper values in the constructor.

Resolves: #84966
Releases: master
Change-Id: I145b99842eea2a2386742b1525b33a49022c9339
Reviewed-on: https://review.typo3.org/56919
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
  • Loading branch information
bmack authored and NeoBlack committed May 11, 2018
1 parent 545c3c9 commit bb42066
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 18 deletions.
Expand Up @@ -1626,7 +1626,8 @@ protected function getButtons(ServerRequestInterface $request): void
$cshButton = $buttonBar->makeHelpButton()->setModuleName('xMOD_csh_corebe')->setFieldName('TCEforms');
$buttonBar->addButton($cshButton);

if ($this->returnUrl !== $this->getCloseUrl()) {
$closeUrl = $this->getCloseUrl();
if ($this->returnUrl !== $closeUrl) {
$shortCutButton = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar()->makeShortcutButton();
$shortCutButton->setModuleName('xMOD_alt_doc.php')
->setGetVariables([
Expand All @@ -1638,10 +1639,7 @@ protected function getButtons(ServerRequestInterface $request): void
'returnNewPageId',
'noView']);
$this->moduleTemplate->getDocHeaderComponent()->getButtonBar()->addButton($shortCutButton);
}

$closeUrl = $this->getCloseUrl();
if ($this->returnUrl !== $closeUrl) {
$requestUri = GeneralUtility::linkThisScript([
'returnUrl' => $closeUrl,
]);
Expand Down
4 changes: 2 additions & 2 deletions typo3/sysext/core/Classes/Utility/GeneralUtility.php
Expand Up @@ -2075,7 +2075,7 @@ public static function mkdir($newFolder)
* sets permissions on newly created directories.
*
* @param string $directory Target directory to create. Must a have trailing slash
* @param string $deepDirectory Directory to create. This second parameter
* @param string $deepDirectory Directory to create. This second parameter is deprecated since TYPO3 v9, and will be removed in TYPO3 v10.
* @throws \InvalidArgumentException If $directory or $deepDirectory are not strings
* @throws \RuntimeException If directory could not be created
*/
Expand Down Expand Up @@ -2333,7 +2333,7 @@ public static function getAllFilesAndFoldersInPath(array $fileArr, $path, $extLi
*
* @param array $fileArr The file array to remove the prefix from
* @param string $prefixToRemove The prefix path to remove (if found as first part of string!)
* @return array The input $fileArr processed.
* @return array|string The input $fileArr processed, or a string with an error message, when an error occurred.
*/
public static function removePrefixPathFromList(array $fileArr, $prefixToRemove)
{
Expand Down
Expand Up @@ -5559,7 +5559,7 @@ protected function processUrl($context, $url, $typolinkConfiguration = [])
*
* @param string $mailAddress Email address
* @param string $linktxt Link text, default will be the email address.
* @return string Returns a numerical array with two elements: 1) $mailToUrl, string ready to be inserted into the href attribute of the <a> tag, b) $linktxt: The string between starting and ending <a> tag.
* @return array A numerical array with two elements: 1) $mailToUrl, string ready to be inserted into the href attribute of the <a> tag, b) $linktxt: The string between starting and ending <a> tag.
*/
public function getMailTo($mailAddress, $linktxt)
{
Expand Down Expand Up @@ -5730,11 +5730,7 @@ public function getQueryArguments($conf, $overruleQueryArguments = [], $forceOve
} else {
$newQueryArray = $currentQueryArray;
}
if ($forceOverruleArguments) {
ArrayUtility::mergeRecursiveWithOverrule($newQueryArray, $overruleQueryArguments);
} else {
ArrayUtility::mergeRecursiveWithOverrule($newQueryArray, $overruleQueryArguments, false);
}
ArrayUtility::mergeRecursiveWithOverrule($newQueryArray, $overruleQueryArguments, $forceOverruleArguments);
return GeneralUtility::implodeArrayForUrl('', $newQueryArray, '', false, true);
}

Expand Down
Expand Up @@ -258,7 +258,7 @@ public function start($tmpl, $sys_page, $id, $conf, $menuNumber, $objSuffix = ''
$this->conf = $conf;
$this->menuNumber = $menuNumber;
$this->mconf = $conf[$this->menuNumber . $objSuffix . '.'];
$this->debug = $tsfe->debug;
$this->debug = !empty($tsfe->config['config']['debug']);
$this->WMcObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
// In XHTML and HTML5 there is no "name" attribute anymore
switch ($tsfe->xhtmlDoctype) {
Expand Down
Expand Up @@ -16,7 +16,6 @@
*/

use TYPO3\CMS\Core\Service\DependencyOrderingService;
use TYPO3\CMS\Core\TypoScript\TemplateService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
Expand Down Expand Up @@ -196,14 +195,13 @@ public function getTypoScriptFrontendController(): TypoScriptFrontendController
// However, this is added to avoid any exceptions when trying to create a link
$GLOBALS['TSFE'] = GeneralUtility::makeInstance(
TypoScriptFrontendController::class,
[],
(int)GeneralUtility::_GP('id'),
null,
GeneralUtility::_GP('id'),
(int)GeneralUtility::_GP('type')
);
$GLOBALS['TSFE']->sys_page = GeneralUtility::makeInstance(PageRepository::class);
$GLOBALS['TSFE']->sys_page->init(false);
$GLOBALS['TSFE']->tmpl = GeneralUtility::makeInstance(TemplateService::class);
$GLOBALS['TSFE']->tmpl->init();
$GLOBALS['TSFE']->initTemplate();
}
return $GLOBALS['TSFE'];
}
Expand Down

0 comments on commit bb42066

Please sign in to comment.