PluginDataUpdater.php
753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace ACP\Updates;
use ACP\API;
use ACP\Storage;
use ACP\Type\ActivationToken;
use ACP\Type\SiteUrl;
class PluginDataUpdater {
/**
* @var API
*/
private $api;
/**
* @var SiteUrl
*/
private $site_url;
/**
* @var Storage\PluginsData
*/
private $storage;
public function __construct( API $api, SiteUrl $site_url, Storage\PluginsData $storage ) {
$this->api = $api;
$this->site_url = $site_url;
$this->storage = $storage;
}
public function update( ActivationToken $token = null ) {
$response = $this->api->dispatch(
new API\Request\ProductsUpdate( $this->site_url, $token )
);
if ( ! $response || $response->has_error() ) {
return;
}
$this->storage->save( (array) $response->get_body() );
}
}