Exemple #1
0
 /**
  * This constructor initializes the class.
  *
  * @access public
  * @param DB_ORM_Model $model                   a reference to the implementing model
  * @param array $metadata                       the adaptor's metadata
  * @throws Throwable_Exception                  indicates that error occurred when loading
  *                                              a configuration
  * @throws Throwable_InvalidArgument_Exception  indicates that an invalid field name
  *                                              was specified
  */
 public function __construct(DB_ORM_Model $model, array $metadata = array())
 {
     parent::__construct($model, $metadata['field']);
     $this->metadata['units'] = array();
     $group = strtolower('uom.' . $metadata['measurement'] . '.' . $metadata['units'][0]);
     if (($unit = static::config($group)) === NULL) {
         throw new Throwable_Exception('Message: Unable to load configuration. Reason: Configuration group :group is undefined.', array(':group' => $group));
     }
     $this->metadata['units'][0] = $unit;
     // field's unit
     $group = strtolower('uom.' . $metadata['measurement'] . '.' . $metadata['units'][1]);
     if (($unit = static::config($group)) === NULL) {
         throw new Throwable_Exception('Message: Unable to load configuration. Reason: Configuration group :group is undefined.', array(':group' => $group));
     }
     $this->metadata['units'][1] = $unit;
     // adaptor's unit
 }
Exemple #2
0
 /**
  * This constructor initializes the class.
  *
  * @access public
  * @param DB_ORM_Model $model                   a reference to the implementing model
  * @param array $metadata                       the adaptor's metadata
  * @throws Throwable_InvalidArgument_Exception  indicates that an invalid field name
  *                                              was specified
  */
 public function __construct(DB_ORM_Model $model, array $metadata = array())
 {
     parent::__construct($model, $metadata['field']);
     // Sets the number of decimal points.
     $this->metadata['precision'] = isset($metadata['precision']) ? (int) $metadata['precision'] : 0;
     // Sets the data type that will be used when casting value.
     $this->metadata['type'] = $this->metadata['precision'] > 0 ? 'double' : 'integer';
     // Sets the separator between the fractional and integer digits.
     $this->metadata['separator'] = isset($metadata['separator']) ? (string) $metadata['separator'] : '.';
     $this->metadata['regex'] = array();
     // Sets the regex that will be used to replace separator
     $this->metadata['regex'][0] = '/' . preg_quote($this->metadata['separator']) . '/';
     // Sets the thousands delimiter.
     $this->metadata['delimiter'] = isset($metadata['delimiter']) ? (string) $metadata['delimiter'] : ',';
     // Sets the regex that will be used to replace delimiter
     $this->metadata['regex'][1] = '/' . preg_quote($this->metadata['delimiter']) . '/';
 }
Exemple #3
0
 /**
  * This constructor initializes the class.
  *
  * @access public
  * @param DB_ORM_Model $model                   a reference to the implementing model
  * @param array $metadata                       the adaptor's metadata
  * @throws Throwable_InvalidArgument_Exception  indicates that an invalid field name
  *                                              was specified
  */
 public function __construct(DB_ORM_Model $model, array $metadata = array())
 {
     parent::__construct($model, $metadata['field']);
     $this->metadata['format'] = isset($metadata['format']) ? (string) $metadata['format'] : 'Y-m-d H:i:s';
 }
Exemple #4
0
 /**
  * This constructor initializes the class.
  *
  * @access public
  * @param DB_ORM_Model $model                   a reference to the implementing model
  * @param array $metadata                       the adaptor's metadata
  * @throws Throwable_InvalidArgument_Exception  indicates that an invalid field name
  *                                              was specified
  */
 public function __construct(DB_ORM_Model $model, array $metadata = array())
 {
     parent::__construct($model, $metadata['field']);
 }
Exemple #5
0
 /**
  * This constructor initializes the class.
  *
  * @access public
  * @param DB_ORM_Model $model                   a reference to the implementing model
  * @param array $metadata                       the adaptor's metadata
  * @throws Throwable_InvalidArgument_Exception  indicates that an invalid field name
  *                                              was specified
  */
 public function __construct(DB_ORM_Model $model, array $metadata = array())
 {
     parent::__construct($model, $metadata['field']);
     $this->metadata['config'] = isset($metadata['config']) ? $metadata['config'] : NULL;
 }
Exemple #6
0
 /**
  * This constructor initializes the class.
  *
  * @access public
  * @param DB_ORM_Model $model                   a reference to the implementing model
  * @param array $metadata                       the adaptor's metadata
  * @throws Throwable_InvalidArgument_Exception  indicates that an invalid field name
  *                                              was specified
  */
 public function __construct(DB_ORM_Model $model, array $metadata = array())
 {
     parent::__construct($model, $metadata['field']);
     $this->metadata['level'] = isset($metadata['level']) ? min(0, max(9, (int) $metadata['level'])) : 9;
 }
Exemple #7
0
 /**
  * This constructor initializes the class.
  *
  * @access public
  * @param DB_ORM_Model $model                   a reference to the implementing model
  * @param array $metadata                       the adaptor's metadata
  * @throws Throwable_InvalidArgument_Exception  indicates that an invalid field name
  *                                              was specified
  */
 public function __construct(DB_ORM_Model $model, array $metadata = array())
 {
     parent::__construct($model, $metadata['field']);
     $this->metadata['prefix'] = isset($metadata['prefix']) ? (string) $metadata['prefix'] : '';
     $this->metadata['suffix'] = isset($metadata['suffix']) ? (string) $metadata['suffix'] : '';
 }
Exemple #8
0
 /**
  * This constructor initializes the class.
  *
  * @access public
  * @param DB_ORM_Model $model                   a reference to the implementing model
  * @param array $metadata                       the adaptor's metadata
  * @throws Throwable_InvalidArgument_Exception  indicates that an invalid field name
  *                                              was specified
  */
 public function __construct(DB_ORM_Model $model, array $metadata = array())
 {
     parent::__construct($model, $metadata['field']);
     $this->metadata['class'] = (string) $metadata['class'];
 }
Exemple #9
0
 /**
  * This constructor initializes the class.
  *
  * @access public
  * @param DB_ORM_Model $model                   a reference to the implementing model
  * @param array $metadata                       the adaptor's metadata
  * @throws Throwable_InvalidArgument_Exception  indicates that an invalid field name
  *                                              was specified
  */
 public function __construct(DB_ORM_Model $model, array $metadata = array())
 {
     parent::__construct($model, $metadata['field']);
     $this->metadata['delimiter'] = isset($metadata['delimiter']) ? (string) $metadata['delimiter'] : ',';
     $this->metadata['regex'] = '/' . preg_quote($this->metadata['delimiter']) . '/';
 }
Exemple #10
0
 /**
  * This constructor initializes the class.
  *
  * @access public
  * @param DB_ORM_Model $model                   a reference to the implementing model
  * @param array $metadata                       the adaptor's metadata
  * @throws Throwable_InvalidArgument_Exception  indicates that an invalid field name
  *                                              was specified
  */
 public function __construct(DB_ORM_Model $model, array $metadata = array())
 {
     parent::__construct($model, $metadata['field']);
     $this->metadata['values'] = isset($metadata['values']) ? (array) $metadata['values'] : array('yes', 'no');
 }