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