Total Complexity | 7 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | class RestfulServerTestValidationFailure extends DataObject implements TestOnly |
||
16 | { |
||
17 | private static $api_access = true; |
||
|
|||
18 | |||
19 | private static $table_name = 'RestfulServerTestValidationFailure'; |
||
20 | |||
21 | private static $db = array( |
||
22 | 'Content' => 'Text', |
||
23 | 'Title' => 'Text', |
||
24 | ); |
||
25 | |||
26 | /** |
||
27 | * @return \SilverStripe\ORM\ValidationResult |
||
28 | */ |
||
29 | public function validate() |
||
30 | { |
||
31 | $result = parent::validate(); |
||
32 | |||
33 | if (strlen($this->Content) === 0) { |
||
34 | $result->addFieldError('Content', 'Content required'); |
||
35 | } |
||
36 | |||
37 | if (strlen($this->Title) === 0) { |
||
38 | $result->addFieldError('Title', 'Title required'); |
||
39 | } |
||
40 | |||
41 | return $result; |
||
42 | } |
||
43 | |||
44 | public function canView($member = null) |
||
45 | { |
||
46 | return true; |
||
47 | } |
||
48 | |||
49 | public function canEdit($member = null) |
||
50 | { |
||
51 | return true; |
||
52 | } |
||
53 | |||
54 | public function canDelete($member = null) |
||
55 | { |
||
56 | return true; |
||
57 | } |
||
58 | |||
59 | public function canCreate($member = null, $context = array()) |
||
62 | } |
||
63 | } |
||
64 |