-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathDBLink.php
47 lines (40 loc) · 1.23 KB
/
DBLink.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
<?php
namespace SilverStripe\LinkField\ORM;
use SilverStripe\LinkField\Type\Registry;
use SilverStripe\ORM\FieldType\DBHTMLText;
use SilverStripe\LinkField\Form\LinkField;
use SilverStripe\Dev\Deprecation;
/**
* Represent Link object stored as a JSON string
*
* @deprecated 3.0.0 Will be removed without equivalent functionality to replace it
*/
class DBLink extends DBJson
{
public function __construct($name = null, $defaultVal = [])
{
Deprecation::withNoReplacement(function () {
Deprecation::notice('3.0.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS);
});
parent::__construct($name, $defaultVal);
}
/**
* Load the link data into a singleton Link Object
*
* @return DBHTMLText
*/
public function forTemplate()
{
$value = $this->getValue();
if ($value) {
$type = Registry::singleton()->byKey($value['typeKey']);
if ($type) {
return $type->loadLinkData($value)->forTemplate();
}
}
}
public function scaffoldFormField($title = null, $params = null)
{
return LinkField::create($this->getName(), $this->getValue());
}
}