1<?php
2
3class helper_plugin_structacl extends DokuWiki_Plugin
4{
5    const STRUCTACL_SEPCHAR = '.';
6    /**
7     * Convert config lines "schema.field name" into an array
8     *
9     * @param string $confValue
10     * @return array
11     */
12    public function getConfiguration($confValue)
13    {
14        $lines = explode(PHP_EOL , $confValue);
15        $config = [];
16
17        foreach ($lines as $line) {
18            // ignore comments, empty and invalid lines
19            $line = preg_replace('/#.*$/', '', $line);
20            $line = trim($line);
21            if ($line === '' || strpos($line, self::STRUCTACL_SEPCHAR) === false) continue;
22
23            list($schema, $field) = explode(self::STRUCTACL_SEPCHAR, $line, 2);
24            $config[$schema] = $config[$schema] ?? [];
25            $config[$schema][] = $field;
26        }
27
28        return $config;
29    }
30}
31