1<?php
2
3
4namespace ComboStrap;
5
6use ComboStrap\Meta\Api\Metadata;
7use ComboStrap\Meta\Api\MetadataBoolean;
8
9/**
10 * Class LowQualityPageIndicator
11 * @package ComboStrap
12 * Tells if the page can be of low quality or not
13 * By default, it can
14 */
15class LowQualityPageOverwrite extends MetadataBoolean
16{
17
18    /**
19     * An indicator in the meta
20     * that set a boolean to true or false
21     * to tell if a page may be of low quality
22     */
23    public const PROPERTY_NAME = 'low_quality_page';
24    public const CAN_BE_LOW_QUALITY_PAGE_DEFAULT = true;
25
26    public static function createForPage(MarkupPath $page)
27    {
28        return (new LowQualityPageOverwrite())
29            ->setResource($page);
30    }
31
32    static public function getTab(): string
33    {
34        return MetaManagerForm::TAB_QUALITY_VALUE;
35    }
36
37    static public function getDescription(): string
38    {
39        return "If checked, this page will never be a low quality page";
40    }
41
42    static public function getLabel(): string
43    {
44        return "Prevent this page to become a low quality page";
45    }
46
47    public static function getName(): string
48    {
49        return self::PROPERTY_NAME;
50    }
51
52    static public function getPersistenceType(): string
53    {
54        return Metadata::PERSISTENT_METADATA;
55    }
56
57    static public function isMutable(): bool
58    {
59        return true;
60    }
61
62    /**
63     * @return bool
64     */
65    public function getValueOrDefault(): bool
66    {
67        try {
68            return $this->getValue();
69        } catch (ExceptionNotFound $e) {
70            return $this->getDefaultValue();
71        }
72    }
73
74
75    /**
76     * @return bool
77     */
78    public function getDefaultValue(): bool
79    {
80        /**
81         * A page can be of low quality by default
82         */
83        return self::CAN_BE_LOW_QUALITY_PAGE_DEFAULT;
84    }
85
86    static public function getCanonical(): string
87    {
88        return "low_quality_page";
89    }
90
91
92    static public function isOnForm(): bool
93    {
94        return true;
95    }
96
97}
98