private function savePropertiesDirectly(Remote\Model $object)
    {
        foreach ($object::getProperties() as $property_name => $meta) {
            if ($meta[Remote\Model::KEY_SAVE_DIRECTLY] && $object->isDirty($property_name)) {
                //Then actually save
                $property_objects = $object->$property_name;
                /** @var Remote\Model $property_type */
                $property_type = get_class(current($property_objects));

                $url = new URL($this, sprintf('%s/%s/%s', $object::getResourceURI(), $object->getGUID(), $property_type::getResourceURI()));
                $request = new Request($this, $url, Request::METHOD_PUT);

                $property_array = [];
                /** @var Remote\Model[] $property_objects */
                foreach ($property_objects as $property_object) {
                    $property_array[] = $property_object->toStringArray(false);
                }

                $root_node_name = Helpers::pluralize($property_type::getRootNodeName());
                $request->setBody(Helpers::arrayToXML([$root_node_name => $property_array]));

                $request->send();

                $response = $request->getResponse();
                foreach ($response->getElements() as $element_index => $element) {
                    if ($response->getErrorsForElement($element_index) === null) {
                        $property_objects[$element_index]->fromStringArray($element);
                        $property_objects[$element_index]->setClean();
                    }
                }

                //Set it clean so the following save might have nothing to do.
                $object->setClean($property_name);
            }
        }
    }
private function savePropertiesDirectly(Remote\Model $object)
    {
        foreach ($object::getProperties() as $property_name => $meta) {
            if ($meta[Remote\Model::KEY_SAVE_DIRECTLY] && $object->isDirty($property_name)) {
                //Then actually save
                $property_objects = $object->$property_name;
                /** @var Remote\Model $property_type */
                $property_type = get_class(current($property_objects));

                $url = new URL($this, sprintf('%s/%s/%s', $object::getResourceURI(), $object->getGUID(), $property_type::getResourceURI()));
                $request = new Request($this, $url, Request::METHOD_PUT);

                $property_array = [];
                /** @var Remote\Model[] $property_objects */
                foreach ($property_objects as $property_object) {
                    $property_array[] = $property_object->toStringArray(false);
                }

                $root_node_name = Helpers::pluralize($property_type::getRootNodeName());
                $request->setBody(Helpers::arrayToXML([$root_node_name => $property_array]));

                $request->send();

                $response = $request->getResponse();
                foreach ($response->getElements() as $element_index => $element) {
                    if ($response->getErrorsForElement($element_index) === null) {
                        $property_objects[$element_index]->fromStringArray($element);
                        $property_objects[$element_index]->setClean();
                    }
                }

                //Set it clean so the following save might have nothing to do.
                $object->setClean($property_name);
            }
        }
    }
private function savePropertiesDirectly ( Remote \ Model $ object ) { foreach ( $ object :: getProperties ( ) as $ property_name => $ meta ) { if ( $ meta [ Remote \ Model :: KEY_SAVE_DIRECTLY ] && $ object -> isDirty ( $ property_name ) ) { //Then actually save $ property_objects = $ object -> $ property_name ; /** @var Remote\Model $property_type */ $ property_type = get_class ( current ( $ property_objects ) ) ; $ url = new URL ( $ this , sprintf ( '%s/%s/%s' , $ object :: getResourceURI ( ) , $ object -> getGUID ( ) , $ property_type :: getResourceURI ( ) ) ) ; $ request = new Request ( $ this , $ url , Request :: METHOD_PUT ) ; $ property_array = [ ] ; /** @var Remote\Model[] $property_objects */ foreach ( $ property_objects as $ property_object ) { $ property_array [ ] = $ property_object -> toStringArray ( false ) ; } $ root_node_name = Helpers :: pluralize ( $ property_type :: getRootNodeName ( ) ) ; $ request -> setBody ( Helpers :: arrayToXML ( [ $ root_node_name => $ property_array ] ) ) ; $ request -> send ( ) ; $ response = $ request -> getResponse ( ) ; foreach ( $ response -> getElements ( ) as $ element_index => $ element ) { if ( $ response -> getErrorsForElement ( $ element_index ) === null ) { $ property_objects [ $ element_index ] -> fromStringArray ( $ element ) ; $ property_objects [ $ element_index ] -> setClean ( ) ; } } //Set it clean so the following save might have nothing to do. $ object -> setClean ( $ property_name ) ; } } }
Function to save properties directly which do not update via a POST.

This is called automatically from the save method for things like
adding contacts to ContactGroups

@param Remote\Model $object
@throws Exception
Function to save properties directly which do not update via a POST .