/** * @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; }
/** * 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); } }
/** * @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; }