Example #1
0
 /**
  * @param mixed $value
  */
 public function append($value)
 {
     if (!is_object($value)) {
         parent::append($value);
         return;
     }
     $pos = count($this->data);
     $this->index[$value->hashCode()] = $pos;
     $this->indexSplHash[spl_object_hash($value)] = $value->hashCode();
     $this->data[] = $value;
 }
Example #2
0
File: Form.php Project: c15k0/psfs
 /**
  * Método que hidrata los campos de un formulario desde un modelo
  * @param string $key
  * @param mixed $value
  * @return void
  */
 private function hydrateModelField($key, $value)
 {
     $setter = "set" . ucfirst($key);
     $getter = "get" . ucfirst($key);
     if (method_exists($this->model, $setter)) {
         if (method_exists($this->model, $getter)) {
             $tmp = $this->model->{$getter}();
             if ($tmp instanceof Collection && is_object($tmp) && gettype($value) !== gettype($tmp)) {
                 $collection = new Collection();
                 $collection->append($value);
                 $value = $collection;
             }
         }
         $this->model->{$setter}($value);
     }
 }
Example #3
0
 /**
  * @param mixed $value
  */
 public function append($value)
 {
     if (!is_object($value)) {
         parent::append($value);
         return;
     }
     $this->data[] = $value;
     end($this->data);
     $pos = key($this->data);
     $hashCode = $this->getHashCode($value);
     $this->index[$hashCode] = $pos;
     $this->indexSplHash[spl_object_hash($value)] = $hashCode;
 }