-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[!!!][TASK] Replace custom TranslateViewHelper with LanguagePathViewH…
…elper
- Loading branch information
Showing
10 changed files
with
92 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
namespace TYPO3\CMS\ContentBlocks\ViewHelpers; | ||
|
||
use TYPO3\CMS\ContentBlocks\Registry\ContentBlockRegistry; | ||
use TYPO3\CMS\ContentBlocks\Utility\ContentBlockPathUtility; | ||
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 TYPO3Fluid\Fluid\Exception; | ||
|
||
/** | ||
* LanguagePathViewHelper | ||
* | ||
* ONLY TO BE USED INSIDE CONTENT BLOCKS | ||
* | ||
* Examples | ||
* ======== | ||
* | ||
* <f:translate key="{cb:languagePath()}:header" /> | ||
*/ | ||
class LanguagePathViewHelper extends AbstractViewHelper | ||
{ | ||
use CompileWithRenderStatic; | ||
|
||
public function initializeArguments(): void | ||
{ | ||
$this->registerArgument('name', 'string', 'The vendor/package of the Content Block.'); | ||
} | ||
|
||
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string | ||
{ | ||
$name = (string)($arguments['name'] ?? $renderingContext->getVariableProvider()->get('data._name')); | ||
if ($name === '') { | ||
throw new Exception(__CLASS__ . ' seemingly called outside Content Blocks context.', 1699271759); | ||
} | ||
$contentBlockRegistry = GeneralUtility::makeInstance(ContentBlockRegistry::class); | ||
if (!$contentBlockRegistry->hasContentBlock($name)) { | ||
throw new Exception('Content block with the name "' . $name . '" is not registered.', 1699272189); | ||
} | ||
$languagePath = 'LLL:' . $contentBlockRegistry->getContentBlockExtPath($name) . '/' . ContentBlockPathUtility::getLanguageFilePath(); | ||
return $languagePath; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters