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) 2017 nystudio107 |
||||
10 | */ |
||||
11 | |||||
12 | namespace nystudio107\seomatic\models; |
||||
13 | |||||
14 | use Craft; |
||||
15 | use nystudio107\seomatic\base\MetaContainer; |
||||
16 | use nystudio107\seomatic\helpers\ImageTransform as ImageTransformHelper; |
||||
17 | use nystudio107\seomatic\Seomatic; |
||||
18 | use yii\caching\TagDependency; |
||||
19 | |||||
20 | /** |
||||
21 | * @author nystudio107 |
||||
22 | * @package Seomatic |
||||
23 | * @since 3.0.0 |
||||
24 | */ |
||||
25 | class MetaLinkContainer extends MetaContainer |
||||
26 | { |
||||
27 | // Constants |
||||
28 | // ========================================================================= |
||||
29 | |||||
30 | public const CONTAINER_TYPE = 'MetaLinkContainer'; |
||||
31 | |||||
32 | // Public Properties |
||||
33 | // ========================================================================= |
||||
34 | |||||
35 | /** |
||||
36 | * The data in this container |
||||
37 | * |
||||
38 | * @var MetaLink[] $data |
||||
39 | */ |
||||
40 | public $data = []; |
||||
41 | |||||
42 | // Public Methods |
||||
43 | // ========================================================================= |
||||
44 | |||||
45 | /** |
||||
46 | * @inheritdoc |
||||
47 | */ |
||||
48 | public function includeMetaData($dependency) |
||||
49 | { |
||||
50 | Craft::beginProfile('MetaLinkContainer::includeMetaData', __METHOD__); |
||||
51 | $uniqueKey = $this->handle . $dependency->tags[3]; |
||||
52 | $cache = Craft::$app->getCache(); |
||||
53 | if ($this->clearCache) { |
||||
54 | TagDependency::invalidate($cache, $dependency->tags[3]); |
||||
55 | } |
||||
56 | $tagData = $cache->getOrSet( |
||||
57 | self::CONTAINER_TYPE . $uniqueKey, |
||||
58 | function() use ($uniqueKey) { |
||||
59 | Craft::info( |
||||
60 | self::CONTAINER_TYPE . ' cache miss: ' . $uniqueKey, |
||||
61 | __METHOD__ |
||||
62 | ); |
||||
63 | $tagData = []; |
||||
64 | if ($this->prepForInclusion()) { |
||||
65 | /** @var MetaLink $metaLinkModel */ |
||||
66 | foreach ($this->data as $metaLinkModel) { |
||||
67 | if ($metaLinkModel->include) { |
||||
68 | $configs = $metaLinkModel->tagAttributesArray(); |
||||
69 | foreach ($configs as $config) { |
||||
70 | if ($metaLinkModel->prepForRender($config)) { |
||||
71 | $tagData[] = $config; |
||||
72 | // If `devMode` is enabled, validate the Meta Link and output any model errors |
||||
73 | if (Seomatic::$devMode) { |
||||
74 | $metaLinkModel->debugMetaItem( |
||||
75 | 'Link attribute: ' |
||||
76 | ); |
||||
77 | } |
||||
78 | } |
||||
79 | } |
||||
80 | } |
||||
81 | } |
||||
82 | } |
||||
83 | |||||
84 | return $tagData; |
||||
85 | }, |
||||
86 | Seomatic::$cacheDuration, |
||||
87 | $dependency |
||||
88 | ); |
||||
89 | // Invalidate the cache we just created if there were pending image transforms in it |
||||
90 | // or we were asked to clear the cache for this container (because it's a preview request, etc.) |
||||
91 | if ($this->clearCache || ImageTransformHelper::$pendingImageTransforms) { |
||||
92 | TagDependency::invalidate($cache, $dependency->tags[3]); |
||||
93 | } |
||||
94 | // Register the tags |
||||
95 | foreach ($tagData as $config) { |
||||
96 | Seomatic::$view->registerLinkTag($config); |
||||
0 ignored issues
–
show
|
|||||
97 | } |
||||
98 | Craft::endProfile('MetaLinkContainer::includeMetaData', __METHOD__); |
||||
99 | } |
||||
100 | |||||
101 | /** |
||||
102 | * @inheritdoc |
||||
103 | */ |
||||
104 | public function normalizeContainerData() |
||||
105 | { |
||||
106 | parent::normalizeContainerData(); |
||||
107 | |||||
108 | /** @var array $config */ |
||||
109 | foreach ($this->data as $key => $config) { |
||||
110 | $config['key'] = $key; |
||||
111 | $this->data[$key] = MetaLink::create($key, $config); |
||||
0 ignored issues
–
show
$config of type nystudio107\seomatic\models\MetaLink is incompatible with the type array expected by parameter $config of nystudio107\seomatic\models\MetaLink::create() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
112 | } |
||||
113 | } |
||||
114 | } |
||||
115 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.