code/content/ContentService.php
public function getWriterFor(DataObject $object = null, $field = 'FilePointer', $type = null) {
		if ($object && $field && $object->hasField($field)) {
			$val = $object->$field;
			if (strlen($val)) {
				$reader = $this->getReader($val);
				if ($reader && $reader->isReadable()) {
					return $reader->getWriter();
				}
			}
		}
		
		if (!$type) {
			// specifically expecting to be handling File objects, but allows other 
			// objects to play too
			if ($object && $object->hasMethod('getEffectiveContentStore')) {
				$type = $object->getEffectiveContentStore();
			} else {
				$type = $this->defaultStore;
			}
		}
		
		// looks like we're getting a writer with no underlying file (as yet)
		return $this->getWriter($type);
	}
public function getWriterFor(DataObject $object = null, $field = 'FilePointer', $type = null) {
		if ($object && $field && $object->hasField($field)) {
			$val = $object->$field;
			if (strlen($val)) {
				$reader = $this->getReader($val);
				if ($reader && $reader->isReadable()) {
					return $reader->getWriter();
				}
			}
		}
		
		if (!$type) {
			// specifically expecting to be handling File objects, but allows other 
			// objects to play too
			if ($object && $object->hasMethod('getEffectiveContentStore')) {
				$type = $object->getEffectiveContentStore();
			} else {
				$type = $this->defaultStore;
			}
		}
		
		// looks like we're getting a writer with no underlying file (as yet)
		return $this->getWriter($type);
	}
public function getWriterFor ( DataObject $ object = null , $ field = 'FilePointer' , $ type = null ) { if ( $ object && $ field && $ object -> hasField ( $ field ) ) { $ val = $ object -> $ field ; if ( strlen ( $ val ) ) { $ reader = $ this -> getReader ( $ val ) ; if ( $ reader && $ reader -> isReadable ( ) ) { return $ reader -> getWriter ( ) ; } } } if ( ! $ type ) { // specifically expecting to be handling File objects, but allows other  // objects to play too if ( $ object && $ object -> hasMethod ( 'getEffectiveContentStore' ) ) { $ type = $ object -> getEffectiveContentStore ( ) ; } else { $ type = $ this -> defaultStore ; } } // looks like we're getting a writer with no underlying file (as yet) return $ this -> getWriter ( $ type ) ; }
Gets a writer for a DataObject

If the field already has a value, a writer is created matching that
identifier. Otherwise, a new writer is created based on either

- The $type passed in
- whether the $object class specifies a prefered storage type via
getEffectiveContentStore
- what the `defaultStore` is set to for the content service


@param DataObject $object
The object to get a writer for
@param String $field
The field being written to
@param String $type
Explicitly state what the content store type will be
@return ContentWriter
Gets a writer for a DataObject