[!!!][TASK] Use native trigger_error and ErrorHandler for deprecations
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Resource / Utility / BackendUtility.php
1 <?php
2 namespace TYPO3\CMS\Core\Resource\Utility;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Localization\LanguageService;
18 use TYPO3\CMS\Core\Messaging\FlashMessage;
19 use TYPO3\CMS\Core\Resource\AbstractFile;
20 use TYPO3\CMS\Core\Utility\GeneralUtility;
21
22 /**
23 * Some Backend Utility functions for working with resources
24 */
25 class BackendUtility
26 {
27 /**
28 * Create a flash message for a file that is marked as missing
29 *
30 * @param AbstractFile $file
31 * @return FlashMessage
32 * @deprecated
33 */
34 public static function getFlashMessageForMissingFile(AbstractFile $file)
35 {
36 trigger_error('This method will be removed in TYPO3 v10, create the flash message code in your own custom code in the correct context.', E_USER_DEPRECATED);
37
38 /** @var LanguageService $lang */
39 $lang = $GLOBALS['LANG'];
40
41 /** @var FlashMessage $flashMessage */
42 $flashMessage = GeneralUtility::makeInstance(
43 FlashMessage::class,
44 $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:warning.file_missing_text') .
45 ' <abbr title="' . htmlspecialchars($file->getStorage()->getName() . ' :: ' . $file->getIdentifier()) . '">' .
46 htmlspecialchars($file->getName()) . '</abbr>',
47 $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:warning.file_missing'),
48 FlashMessage::ERROR
49 );
50
51 return $flashMessage;
52 }
53 }