Merge pull request #10435 from nupplaphil/feat/di_cleanup

Add constructor injection for ExternalResource Storage
This commit is contained in:
Hypolite Petovan 2021-06-27 21:02:03 -04:00 committed by GitHub
commit 005ba8c388
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -22,7 +22,7 @@
namespace Friendica\Model\Storage;
use BadMethodCallException;
use Friendica\DI;
use Friendica\Network\IHTTPRequest;
/**
* External resource storage class
@ -34,6 +34,14 @@ class ExternalResource implements IStorage
{
const NAME = 'ExternalResource';
/** @var IHTTPRequest */
private $httpRequest;
public function __construct(IHTTPRequest $httpRequest)
{
$this->httpRequest = $httpRequest;
}
/**
* @inheritDoc
*/
@ -44,7 +52,7 @@ class ExternalResource implements IStorage
return "";
}
$curlResult = DI::httpRequest()->get($filename);
$curlResult = $this->httpRequest->get($filename);
if ($curlResult->isSuccess()) {
return $curlResult->getBody();
} else {

View file

@ -23,6 +23,8 @@ namespace Friendica\Model\Storage;
/**
* Interface for storage backends
*
* @todo Split this interface into "IStorage" for get() operations (including Resource fetching) and "IUserStorage" for real user backends including put/delete/options
*/
interface IStorage
{