/** * Ensures allow_null is not set to FALSE on the field, as it prevents * proper auto-incrementing of a primary key. * * @param array $options */ public function __construct($options = array()) { parent::__construct($options); // Ensure allow_null is TRUE if (!$this->allow_null) { throw new Kohana_Exception(':class cannot have allow_null set to FALSE', array(':class' => get_class($this))); } }
/** * Sets the default to 0 if we have no format, or an empty string otherwise. * * @param array $options */ public function __construct($options = array()) { parent::__construct($options); if (!isset($options['default']) and !$this->allow_null) { // Having a format implies we're saving a string, so we want a proper default $this->default = $this->format ? '' : 0; } }
/** * Ensures convert_empty is not set on the field, as it prevents FALSE * from ever being set on the field. * * @param array $options */ public function __construct($options = array()) { parent::__construct($options); // Ensure convert_empty is FALSE if ($this->convert_empty) { throw new Kohana_Exception(':class cannot have convert_empty set to TRUE', array(':class' => get_class($this))); } }
/** * Ensures there is a path for saving set * * @param array $options */ public function __construct($options = array()) { parent::__construct($options); // Ensure we have path to save to if (empty($this->path) or !is_writable($this->path)) { throw new Kohana_Exception(get_class($this) . ' must have a `path` property set that points to a writable directory'); } // Make sure the path has a trailing slash $this->path = rtrim(str_replace('\\', '/', $this->path), '/') . '/'; }
/** * Ensures there is a path for saving set * * @param array $options */ public function __construct($options = array()) { parent::__construct($options); // Normalize the path $this->path = realpath(str_replace('\\', '/', $this->path)); // Ensure we have a trailing slash if (!empty($this->path) and is_writable($this->path)) { $this->path = rtrim($this->path, '/') . '/'; } else { throw new Kohana_Exception(get_class($this) . ' must have a `path` property set that points to a writable directory'); } }
/** * Ensures there is a choices array set * * @param array $options */ public function __construct($options = array()) { parent::__construct($options); // Ensure we have choices to gather values from if (empty($this->choices)) { throw new Kohana_Exception('Field_Enum must have a `choices` property set'); } // Convert non-associative values to associative ones if (!arr::is_assoc($this->choices)) { $this->choices = array_combine($this->choices, $this->choices); } }
/** * Ensures there is a path for saving set. * * @param array $options */ public function __construct($options = array()) { parent::__construct($options); // Set the path $this->path = $this->_check_path($this->path); }