Conditions | 5 |
Paths | 8 |
Total Lines | 21 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
45 | protected function resolve(mixed $source, array $arguments, mixed $context, ResolveInfo $resolveInfo): mixed |
||
46 | { |
||
47 | $fieldName = $resolveInfo->fieldName; |
||
48 | $result = $source[$fieldName] ?? ''; |
||
49 | // Handle the `site` virtual field |
||
50 | if ($fieldName === 'site') { |
||
51 | $result = null; |
||
52 | $siteId = $source['siteId'] ?? null; |
||
53 | if ($siteId) { |
||
54 | $site = Craft::$app->getSites()->getSiteById($siteId); |
||
55 | if ($site !== null) { |
||
56 | $result = $site->handle; |
||
57 | } |
||
58 | } |
||
59 | } |
||
60 | |||
61 | if (empty($result)) { |
||
62 | $result = null; |
||
63 | } |
||
64 | |||
65 | return $result; |
||
66 | } |
||
68 |