1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* SEOmatic plugin for Craft CMS 3.x |
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\base; |
13
|
|
|
|
14
|
|
|
use Craft; |
15
|
|
|
|
16
|
|
|
use nystudio107\seomatic\helpers\MetaValue as MetaValueHelper; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @author nystudio107 |
20
|
|
|
* @package Seomatic |
21
|
|
|
* @since 3.0.0 |
22
|
|
|
*/ |
23
|
|
|
abstract class VarsModel extends FluentModel |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @inheritdoc |
27
|
|
|
*/ |
28
|
|
|
public function init() |
29
|
|
|
{ |
30
|
|
|
parent::init(); |
31
|
|
|
// For all the emojis |
32
|
|
|
$attributes = $this->attributes(); |
33
|
|
|
if ($attributes !== null) { |
|
|
|
|
34
|
|
|
foreach ($attributes as $attribute) { |
35
|
|
|
if (\is_string($this->$attribute)) { |
36
|
|
|
$this->$attribute = html_entity_decode($this->$attribute, ENT_NOQUOTES, 'UTF-8'); |
37
|
|
|
} |
38
|
|
|
} |
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
/** |
42
|
|
|
* Return the parsed value of a single property |
43
|
|
|
* |
44
|
|
|
* @param string $property |
45
|
|
|
* |
46
|
|
|
* @return string |
47
|
|
|
*/ |
48
|
|
|
public function parsedValue(string $property): string |
49
|
|
|
{ |
50
|
|
|
$result = ''; |
51
|
|
|
|
52
|
|
|
if ($this->canGetProperty($property)) { |
53
|
|
|
$result = MetaValueHelper::parseString($this->$property); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
return $result; |
57
|
|
|
} |
58
|
|
|
/** |
59
|
|
|
* Parse the model properties |
60
|
|
|
*/ |
61
|
|
|
public function parseProperties() |
62
|
|
|
{ |
63
|
|
|
Craft::beginProfile('VarsModel::parseProperties', __METHOD__); |
64
|
|
|
// Parse the meta global vars |
65
|
|
|
$attributes = $this->getAttributes(); |
66
|
|
|
MetaValueHelper::parseArray($attributes); |
67
|
|
|
$this->setAttributes($attributes); |
68
|
|
|
Craft::endProfile('VarsModel::parseProperties', __METHOD__); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|