Pimcore\Model\Object\Classificationstore\Dao::save PHP Метод

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

public save ( )
    public function save()
    {
        $object = $this->model->object;
        $objectId = $object->getId();
        $dataTable = $this->getDataTableName();
        $fieldname = $this->model->getFieldname();
        $condition = $this->db->quoteInto("o_id = ?", $objectId) . " AND " . $this->db->quoteInto("fieldname = ?", $fieldname);
        $this->db->delete($dataTable, $condition);
        $items = $this->model->getItems();
        $collectionMapping = $this->model->getGroupCollectionMappings();
        foreach ($items as $groupId => $group) {
            foreach ($group as $keyId => $keyData) {
                $keyConfig = DefinitionCache::get($keyId);
                $fd = Service::getFieldDefinitionFromKeyConfig($keyConfig);
                foreach ($keyData as $language => $value) {
                    $collectionId = $collectionMapping[$groupId];
                    $data = ["o_id" => $objectId, "collectionId" => $collectionId, "groupId" => $groupId, "keyId" => $keyId, "fieldname" => $fieldname, "language" => $language, "type" => $keyConfig->getType()];
                    if ($fd instanceof Object\ClassDefinition\Data\Password) {
                        $value = $fd->getDataForResource($value, null, []);
                        $this->model->setLocalizedKeyValue($groupId, $keyId, $value, $language);
                    } else {
                        $value = $fd->getDataForResource($value, $this->model->object);
                    }
                    $value = $fd->marshal($value, $object);
                    $data["value"] = $value["value"];
                    $data["value2"] = $value["value2"];
                    $this->db->insertOrUpdate($dataTable, $data);
                }
            }
        }
        $groupsTable = $this->getGroupsTableName();
        $condition = $this->db->quoteInto("o_id = ?", $objectId) . " AND " . $this->db->quoteInto("fieldname = ?", $fieldname);
        $this->db->delete($groupsTable, $condition);
        $activeGroups = $this->model->getActiveGroups();
        if (is_array($activeGroups)) {
            foreach ($activeGroups as $activeGroupId => $enabled) {
                if ($enabled) {
                    $data = ["o_id" => $objectId, "groupId" => $activeGroupId, "fieldname" => $fieldname];
                    $this->db->insertOrUpdate($groupsTable, $data);
                }
            }
        }
    }