Save Property Dropdown Field options

@param \AvoRed\Framework\Models\Database\Property $proerty
@param \AvoRed\Ecommerce\Http\Request\PropertyRequest $request

@return void
767053
private function _saveDropdownOptions($property, $request)
    {
        if (null !== $request->get('dropdown-options')) {
            $property->propertyDropdownOptions()->delete();

            foreach ($request->get('dropdown-options') as $key => $val) {
                if ($key == '__RANDOM_STRING__') {
                    continue;
                }

                $property->propertyDropdownOptions()->create($val);
            }
        }
    }
127762
public void update(boolean submit) {

        boolean ok = (m_propertyValidationStatus == VALIDATION_OK) && (m_aliasValidationStatus == VALIDATION_OK);
        if (submit && ok) {
            saveProperties();
            saveAliases();
            hide();
        }
    }
81640
public function saveUserPref(Request $request)
    {
        if (!$request->isXmlHttpRequest()) {
            $this->app->abort(400);
        }

        $msg = $this->app->trans('Error while saving preference');
        $prop = $request->request->get('prop');
        $value = $request->request->get('value');

        $success = false;
        if (null !== $prop && null !== $value) {
            $this->getUserManipulator()->setUserSetting($this->getAuthenticatedUser(), $prop, $value);
            $success = true;
            $msg = $this->app->trans('Preference saved !');
        }

        return new JsonResponse(['success' => $success, 'message' => $msg]);
    }
582637
protected void saveProps(Properties props) throws IOException {

		if (loadFromPropertiesFile) {
			// Persist the change to the properties file.
			File file = getPropsFile();
			if (file != null) {
				FileWriter writer = new FileWriter(file);
				try {
					props.store(writer, null);
				} finally {
					writer.close();
				}
			}
		}
	}
47973
public function setProperty(&$object, $propertyName, $propertyValue)
    {
        $property = $this->getPropertyInstance($object, $propertyName);
        $property->setAccessible(true);
        $property->setValue($object, $propertyValue);
    }
1086904
protected function saveInternalProperties()
    {
        foreach ($this->internal_property_autosave as $name => $autosave) {
            if ($autosave && $this->hasSubDataObject($name)) {
                $object = $this->getSubDataObject($name);
                $object->save();
                $this->setInternalValue($name, $object->getId());
            }
        }
    }
1222904
public function beforePropertyModelSave(Property &$property, $insert)
    {
        // static values are forced to be of integer data type
        $property->data_type = Property::DATA_TYPE_INTEGER;
        return parent::beforePropertyModelSave($property, $insert);
    }
727812
public static void setProperty(String propertyName, String propertyValue) {
		try {
			FreeMarkerRender.getConfiguration().setSetting(propertyName, propertyValue);
		} catch (TemplateException e) {
			throw new RuntimeException(e);
		}
	}
1206200
private function writeProperty(
        PropertyInterface $property,
        PropertyInterface $blockProperty,
        $value,
        $index,
        NodeInterface $node,
        $userId,
        $webspaceKey,
        $languageCode,
        $segmentKey,
        $isImport = false
    ) {
        // save sub property
        $contentType = $this->contentTypeManager->get($property->getContentTypeName());
        $blockPropertyWrapper = new BlockPropertyWrapper($property, $blockProperty, $index);
        $blockPropertyWrapper->setValue($value);

        if ($isImport && $contentType instanceof ContentTypeExportInterface) {
            return $contentType->importData(
                new SuluNode($node),
                $blockPropertyWrapper,
                $value,
                $userId,
                $webspaceKey,
                $languageCode,
                $segmentKey
            );
        }

        $contentType->write(
            new SuluNode($node),
            $blockPropertyWrapper,
            $userId,
            $webspaceKey,
            $languageCode,
            $segmentKey
        );
    }
232959
public function addProperty(Property $property): void
    {
        $this->properties[(string) $property->getFqsen()] = $property;
    }
835747
protected function saveTemplateOptions(array $properties = null)
    {
        if ($properties === null) {
            $properties = $this->defaultTemplateProperties();
        }

        if ($this->areTemplateOptionsFinalized === false) {
            $this->areTemplateOptionsFinalized = true;
            $this->prepareTemplateOptions();
        }

        $key  = 'template_options';
        $prop = $this->property($key);
        $prop->setStructureMetadata($this->templateOptionsMetadata());
    }
1098172
private void saveProperties(String resourcePath, Map<String, String> properties) throws CmsException {

        CmsResource resource;
        CmsObject cms = getCmsObject();
        int pos = resourcePath.indexOf("?");
        String resName = resourcePath;
        if (pos > -1) {
            resName = resourcePath.substring(0, pos);
        }
        resource = cms.readResource(resName);

        if (properties != null) {
            for (Entry<String, String> entry : properties.entrySet()) {
                String propertyName = entry.getKey();
                String propertyValue = entry.getValue();
                if (CmsStringUtil.isEmptyOrWhitespaceOnly(propertyValue)) {
                    propertyValue = "";
                }
                try {
                    CmsProperty currentProperty = cms.readPropertyObject(resource, propertyName, false);
                    // detect if property is a null property or not
                    if (currentProperty.isNullProperty()) {
                        // create new property object and set key and value
                        currentProperty = new CmsProperty();
                        currentProperty.setName(propertyName);
                        if (OpenCms.getWorkplaceManager().isDefaultPropertiesOnStructure()) {
                            // set structure value
                            currentProperty.setStructureValue(propertyValue);
                            currentProperty.setResourceValue(null);
                        } else {
                            // set resource value
                            currentProperty.setStructureValue(null);
                            currentProperty.setResourceValue(propertyValue);
                        }
                    } else if (currentProperty.getStructureValue() != null) {
                        // structure value has to be updated
                        currentProperty.setStructureValue(propertyValue);
                        currentProperty.setResourceValue(null);
                    } else {
                        // resource value has to be updated
                        currentProperty.setStructureValue(null);
                        currentProperty.setResourceValue(propertyValue);
                    }
                    CmsLock lock = cms.getLock(resource);
                    if (lock.isUnlocked()) {
                        // lock resource before operation
                        cms.lockResource(resName);
                    }
                    // write the property to the resource
                    cms.writePropertyObject(resName, currentProperty);
                    // unlock the resource
                    cms.unlockResource(resName);
                } catch (CmsException e) {
                    // writing the property failed, log error
                    log(e.getLocalizedMessage());
                }
            }
        }
    }
406655
public function setProperty($propertyName, $propertyValue)
    {
        Validate::isString($propertyName, 'propertyName');
        Validate::notNull($propertyValue, 'propertyValue');

        $this->_customProperties[strtolower($propertyName)] = $propertyValue;
    }
335141
public function savePropertyId($propertyId, $id = false)
    {
        $em = $this->getEntityManager();
        $config = $id ? $this->find($id) : $this->findFirst();
        $config->setPropertyId($propertyId);
        $em->persist($config);
        $em->flush();
    }
295654
public void saveProperties(CmsPropertyChangeSet changes) throws CmsException {

        CmsObject cms = m_cms;
        CmsUUID structureId = changes.getTargetStructureId();
        if (m_overrideStructureId != null) {
            structureId = m_overrideStructureId;
        }
        CmsResource resource = cms.readResource(structureId, CmsResourceFilter.IGNORE_EXPIRATION);
        CmsLockActionRecord actionRecord = CmsLockUtil.ensureLock(cms, resource);
        try {
            Map<String, CmsProperty> ownProps = getPropertiesByName(cms.readPropertyObjects(resource, false));
            // determine if the title property should be changed in case of a 'NavText' change
            boolean changeOwnTitle = shouldChangeTitle(ownProps);

            String hasNavTextChange = null;
            List<CmsProperty> ownPropertyChanges = new ArrayList<CmsProperty>();
            for (CmsPropertyModification propMod : changes.getChanges()) {
                if (propMod.isFileNameProperty()) {
                    // in case of the file name property, the resource needs to be renamed
                    if ((m_overrideStructureId == null) && !resource.getStructureId().equals(propMod.getId())) {
                        if (propMod.getId() != null) {
                            throw new IllegalStateException("Invalid structure id in property changes.");
                        }
                    }
                    CmsResource.checkResourceName(propMod.getValue());
                    String oldSitePath = CmsFileUtil.removeTrailingSeparator(cms.getSitePath(resource));
                    String parentPath = CmsResource.getParentFolder(oldSitePath);
                    String newSitePath = CmsFileUtil.removeTrailingSeparator(
                        CmsStringUtil.joinPaths(parentPath, propMod.getValue()));
                    if (!oldSitePath.equals(newSitePath)) {
                        cms.moveResource(oldSitePath, newSitePath);
                    }
                    // read the resource again to update name and path
                    resource = cms.readResource(resource.getStructureId(), CmsResourceFilter.IGNORE_EXPIRATION);
                } else {
                    CmsProperty propToModify = null;
                    if ((m_overrideStructureId != null) || resource.getStructureId().equals(propMod.getId())) {

                        if (CmsPropertyDefinition.PROPERTY_NAVTEXT.equals(propMod.getName())) {
                            hasNavTextChange = propMod.getValue();
                        } else if (CmsPropertyDefinition.PROPERTY_TITLE.equals(propMod.getName())) {
                            changeOwnTitle = false;
                        }
                        propToModify = ownProps.get(propMod.getName());
                        if (propToModify == null) {
                            propToModify = new CmsProperty(propMod.getName(), null, null);
                        }
                        ownPropertyChanges.add(propToModify);
                    } else {
                        throw new IllegalStateException("Invalid structure id in property changes!");
                    }
                    String newValue = propMod.getValue();
                    if (newValue == null) {
                        newValue = "";
                    }
                    if (propMod.isStructureValue()) {
                        propToModify.setStructureValue(newValue);
                    } else {
                        propToModify.setResourceValue(newValue);
                    }
                }
            }
            if (hasNavTextChange != null) {
                if (changeOwnTitle) {
                    CmsProperty titleProp = ownProps.get(CmsPropertyDefinition.PROPERTY_TITLE);
                    if (titleProp == null) {
                        titleProp = new CmsProperty(CmsPropertyDefinition.PROPERTY_TITLE, null, null);
                    }
                    titleProp.setStructureValue(hasNavTextChange);
                    ownPropertyChanges.add(titleProp);
                }
            }
            if (!ownPropertyChanges.isEmpty()) {
                cms.writePropertyObjects(resource, ownPropertyChanges);
            }
        } finally {
            if (actionRecord.getChange() == LockChange.locked) {
                cms.unlockResource(resource);
            }
        }

    }
1235844
public function save(\Illuminate\Http\Request $request)
    {
        if (is_null($this->getModelForOptions())) {
            parent::save($request);
        }
    }
610550
public function saveTemporaryPref(Request $request)
    {
        if (!$request->isXmlHttpRequest()) {
            $this->app->abort(400);
        }

        $prop = $request->request->get('prop');
        $value = $request->request->get('value');
        $success = false;
        $msg = $this->app->trans('Error while saving preference');

        if (!is_null($prop) && !is_null($value)) {
            $this->getSession()->set('phraseanet.' . $prop, $value);
            $success = true;
            $msg = $this->app->trans('Preference saved !');
        }

        return new JsonResponse(['success' => $success, 'message' => $msg]);
    }