Ejemplo n.º 1
0
 public function __construct($id)
 {
     parent::__construct();
     if (!$id instanceof \MongoId) {
         $id = new \MongoId($id);
     }
     $this->id = $id;
 }
Ejemplo n.º 2
0
 public function __construct()
 {
     parent::__construct();
     $this->_display = new Display();
     $this->_display->attach('Url', new Url(), true);
     $this->_display->attach('Time', new Time(), true);
     $this->_display->attach('MongoDoc', new MongoDoc(), true);
     $this->_mail = new Mail();
     $this->_user = new SimpleUser(null);
 }
Ejemplo n.º 3
0
 /**
  * Set model attributes.
  *
  * @param $attributesValues
  */
 public function setAttributesValues($attributesValues)
 {
     foreach ($this->attributes as $key => $rules) {
         if (array_key_exists($key, $attributesValues)) {
             if (array_key_exists('maxLength', $rules) && Model::checkMaxLength($attributesValues[$key], $rules['maxLength'])) {
                 Router::ErrorResponse('Field ' . $key . ' max length ' . $rules[maxLength] . '.');
                 die;
             }
             $this->attributesValues[$key] = $attributesValues[$key];
         } elseif (array_key_exists('nullable', $rules) && $rules['nullable'] == false) {
             Router::ErrorResponse('Field ' . $key . ' is required.');
             die;
         }
     }
 }