Example #1
0
 public function set($values, $value = NULL)
 {
     // Accept set($_POST, array('author', 'body'));
     // Only $_POST['author'] and $_POST['body'] will be passed
     if (is_array($values) and is_array($value)) {
         $keys = array_flip($value);
         $values = array_intersect_key($values, $keys);
         $value = NULL;
     }
     parent::set($values, $value);
     if (!empty($this->_unmapped)) {
         $related = array();
         foreach ($this->_meta->fields() as $k => $v) {
             if ($v instanceof Jelly_Field_Relationship) {
                 $related[$k] = Jelly::meta($v->foreign['model']);
             }
         }
         if (!empty($related)) {
             foreach ($this->_unmapped as $k => $v) {
                 foreach ($related as $key => $r) {
                     if ($r->fields($k) !== NULL and $r instanceof Model) {
                         $this->{$key}->set($k, $v);
                         continue;
                     }
                 }
             }
         }
     }
     return $this;
 }
Example #2
0
 public function delete($key = NULL)
 {
     if (parent::delete($key)) {
         $seed = Arr::get($_POST, '__SEED__') and Session::instance()->delete($seed);
         return TRUE;
     }
     return FALSE;
 }