stream opening

This commit is contained in:
Maxime Renou 2019-06-09 13:37:31 +02:00
parent 70b186f8dd
commit 7a18467734
1 changed files with 6 additions and 1 deletions

View File

@ -99,12 +99,17 @@ class Storage
return $storage->retrieve("$prefix{$entity->{"get".$camel}()}", $local_path); return $storage->retrieve("$prefix{$entity->{"get".$camel}()}", $local_path);
} }
public function stream($entity, $attribute, $target_stream) public function stream($entity, $attribute, $target_stream = null)
{ {
$annotation = $this->getStorageAnnotation($entity, $attribute); $annotation = $this->getStorageAnnotation($entity, $attribute);
$storage = $this->get($annotation->name); $storage = $this->get($annotation->name);
$prefix = is_null($annotation->prefix) || empty($annotation->prefix) ? '' : trim($annotation->prefix, '/').'/'; $prefix = is_null($annotation->prefix) || empty($annotation->prefix) ? '' : trim($annotation->prefix, '/').'/';
$camel = ucfirst(Container::camelize($attribute)); $camel = ucfirst(Container::camelize($attribute));
if (is_null($target_stream)) {
return $storage->getStream("$prefix{$entity->{"get".$camel}()}");
}
return $storage->stream("$prefix{$entity->{"get".$camel}()}", $target_stream); return $storage->stream("$prefix{$entity->{"get".$camel}()}", $target_stream);
} }