1 | <?php defined('SYSPATH') OR die('No direct script access.'); |
||
14 | abstract class Kohana_Jam_Field_Boolean extends Jam_Field { |
||
15 | |||
16 | /** |
||
17 | * @var mixed how TRUE is represented in the database |
||
18 | */ |
||
19 | public $true = 1; |
||
20 | |||
21 | /** |
||
22 | * @var mixed how FALSE is represented in the database |
||
23 | */ |
||
24 | public $false = 0; |
||
25 | |||
26 | /** |
||
27 | * @var boolean null values are not allowed |
||
28 | */ |
||
29 | public $allow_null = FALSE; |
||
30 | |||
31 | /** |
||
32 | * @var boolean default value is FALSE, since NULL isn't allowed |
||
33 | */ |
||
34 | public $default = FALSE; |
||
35 | |||
36 | /** |
||
37 | * Ensures convert_empty is not set on the field, as it prevents FALSE |
||
38 | * from ever being set on the field. |
||
39 | * |
||
40 | * @param array $options |
||
41 | */ |
||
42 | 6 | public function __construct($options = array()) |
|
43 | { |
||
44 | 6 | parent::__construct($options); |
|
45 | |||
46 | // Ensure convert_empty is FALSE |
||
47 | 6 | if ($this->convert_empty) |
|
48 | { |
||
49 | 1 | throw new Kohana_Exception(':class cannot have convert_empty set to TRUE', array( |
|
50 | 1 | ':class' => get_class($this))); |
|
51 | } |
||
52 | 5 | } |
|
53 | |||
54 | /** |
||
55 | * Validates a boolean out of the value with filter_var. |
||
56 | * |
||
57 | * @param mixed $value |
||
58 | * @return void |
||
59 | */ |
||
60 | 27 | public function set(Jam_Validated $model, $value, $is_changed) |
|
71 | |||
72 | } // End Kohana_Jam_Field_Boolean |
||
73 |