xref: /plugin/farmer/remote.php (revision 107b329db3411678bd8cfaafd4a6b07c4c60e833)
1<?php
2
3use dokuwiki\Extension\RemotePlugin;
4
5class remote_plugin_farmer extends RemotePlugin {
6    /** @var helper_plugin_farmer hlp */
7    protected $helper;
8
9    /**
10     * remote_plugin_struct constructor.
11     */
12    public function __construct()
13    {
14        parent::__construct();
15
16        $this->helper = plugin_load('helper', 'farmer');
17    }
18
19    /**
20     * Get the configured farm host
21     *
22     * @return string
23     */
24    public function getFarmhost(): string
25    {
26        return $this->helper->getConfig()['base']['farmhost'];
27    }
28
29    /**
30     * Get the configured base domain of the farmer
31     * This could be an empty string, then farmhost will be used to determine an animal url
32     *
33     * @return string
34     */
35    public function getBaseDomain(): string
36    {
37        return $this->helper->getConfig()['base']['basedomain'];
38    }
39
40    /**
41     * Get a list of all animal names
42     *
43     * @return array
44     */
45    public function listAnimals(): array
46    {
47        return $this->helper->getAllAnimals();
48    }
49
50    /**
51     * Get a list of all animal urls
52     *
53     * @return array
54     */
55    public function listAnimalUrls(): array
56    {
57        foreach($this->helper->getAllAnimals() as $animal) {
58            $animalUrls[] = $this->helper->getAnimalURL($animal);
59        }
60        return $animalUrls;
61    }
62}
63