Added default reader functionality
This commit is contained in:
@@ -29,6 +29,7 @@ class ObjectRetriever implements CustomCacheAndLogInterface {
|
|||||||
private $options;
|
private $options;
|
||||||
private $cache;
|
private $cache;
|
||||||
private $objects;
|
private $objects;
|
||||||
|
private $defaultReader;
|
||||||
|
|
||||||
const CO_API_URL = 'https://api.cloudobjects.net/';
|
const CO_API_URL = 'https://api.cloudobjects.net/';
|
||||||
|
|
||||||
@@ -107,6 +108,22 @@ class ObjectRetriever implements CustomCacheAndLogInterface {
|
|||||||
$this->client = new Client($options);
|
$this->client = new Client($options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a default reader for CloudObject instances.
|
||||||
|
*/
|
||||||
|
public function setDefaultReader(NodeReader $reader) : self {
|
||||||
|
$this->defaultReader = $reader;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the default reader for CloudObject instances.
|
||||||
|
*/
|
||||||
|
public function getDefaultReader() : NodeReader {
|
||||||
|
return $this->defaultReader;
|
||||||
|
}
|
||||||
|
|
||||||
public function logInfoWithTime($message, $ts) {
|
public function logInfoWithTime($message, $ts) {
|
||||||
if (isset($this->logger))
|
if (isset($this->logger))
|
||||||
$this->logger->info($message, [ 'elapsed_ms' => round((microtime(true) - $ts) * 1000) ]);
|
$this->logger->info($message, [ 'elapsed_ms' => round((microtime(true) - $ts) * 1000) ]);
|
||||||
@@ -179,7 +196,14 @@ class ObjectRetriever implements CustomCacheAndLogInterface {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CloudObject($coid, $node);
|
$object = new CloudObject($coid, $node);
|
||||||
|
|
||||||
|
if ($this->defaultReader) {
|
||||||
|
// Initialize CloudObject with default reader if it is set
|
||||||
|
$object->setReader($this->defaultReader);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $object;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user