Commit | Line | Data |
---|---|---|
42aa9860 | 1 | <?php |
a9229942 | 2 | |
42aa9860 | 3 | namespace wcf\data\devtools\missing\language\item; |
a9229942 | 4 | |
42aa9860 MS |
5 | use wcf\data\DatabaseObject; |
6 | use wcf\data\language\Language; | |
7 | use wcf\system\language\LanguageFactory; | |
8 | use wcf\system\WCF; | |
9 | use wcf\util\JSON; | |
10 | ||
11 | /** | |
12 | * Represents a missing language item log entry. | |
a9229942 TD |
13 | * |
14 | * @author Matthias Schmidt | |
15 | * @copyright 2001-2020 WoltLab GmbH | |
16 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | |
17 | * @package WoltLabSuite\Core\Devtools\Missing\Language\Item | |
18 | * @since 5.3 | |
19 | * | |
20 | * @property-read int $itemID unique id of the missing language item log entry | |
21 | * @property-read int $languageID id of the language the missing language item was requested for | |
22 | * @property-read string $languageItem name of the missing language item | |
23 | * @property-read int $lastTime timestamp of the last time the missing language item was requested | |
24 | * @property-read string $stackTrace stack trace of how the missing language item was requested for the last time | |
42aa9860 | 25 | */ |
a9229942 TD |
26 | class DevtoolsMissingLanguageItem extends DatabaseObject |
27 | { | |
28 | /** | |
29 | * Returns the language the missing language item was requested for or `null` if the language | |
30 | * does not exist anymore. | |
31 | * | |
32 | * @return null|Language | |
33 | */ | |
34 | public function getLanguage() | |
35 | { | |
36 | if ($this->languageID === null) { | |
c0b28aa2 | 37 | return null; |
a9229942 TD |
38 | } |
39 | ||
40 | return LanguageFactory::getInstance()->getLanguage($this->languageID); | |
41 | } | |
42 | ||
43 | /** | |
44 | * Returns the formatted stack trace of how the missing language item was requested for the | |
45 | * last time. | |
46 | * | |
47 | * @return string | |
48 | */ | |
49 | public function getStackTrace() | |
50 | { | |
51 | $stackTrace = JSON::decode($this->stackTrace); | |
52 | foreach ($stackTrace as &$stackEntry) { | |
53 | foreach ($stackEntry['args'] as &$stackEntryArg) { | |
54 | if (\gettype($stackEntryArg) === 'string') { | |
55 | $stackEntryArg = \str_replace(["\n", "\t"], ['\n', '\t'], $stackEntryArg); | |
56 | } | |
57 | } | |
58 | unset($stackEntryArg); | |
59 | } | |
60 | unset($stackEntry); | |
61 | ||
62 | return WCF::getTPL()->fetch('__devtoolsMissingLanguageItemStackTrace', 'wcf', [ | |
63 | 'stackTrace' => $stackTrace, | |
64 | ]); | |
65 | } | |
42aa9860 | 66 | } |