1<?php
2
3
4namespace ComboStrap;
5
6/**
7 * Class MetadataWikiPath
8 * @package ComboStrap
9 * A wiki path value where the separator is a {@link DokuPath::PATH_SEPARATOR}
10 */
11abstract class MetadataWikiPath extends MetadataText
12{
13
14    /**
15     * @param string|null $value
16     * @return Metadata
17     * @throws ExceptionCombo
18     */
19    public function setValue($value): Metadata
20    {
21        if ($value === null) {
22            parent::setValue($value);
23            return $this;
24        }
25        if ($value === "" || $value === ":") {
26            // form send empty string
27            // for the root `:`, non canonical
28            return $this;
29        }
30
31        $value = DokuPath::toValidAbsolutePath($value);
32        parent::setValue($value);
33        return $this;
34    }
35
36    /**
37     */
38    public function buildFromStoreValue($value): Metadata
39    {
40        if ($value !== null && $value !== "") {
41            $value = DokuPath::toValidAbsolutePath($value);
42        }
43        parent::buildFromStoreValue($value);
44        return $this;
45    }
46
47
48}
49