return $data['storage_config'];
} catch (InternalServerErrorException $exception) {
- throw new StorageException(sprintf('Failed calling hook::storage_config for backend %s', $name), $exception);
+ throw new StorageException(sprintf('Failed calling hook::storage_config for backend %s', $name), $exception->__toString());
}
}
}
$this->backendInstances[$name] = new Type\SystemResource();
break;
case Type\ExternalResource::getName():
- $this->backendInstances[$name] = new Type\ExternalResource();
+ $this->backendInstances[$name] = new Type\ExternalResource($this->logger);
break;
default:
$data = [
$this->backendInstances[$data['name'] ?? $name] = $data['storage'];
} catch (InternalServerErrorException $exception) {
- throw new StorageException(sprintf('Failed calling hook::storage_instance for backend %s', $name), $exception);
+ throw new StorageException(sprintf('Failed calling hook::storage_instance for backend %s', $name), $exception->__toString());
}
break;
}
namespace Friendica\Core\Storage\Type;
use Exception;
-use Friendica\Core\Logger;
use Friendica\Core\Storage\Exception\ReferenceStorageException;
use Friendica\Core\Storage\Capability\ICanReadFromStorage;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
use Friendica\Util\HTTPSignature;
+use Psr\Log\LoggerInterface;
/**
* External resource storage class
{
const NAME = 'ExternalResource';
+ /** @var LoggerInterface */
+ protected $logger;
+
+ public function __construct(LoggerInterface $logger)
+ {
+ $this->logger = $logger;
+ }
+
/**
* @inheritDoc
*/
try {
$fetchResult = HTTPSignature::fetchRaw($data->url, $data->uid, [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE]]);
} catch (Exception $exception) {
- Logger::notice('URL is invalid', ['url' => $data->url, 'error' => $exception]);
+ $this->logger->notice('URL is invalid', ['url' => $data->url, 'error' => $exception]);
throw new ReferenceStorageException(sprintf('External resource failed to get %s', $reference), $exception->getCode(), $exception);
}
if (!empty($fetchResult) && $fetchResult->isSuccess()) {
- Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => $data->uid, 'url' => $data->url]);
+ $this->logger->debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => $data->uid, 'url' => $data->url]);
return $fetchResult->getBody();
} else {
if (empty($fetchResult)) {