32
32
namespace OCA \Backup \Command ;
33
33
34
34
35
+ use ArtificialOwl \MySmallPhpTools \Exceptions \SignatoryException ;
36
+ use ArtificialOwl \MySmallPhpTools \Exceptions \SignatureException ;
35
37
use OC \Core \Command \Base ;
38
+ use OCA \Backup \Db \RemoteRequest ;
39
+ use OCA \Backup \Model \RemoteInstance ;
40
+ use OCA \Backup \Service \RemoteStreamService ;
41
+ use Symfony \Component \Console \Helper \Table ;
36
42
use Symfony \Component \Console \Input \InputInterface ;
43
+ use Symfony \Component \Console \Output \ConsoleOutput ;
37
44
use Symfony \Component \Console \Output \OutputInterface ;
38
45
39
46
45
52
class RemoteList extends Base {
46
53
47
54
48
- public function __construct () {
55
+ /** @var RemoteRequest */
56
+ private $ remoteRequest ;
57
+
58
+ /** @var RemoteStreamService */
59
+ private $ remoteStreamService ;
60
+
61
+
62
+ public function __construct (RemoteRequest $ remoteRequest , RemoteStreamService $ remoteStreamService ) {
63
+ $ this ->remoteRequest = $ remoteRequest ;
64
+ $ this ->remoteStreamService = $ remoteStreamService ;
49
65
50
66
parent ::__construct ();
51
67
}
@@ -67,10 +83,39 @@ protected function configure() {
67
83
* @return int
68
84
*/
69
85
protected function execute (InputInterface $ input , OutputInterface $ output ): int {
70
-
86
+ $ output = new ConsoleOutput ();
87
+ $ output = $ output ->section ();
88
+ $ table = new Table ($ output );
89
+ $ table ->setHeaders (
90
+ ['Address ' , 'Stored Uid ' , 'Current Uid ' , 'Href ' , 'Incoming data ' , 'Outgoing data ' ]
91
+ );
92
+ $ table ->render ();
93
+
94
+ foreach ($ this ->remoteRequest ->getAll () as $ remoteInstance ) {
95
+
96
+ $ color = 'error ' ;
97
+ /** @var RemoteInstance $current */
98
+ try {
99
+ $ current = $ this ->remoteStreamService ->retrieveSignatory ($ remoteInstance ->getId ());
100
+ if ($ remoteInstance ->getUid (true ) === $ current ->getUid (true )) {
101
+ $ color = 'info ' ;
102
+ }
103
+ } catch (SignatoryException | SignatureException $ e ) {
104
+ }
105
+
106
+ $ table ->appendRow (
107
+ [
108
+ $ remoteInstance ->getInstance (),
109
+ $ remoteInstance ->getUid (true ),
110
+ '< ' . $ color . '> ' . $ current ->getUid (true ) . '</ ' . $ color . '> ' ,
111
+ $ remoteInstance ->getId (),
112
+ ($ remoteInstance ->isIncoming () ? '<info>yes</info> ' : '<comment>no</comment ' ),
113
+ ($ remoteInstance ->isOutgoing () ? '<info>yes</info> ' : '<comment>no</comment ' )
114
+ ]
115
+ );
116
+ }
71
117
72
118
return 0 ;
73
119
}
74
120
75
121
}
76
-
0 commit comments