This repository has been archived by the owner on May 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from MartialGeek/torrent_id_list
New type TorrentIdList
- Loading branch information
Showing
8 changed files
with
352 additions
and
416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# 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: | ||
|
||
```php | ||
$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: | ||
|
||
```php | ||
$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: | ||
|
||
```php | ||
$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: | ||
|
||
```php | ||
$logger = new \Monolog\Logger('transmission'); | ||
$logger->pushHandler(new \Monolog\Handler\StreamHandler('php://stdout')); | ||
$api = new \Martial\Transmission\API\RpcClient($guzzle, $rpcUsername, $rpcPassword, $logger); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.