1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SilverStripe\Registry\Tests\Stub; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Dev\TestOnly; |
6
|
|
|
use SilverStripe\Forms\FieldList; |
7
|
|
|
use SilverStripe\Forms\TextField; |
8
|
|
|
use SilverStripe\ORM\DataObject; |
9
|
|
|
use Silverstripe\Control\Controller; |
10
|
|
|
use SilverStripe\Registry\RegistryDataInterface; |
11
|
|
|
use SilverStripe\Registry\Tests\Stub\RegistryPageTestPage; |
12
|
|
|
|
13
|
|
|
class RegistryPageTestContactExtra extends DataObject implements RegistryDataInterface, TestOnly |
14
|
|
|
{ |
15
|
|
|
private static $table_name = 'RegistryPageTestContactExtra'; |
|
|
|
|
16
|
|
|
|
17
|
|
|
private static $use_link = true; |
|
|
|
|
18
|
|
|
|
19
|
|
|
private static $db = [ |
|
|
|
|
20
|
|
|
'FirstName' => 'Varchar(50)', |
21
|
|
|
'Surname' => 'Varchar(50)', |
22
|
|
|
]; |
23
|
|
|
|
24
|
|
|
private static $has_one = [ |
|
|
|
|
25
|
|
|
'RegistryPage' => RegistryPageTestPage::class |
26
|
|
|
]; |
27
|
|
|
|
28
|
|
|
private static $summary_fields = [ |
|
|
|
|
29
|
|
|
'FirstName' => 'First name', |
30
|
|
|
'Surname' => 'Surname', |
31
|
|
|
'RegistryPage.Title' => 'Registry Page', |
32
|
|
|
'RegistryPage.ID' => 'Registry Page ID', |
33
|
|
|
'StaticReference' => 'Other' |
34
|
|
|
]; |
35
|
|
|
|
36
|
|
|
private static $searchable_fields = [ |
|
|
|
|
37
|
|
|
'FirstName', |
38
|
|
|
'Surname', |
39
|
|
|
'RegistryPage.Title', |
40
|
|
|
'RegistryPage.ID', |
41
|
|
|
]; |
42
|
|
|
|
43
|
|
|
public function getSearchFields() |
44
|
|
|
{ |
45
|
|
|
return new FieldList( |
46
|
|
|
new TextField('FirstName', 'First name'), |
47
|
|
|
new TextField('Surname', 'Surname'), |
48
|
|
|
new TextField('RegistryPage.Title', 'Registry Page'), |
49
|
|
|
new TextField('RegistryPage.ID', 'Registry ID') |
50
|
|
|
); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function getStaticReference() |
54
|
|
|
{ |
55
|
|
|
return 'Static Reference'; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function Link($action = null) |
59
|
|
|
{ |
60
|
|
|
$page = RegistryPageTestPage::get()->filter('DataClass', RegistryPageTestContactExtra::class)->First(); |
61
|
|
|
return Controller::join_links($page->Link(), $action, $this->ID); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|