/**
* Determines and returns the relative path and filename for the given Storage Object or PersistentResource. If the given
* object represents a persistent resource, its own relative publication path will be empty. If the given object
* represents a static resources, it will contain a relative path.
*
* No matter which kind of resource, persistent or static, this function will return a sub directory structure
* if no relative publication path was defined in the given object.
*
* @param ResourceMetaDataInterface $object PersistentResource or Storage Object
* @return string The relative path and filename, for example "c/8/2/8/c828d0f88ce197be1aff7cc2e5e86b1244241ac6/MyPicture.jpg" (if subdivideHashPathSegment is on) or "c828d0f88ce197be1aff7cc2e5e86b1244241ac6/MyPicture.jpg" (if it's off)
*/
protected function getRelativePublicationPathAndFilename(ResourceMetaDataInterface $object)
{
if ($object->getRelativePublicationPath() !== '') {
$pathAndFilename = $object->getRelativePublicationPath() . $object->getFilename();
} else {
if ($this->subdivideHashPathSegment) {
$sha1Hash = $object->getSha1();
$pathAndFilename = $sha1Hash[0] . '/' . $sha1Hash[1] . '/' . $sha1Hash[2] . '/' . $sha1Hash[3] . '/' . $sha1Hash . '/' . $object->getFilename();
} else {
$pathAndFilename = $object->getSha1() . '/' . $object->getFilename();
}
}
return $pathAndFilename;
}