1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* SEOmatic plugin for Craft CMS |
4
|
|
|
* |
5
|
|
|
* A turnkey SEO implementation for Craft CMS that is comprehensive, powerful, |
6
|
|
|
* and flexible |
7
|
|
|
* |
8
|
|
|
* @link https://nystudio107.com |
9
|
|
|
* @copyright Copyright (c) 2019 nystudio107 |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace nystudio107\seomatic\gql\resolvers; |
13
|
|
|
|
14
|
|
|
use GraphQL\Type\Definition\ResolveInfo; |
15
|
|
|
use nystudio107\seomatic\helpers\Container as ContainerHelper; |
16
|
|
|
use nystudio107\seomatic\helpers\Gql as GqlHelper; |
17
|
|
|
use nystudio107\seomatic\helpers\Json; |
18
|
|
|
use nystudio107\seomatic\models\FrontendTemplateContainer; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Class FrontendContainerResolver |
22
|
|
|
* |
23
|
|
|
* @author nystudio107 |
24
|
|
|
* @package Seomatic |
25
|
|
|
* @since 3.4.19 |
26
|
|
|
*/ |
27
|
|
|
class FrontendContainerResolver |
28
|
|
|
{ |
29
|
|
|
// Public Methods |
30
|
|
|
// ========================================================================= |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Get the frontend container files separately |
34
|
|
|
*/ |
35
|
|
|
public static function getContainerFiles($source, array $arguments, $context, ResolveInfo $resolveInfo) |
|
|
|
|
36
|
|
|
{ |
37
|
|
|
$siteId = GqlHelper::getSiteIdFromGqlArguments($arguments); |
38
|
|
|
$typeMap = [ |
39
|
|
|
'robots' => 'robots.txt', |
40
|
|
|
'humans' => 'humans.txt', |
41
|
|
|
'ads' => 'ads.txt', |
42
|
|
|
'security' => 'security.txt', |
43
|
|
|
]; |
44
|
|
|
|
45
|
|
|
$containerData = ContainerHelper::getContainerArrays([FrontendTemplateContainer::CONTAINER_TYPE], '', $siteId); |
46
|
|
|
$decodedData = Json::decodeIfJson(reset($containerData)); |
47
|
|
|
$containerItems = []; |
48
|
|
|
|
49
|
|
|
foreach ($decodedData as $decodedItem) { |
50
|
|
|
$containerItems[key($decodedItem)] = current($decodedItem); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
if (!empty($arguments['type'])) { |
54
|
|
|
$containerItems = [ |
55
|
|
|
$arguments['type'] => $containerItems[$arguments['type']] ?? [], |
56
|
|
|
]; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
array_walk($containerItems, function(&$contents, $type) use ($typeMap) { |
60
|
|
|
$contents = [ |
61
|
|
|
'filename' => $typeMap[$type], |
62
|
|
|
'contents' => $contents, |
63
|
|
|
]; |
64
|
|
|
}); |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
return $containerItems; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.