xref: /dokuwiki/vendor/kissifrot/php-ixr/src/Client/ClientMulticall.php (revision 7f8f24562b596c56d79e46eba9f82780df5725cb)
1*7f8f2456SAndreas Gohr<?php
2*7f8f2456SAndreas Gohrnamespace IXR\Client;
3*7f8f2456SAndreas Gohr
4*7f8f2456SAndreas Gohr/**
5*7f8f2456SAndreas Gohr * IXR_ClientMulticall
6*7f8f2456SAndreas Gohr *
7*7f8f2456SAndreas Gohr * @package IXR
8*7f8f2456SAndreas Gohr * @since 1.5.0
9*7f8f2456SAndreas Gohr */
10*7f8f2456SAndreas Gohrclass ClientMulticall extends Client
11*7f8f2456SAndreas Gohr{
12*7f8f2456SAndreas Gohr    private $calls = [];
13*7f8f2456SAndreas Gohr
14*7f8f2456SAndreas Gohr    public function __construct($server, $path = false, $port = 80)
15*7f8f2456SAndreas Gohr    {
16*7f8f2456SAndreas Gohr        parent::__construct($server, $path, $port);
17*7f8f2456SAndreas Gohr        $this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
18*7f8f2456SAndreas Gohr    }
19*7f8f2456SAndreas Gohr
20*7f8f2456SAndreas Gohr    public function addCall()
21*7f8f2456SAndreas Gohr    {
22*7f8f2456SAndreas Gohr        $args = func_get_args();
23*7f8f2456SAndreas Gohr        $methodName = array_shift($args);
24*7f8f2456SAndreas Gohr        $struct = [
25*7f8f2456SAndreas Gohr            'methodName' => $methodName,
26*7f8f2456SAndreas Gohr            'params' => $args
27*7f8f2456SAndreas Gohr        ];
28*7f8f2456SAndreas Gohr        $this->calls[] = $struct;
29*7f8f2456SAndreas Gohr    }
30*7f8f2456SAndreas Gohr
31*7f8f2456SAndreas Gohr    public function query()
32*7f8f2456SAndreas Gohr    {
33*7f8f2456SAndreas Gohr        // Prepare multicall, then call the parent::query() method
34*7f8f2456SAndreas Gohr        return parent::query('system.multicall', $this->calls);
35*7f8f2456SAndreas Gohr    }
36*7f8f2456SAndreas Gohr}
37