‪TYPO3CMS  ‪main
FormatDetailsViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
23 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
24 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
25 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
26 
32 final class ‪FormatDetailsViewHelper extends AbstractViewHelper
33 {
34  use CompileWithRenderStatic;
35  use ‪LogDataTrait;
36 
37  public function ‪initializeArguments(): void
38  {
39  $this->registerArgument('logEntry', LogEntry::class, 'Log entry instance to be rendered', true);
40  }
41 
53  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string
54  {
56  $logEntry = $arguments['logEntry'];
57  $detailString = $logEntry->getDetails();
58  $substitutes = $logEntry->getLogData();
59  // Strip paths from file names if the log was a file action
60  if ($logEntry->getType() === 2) {
61  $substitutes = ‪self::stripPathFromFilenames($substitutes);
62  }
63  return self::formatLogDetailsStatic($detailString, $substitutes);
64  }
65 
69  protected static function ‪stripPathFromFilenames(array $files = []): array
70  {
71  foreach ($files as $key => $file) {
72  $files[$key] = ‪PathUtility::basename((string)$file);
73  }
74  return $files;
75  }
76 }
‪TYPO3\CMS\Belog\ViewHelpers\FormatDetailsViewHelper\initializeArguments
‪initializeArguments()
Definition: FormatDetailsViewHelper.php:36
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:27
‪TYPO3\CMS\Belog\ViewHelpers\FormatDetailsViewHelper\renderStatic
‪static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: FormatDetailsViewHelper.php:52
‪TYPO3\CMS\Belog\ViewHelpers
‪TYPO3\CMS\Belog\ViewHelpers\FormatDetailsViewHelper
Definition: FormatDetailsViewHelper.php:33
‪TYPO3\CMS\Core\Utility\PathUtility\basename
‪static basename(string $path)
Definition: PathUtility.php:219
‪TYPO3\CMS\Belog\ViewHelpers\FormatDetailsViewHelper\stripPathFromFilenames
‪static stripPathFromFilenames(array $files=[])
Definition: FormatDetailsViewHelper.php:68
‪TYPO3\CMS\Belog\Domain\Model\LogEntry
Definition: LogEntry.php:29
‪TYPO3\CMS\Core\Log\LogDataTrait
Definition: LogDataTrait.php:25