-
Notifications
You must be signed in to change notification settings - Fork 0
/
GenericMetaTag.php
54 lines (45 loc) · 1.21 KB
/
GenericMetaTag.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace ilateral\SilverStripe\GenericMetaTags;
use SilverStripe\TagManager\SnippetProvider;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\TextField;
use SilverStripe\View\ArrayData;
/**
* A snippet provider that lets you add generic HTML Meta Tags
*/
class MetaTag implements SnippetProvider
{
public function getTitle()
{
return _t(static::class . ".MetaTag", 'Meta Tag');
}
public function getSummary(array $params)
{
return $params['TagName'];
}
public function getParamFields()
{
return FieldList::create(
TextField::create(
"TagName",
_t(static::class . ".TagName", 'Tag Name')
),
TextField::create(
"TagContent",
_t(static::class . ".TagContent", 'Tag Content')
)
);
}
public function getSnippets(array $params)
{
if (empty($params['TagName']) && empty($params['TagContent'])) {
return [];
}
$snippet = ArrayData::create($params)
->renderWith(static::class)
->raw();
return [
SnippetProvider::ZONE_HEAD_START => $snippet
];
}
}