Craft\NeoService::saveStructure PHP Method

saveStructure() public method

Saves the structure for a field to the database.
public saveStructure ( craft\StructureModel $structure, NeoFieldType $fieldType ) : boolean
$structure craft\StructureModel
$fieldType NeoFieldType
return boolean
    public function saveStructure(StructureModel $structure, NeoFieldType $fieldType)
    {
        $owner = $fieldType->element;
        $field = $fieldType->model;
        $locale = $this->_getFieldLocale($fieldType);
        $blockStructure = new Neo_BlockStructureRecord();
        $transaction = $this->beginTransaction();
        try {
            $this->deleteStructure($fieldType);
            craft()->structures->saveStructure($structure);
            $blockStructure->structureId = $structure->id;
            $blockStructure->ownerId = $owner->id;
            $blockStructure->ownerLocale = $locale;
            $blockStructure->fieldId = $field->id;
            $blockStructure->save(false);
            $this->commitTransaction($transaction);
        } catch (\Exception $e) {
            $this->rollbackTransaction($transaction);
            throw $e;
        }
        return true;
    }