/** * @param SchemaProperty $property * @param string $fieldName * @param string $object * @param int $objectId if the object has a related Id * @param int $userId * @param array $fieldIds * @param int $statusId * @param Connection $con * * @throws Exception * @throws PropelException * @return bool */ public static function updateRelatedElements($property, $fieldName, $object, $objectId, $userId, $fieldIds, $statusId, $con) { if (isset($fieldIds[$fieldName])) { $profileId = $fieldIds[$fieldName]['id']; } else { return false; } $language = $fieldIds[$fieldName]['hasLang'] ? $property->getLanguage() : null; $element = SchemaPropertyElementPeer::lookupDetailElement($property->getId(), $profileId, $language); if ($element) { //no matter what we do, it's not generated any more $element->setIsGenerated(false); //did we make it null? if (0 === strlen(trim($object))) { //we have to make sure that it's not a subclass or subproperty if (('is_subproperty_of' == $fieldName || 'is_subclass_of' == $fieldName) && $property->getParentUri()) { //there's a uri but it doesn't match anything registered //so we have to delete just the reciprocal $element->updateReciprocal('deleted', $userId, $property->getSchemaId(), $con); } else { //delete the element $element->delete($con); } } else { //modify it $element->setObject($object); $element->setRelatedSchemaPropertyId($objectId); $element->setUpdatedUserId($userId); $element->save(); } } elseif ($profileId && $object) { //create one $element = SchemaPropertyElementPeer::createElement($property, $userId, $profileId, $statusId, $language, false); $element->setObject($object); $element->setRelatedSchemaPropertyId($objectId); $element->setIsSchemaProperty(TRUE); $element->save(); } return true; }