* ``` * * @internal */ final class FormatDetailsViewHelper extends AbstractViewHelper { use LogDataTrait; public function initializeArguments(): void { $this->registerArgument('logEntry', LogEntry::class, 'Log entry instance to be rendered', true); } /** * Create formatted detail string from log row. * * The method handles two properties of the model: details and logData * Details is a string with possible %s placeholders, and logData an array * with the substitutions. * Furthermore, possible files in logData are stripped to their basename if * the action logged was a file action */ public function render(): string { /** @var LogEntry $logEntry */ $logEntry = $this->arguments['logEntry']; $detailString = $logEntry->getDetails(); $substitutes = $logEntry->getLogData(); // Strip paths from file names if the log was a file action if ($logEntry->getType() === 2) { $substitutes = self::stripPathFromFilenames($substitutes); } return self::formatLogDetailsStatic($detailString, $substitutes); } /** * Strips path from array of file names */ private static function stripPathFromFilenames(array $files = []): array { foreach ($files as $key => $file) { $files[$key] = PathUtility::basename((string)$file); } return $files; } }