Skip to content
This repository has been archived by the owner on May 17, 2022. It is now read-only.

Latest commit

 

History

History
56 lines (44 loc) · 1.85 KB

UPGRADE-2.0.md

File metadata and controls

56 lines (44 loc) · 1.85 KB

UPGRADE FROM 1.x TO 2.0

Torrent IDs

The array of torrent IDs provided as an argument of almost all the client's methods is replaced by a new class \Martial\Transmission\API\TorrentIdList. This class has been created to ensure that the request to the Transmission RPC API is well formatted. The constructor of this class has one argument, your array of IDs.

Before:

$api = new \Martial\Transmission\API\RpcClient($guzzle, $rpcUsername, $rpcPassword);
$sessionId = // Fetch a new session ID
$torrentIds = [42, 43, 44];
$api->torrentGet($sessionId, $torrentIds, [
    \Martial\Transmission\API\Argument\Torrent\Get::ID,
    \Martial\Transmission\API\Argument\Torrent\Get::NAME,
    \Martial\Transmission\API\Argument\Torrent\Get::STATUS
]);

Now:

$api = new \Martial\Transmission\API\RpcClient($guzzle, $rpcUsername, $rpcPassword);
$sessionId = // Fetch a new session ID
$torrentIds = new \Martial\Transmission\API\TorrentIdList([42, 43, 44]);
$api->torrentGet($sessionId, $torrentIds, [
    \Martial\Transmission\API\Argument\Torrent\Get::ID,
    \Martial\Transmission\API\Argument\Torrent\Get::NAME,
    \Martial\Transmission\API\Argument\Torrent\Get::STATUS
]);

Logger

The method \Martial\Transmission\API\TransmissionAPI::setLogger() has been removed because it violated the SRP principle. The logger can now be injected as fourth argument of the client's controller.

Before:

$api = new \Martial\Transmission\API\RpcClient($guzzle, $rpcUsername, $rpcPassword);
$logger = new \Monolog\Logger('transmission');
$logger->pushHandler(new \Monolog\Handler\StreamHandler('php://stdout'));
$api->setLogger($logger);

Now:

$logger = new \Monolog\Logger('transmission');
$logger->pushHandler(new \Monolog\Handler\StreamHandler('php://stdout'));
$api = new \Martial\Transmission\API\RpcClient($guzzle, $rpcUsername, $rpcPassword, $logger);