Doctrine_Record::synchronizeWithArray PHP Метод

synchronizeWithArray() публичный Метод

it expects an array representation of a Doctrine_Record similar to the return value of the toArray() method. If the array contains relations it will create those that don't exist, update the ones that do, and delete the ones missing on the array but available on the Doctrine_Record (unlike @see fromArray() that does not touch what it is not in $array)
public synchronizeWithArray ( array $array, boolean $deep = true )
$array array representation of a Doctrine_Record
$deep boolean whether or not to act on relations
    public function synchronizeWithArray(array $array, $deep = true)
    {
        $refresh = false;
        foreach ($array as $key => $value) {
            if ($key == '_identifier') {
                $refresh = true;
                $this->assignIdentifier($value);
                continue;
            }
            if ($deep && $this->getTable()->hasRelation($key)) {
                if (!$this->{$key}) {
                    $this->refreshRelated($key);
                }
                if (is_array($value)) {
                    if (isset($value[0]) && !is_array($value[0])) {
                        $this->unlink($key, array(), false);
                        $this->link($key, $value, false);
                    } else {
                        $this->{$key}->synchronizeWithArray($value);
                    }
                }
            } else {
                if ($this->getTable()->hasField($key) || array_key_exists($key, $this->_values)) {
                    $this->set($key, $value);
                }
            }
        }
        // Eliminate relationships missing in the $array
        foreach ($this->_references as $name => $relation) {
            $rel = $this->getTable()->getRelation($name);
            if (!isset($array[$name]) && (!$rel->isOneToOne() || !isset($array[$rel->getLocalFieldName()]))) {
                unset($this->{$name});
            }
        }
        if ($refresh) {
            $this->refresh();
        }
    }