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