1<?php
2
3
4namespace ComboStrap;
5
6
7use ComboStrap\Meta\Api\MetadataText;
8use ComboStrap\Meta\Field\PageH1;
9use ComboStrap\Meta\Store\MetadataDokuWikiStore;
10
11class Label extends MetadataText
12{
13
14    public const PROPERTY_NAME = 'label';
15
16
17    public static function createForMarkup($page): Label
18    {
19        return (new Label())
20            ->setResource($page);
21    }
22
23    static public function getTab(): string
24    {
25        return MetaManagerForm::TAB_PAGE_VALUE;
26    }
27
28    static public function getDescription(): string
29    {
30        return "A label is a short description of a couple of words used in a listing (table row)";
31    }
32
33    static public function getLabel(): string
34    {
35        return "Label";
36    }
37
38    static public function getName(): string
39    {
40        return self::PROPERTY_NAME;
41    }
42
43    static public function getPersistenceType(): string
44    {
45        return MetadataDokuWikiStore::PERSISTENT_DOKUWIKI_KEY;
46    }
47
48    static public function isMutable(): bool
49    {
50        return true;
51    }
52
53    /**
54     * @return string
55     */
56    public function getDefaultValue(): string
57    {
58
59        return PageTitle::createForMarkup($this->getResource())->getValueOrDefault();
60
61    }
62
63    /**
64     * @return string
65     */
66    public function getValueOrDefault(): string
67    {
68        try {
69            return $this->getValue();
70        } catch (ExceptionNotFound $e) {
71            return $this->getDefaultValue();
72        }
73    }
74
75
76    static public function isOnForm(): bool
77    {
78        return true;
79    }
80}
81