Pimcore\Model\Object\ClassDefinition\Data\Relations\AbstractRelations::save PHP Метод

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

public save ( $object, array $params = [] )
$object
$params array
    public function save($object, $params = [])
    {
        $db = Db::get();
        $data = $this->getDataFromObjectParam($object, $params);
        $relations = $this->getDataForResource($data, $object, $params);
        if (is_array($relations) && !empty($relations)) {
            foreach ($relations as $relation) {
                $this->enrichRelation($object, $params, $classId, $relation);
                /*relation needs to be an array with src_id, dest_id, type, fieldname*/
                try {
                    $db->insert("object_relations_" . $classId, $relation);
                } catch (\Exception $e) {
                    Logger::error("It seems that the relation " . $relation["src_id"] . " => " . $relation["dest_id"] . " (fieldname: " . $this->getName() . ") already exist -> please check immediately!");
                    Logger::error($e);
                    // try it again with an update if the insert fails, shouldn't be the case, but it seems that
                    // sometimes the insert throws an exception
                    throw $e;
                }
            }
        }
    }