1<?php 2 3 4namespace ComboStrap; 5 6 7use ComboStrap\Api\QualityMessageHandler; 8use ComboStrap\Meta\Api\Metadata; 9use ComboStrap\Meta\Api\MetadataBoolean; 10 11class QualityDynamicMonitoringOverwrite extends MetadataBoolean 12{ 13 14 /** 15 * Key in the frontmatter that disable the message 16 */ 17 public const PROPERTY_NAME = "dynamic_quality_monitoring"; 18 public const EXECUTE_DYNAMIC_QUALITY_MONITORING_DEFAULT = true; 19 20 public static function createFromPage(MarkupPath $page): QualityDynamicMonitoringOverwrite 21 { 22 return (new QualityDynamicMonitoringOverwrite()) 23 ->setResource($page); 24 } 25 26 static public function getTab(): ?string 27 { 28 return MetaManagerForm::TAB_QUALITY_VALUE; 29 } 30 31 static public function getDescription(): string 32 { 33 return "If checked, the quality message will not be shown for the page."; 34 } 35 36 static public function getLabel(): string 37 { 38 return "Disable the quality control of this page"; 39 } 40 41 static public function getCanonical(): string 42 { 43 return QualityMessageHandler::CANONICAL; 44 } 45 46 47 static public 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 * @return bool 76 */ 77 public function getDefaultValue(): bool 78 { 79 return self::EXECUTE_DYNAMIC_QUALITY_MONITORING_DEFAULT; 80 } 81 82 static public function isOnForm(): bool 83 { 84 return true; 85 } 86 87} 88