Seomatic_Meta::getContentColumnType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * SEOmatic plugin for Craft CMS 3.x
4
 *
5
 * @link      https://nystudio107.com/
6
 * @copyright Copyright (c) 2017 nystudio107
7
 * @license   https://nystudio107.com/license
8
 */
9
10
namespace nystudio107\seomatic\fields;
11
12
use Craft;
13
use craft\base\ElementInterface;
14
use craft\base\Field;
15
use craft\helpers\Json;
16
17
use yii\db\Schema;
18
19
/**
20
 * @author    nystudio107
21
 * @package   Seomatic
22
 * @since     3.0.0
23
 */
24
class Seomatic_Meta extends Field
25
{
26
    // Public Properties
27
    // =========================================================================
28
29
    public $assetSources = [];
30
    public $seoMainEntityCategory = '';
31
    public $seoMainEntityOfPage = '';
32
    public $seoTitleSource = '';
33
    public $seoTitleSourceField = '';
34
    public $seoTitle = '';
35
    public $seoTitleSourceChangeable = true;
36
    public $seoDescriptionSource = '';
37
    public $seoDescriptionSourceField = '';
38
    public $seoDescription = '';
39
    public $seoDescriptionSourceChangeable = true;
40
    public $seoKeywordsSource = '';
41
    public $seoKeywordsSourceField = '';
42
    public $seoKeywords = '';
43
    public $seoKeywordsSourceChangeable = true;
44
    public $seoImageIdSource = '';
45
    public $seoImageIdSourceField = '';
46
    public $seoImageIdSourceChangeable = true;
47
    public $seoImageTransform = '';
48
    public $twitterCardType = '';
49
    public $twitterCardTypeChangeable = true;
50
    public $seoTwitterImageIdSource = '';
51
    public $seoTwitterImageIdSourceField = '';
52
    public $seoTwitterImageIdSourceChangeable = true;
53
    public $seoTwitterImageTransform = '';
54
    public $openGraphType = '';
55
    public $openGraphTypeChangeable = true;
56
    public $seoFacebookImageIdSource = '';
57
    public $seoFacebookImageIdSourceField = '';
58
    public $seoFacebookImageIdSourceChangeable = true;
59
    public $seoFacebookImageTransform = '';
60
    public $robots = '';
61
    public $robotsChangeable = true;
62
63
    // Static Methods
64
    // =========================================================================
65
66
    /**
67
     * @inheritdoc
68
     */
69
    public static function displayName(): string
70
    {
71
        return Craft::t('seomatic', 'SEOmatic Meta (deprecated)');
72
    }
73
74
    /**
75
     * @inheritdoc
76
     */
77
    public static function isSelectable(): bool
78
    {
79
        return false;
80
    }
81
82
    // Public Methods
83
    // =========================================================================
84
85
    /**
86
     * @inheritdoc
87
     */
88
    public function rules()
89
    {
90
        $rules = parent::rules();
91
        $rules = array_merge($rules, [
92
        ]);
93
94
        return $rules;
95
    }
96
97
    /**
98
     * @inheritdoc
99
     */
100
    public function getContentColumnType(): string
101
    {
102
        return Schema::TYPE_TEXT;
103
    }
104
105
    /**
106
     * @inheritdoc
107
     */
108
    public function normalizeValue($value, ElementInterface $element = null)
109
    {
110
        if (!empty($value)) {
111
            if (\is_string($value)) {
112
                $value = Json::decodeIfJson($value);
113
            }
114
        }
115
116
        return $value;
117
    }
118
119
    /**
120
     * @inheritdoc
121
     */
122
    public function getSettingsHtml()
123
    {
124
        return '<p>The SEOmatic Meta field type is deprecated in Craft 3. Use the SEO Settings field instead.</p>';
125
    }
126
127
    /**
128
     * @inheritdoc
129
     */
130
    public function getInputHtml($value, ElementInterface $element = null): string
131
    {
132
        return '';
133
    }
134
}
135