mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-26 19:11:07 +00:00
Merge pull request #6816 from yguedidi/use-psr-17-and-psr-18
Use PSR-17 and PSR-18
This commit is contained in:
commit
ac1c1ff571
2 changed files with 12 additions and 10 deletions
|
@ -9,10 +9,11 @@ use Http\Client\Common\HttpMethodsClient;
|
||||||
use Http\Client\Common\Plugin\ErrorPlugin;
|
use Http\Client\Common\Plugin\ErrorPlugin;
|
||||||
use Http\Client\Common\Plugin\RedirectPlugin;
|
use Http\Client\Common\Plugin\RedirectPlugin;
|
||||||
use Http\Client\Common\PluginClient;
|
use Http\Client\Common\PluginClient;
|
||||||
use Http\Client\HttpClient;
|
use Http\Discovery\Psr17FactoryDiscovery;
|
||||||
use Http\Discovery\MessageFactoryDiscovery;
|
use Psr\Http\Client\ClientInterface;
|
||||||
use Http\Message\MessageFactory;
|
use Psr\Http\Message\RequestFactoryInterface;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use Psr\Http\Message\StreamFactoryInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\DomCrawler\Crawler;
|
use Symfony\Component\DomCrawler\Crawler;
|
||||||
use Symfony\Component\Finder\Finder;
|
use Symfony\Component\Finder\Finder;
|
||||||
|
@ -28,9 +29,9 @@ class DownloadImages
|
||||||
private $mimeTypes;
|
private $mimeTypes;
|
||||||
private $wallabagUrl;
|
private $wallabagUrl;
|
||||||
|
|
||||||
public function __construct(HttpClient $client, $baseFolder, $wallabagUrl, LoggerInterface $logger, MessageFactory $messageFactory = null)
|
public function __construct(ClientInterface $client, $baseFolder, $wallabagUrl, LoggerInterface $logger, RequestFactoryInterface $requestFactory = null, StreamFactoryInterface $streamFactory = null)
|
||||||
{
|
{
|
||||||
$this->client = new HttpMethodsClient(new PluginClient($client, [new ErrorPlugin(), new RedirectPlugin()]), $messageFactory ?: MessageFactoryDiscovery::find());
|
$this->client = new HttpMethodsClient(new PluginClient($client, [new ErrorPlugin(), new RedirectPlugin()]), $requestFactory ?: Psr17FactoryDiscovery::findRequestFactory(), $streamFactory ?: Psr17FactoryDiscovery::findStreamFactory());
|
||||||
$this->baseFolder = $baseFolder;
|
$this->baseFolder = $baseFolder;
|
||||||
$this->wallabagUrl = rtrim($wallabagUrl, '/');
|
$this->wallabagUrl = rtrim($wallabagUrl, '/');
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
|
|
|
@ -6,10 +6,11 @@ use Http\Client\Common\HttpMethodsClient;
|
||||||
use Http\Client\Common\Plugin\ErrorPlugin;
|
use Http\Client\Common\Plugin\ErrorPlugin;
|
||||||
use Http\Client\Common\PluginClient;
|
use Http\Client\Common\PluginClient;
|
||||||
use Http\Client\Exception\RequestException;
|
use Http\Client\Exception\RequestException;
|
||||||
use Http\Client\HttpClient;
|
use Http\Discovery\Psr17FactoryDiscovery;
|
||||||
use Http\Discovery\MessageFactoryDiscovery;
|
use Psr\Http\Client\ClientInterface;
|
||||||
use Http\Message\MessageFactory;
|
use Psr\Http\Message\RequestFactoryInterface;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use Psr\Http\Message\StreamFactoryInterface;
|
||||||
use Wallabag\CoreBundle\Entity\Entry;
|
use Wallabag\CoreBundle\Entity\Entry;
|
||||||
|
|
||||||
class PocketImport extends AbstractImport
|
class PocketImport extends AbstractImport
|
||||||
|
@ -152,9 +153,9 @@ class PocketImport extends AbstractImport
|
||||||
/**
|
/**
|
||||||
* Set the Http client.
|
* Set the Http client.
|
||||||
*/
|
*/
|
||||||
public function setClient(HttpClient $client, MessageFactory $messageFactory = null)
|
public function setClient(ClientInterface $client, RequestFactoryInterface $requestFactory = null, StreamFactoryInterface $streamFactory = null)
|
||||||
{
|
{
|
||||||
$this->client = new HttpMethodsClient(new PluginClient($client, [new ErrorPlugin()]), $messageFactory ?: MessageFactoryDiscovery::find());
|
$this->client = new HttpMethodsClient(new PluginClient($client, [new ErrorPlugin()]), $requestFactory ?: Psr17FactoryDiscovery::findRequestFactory(), $streamFactory ?: Psr17FactoryDiscovery::findStreamFactory());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue