silverstripe /
silverstripe-restfulserver
| 1 | <?php |
||
| 2 | |||
| 3 | namespace SilverStripe\RestfulServer\Tests\Stubs; |
||
| 4 | |||
| 5 | use SilverStripe\Dev\TestOnly; |
||
| 6 | use SilverStripe\ORM\DataObject; |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Class RestfulServerTestValidationFailure |
||
| 10 | * @package SilverStripe\RestfulServer\Tests\Stubs |
||
| 11 | * |
||
| 12 | * @property string Content |
||
| 13 | * @property string Title |
||
| 14 | */ |
||
| 15 | class RestfulServerTestValidationFailure extends DataObject implements TestOnly |
||
| 16 | { |
||
| 17 | private static $api_access = true; |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 18 | |||
| 19 | private static $table_name = 'RestfulServerTestValidationFailure'; |
||
|
0 ignored issues
–
show
|
|||
| 20 | |||
| 21 | private static $db = array( |
||
|
0 ignored issues
–
show
|
|||
| 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()) |
||
| 60 | { |
||
| 61 | return true; |
||
| 62 | } |
||
| 63 | } |
||
| 64 |