1<?php 2 3 4namespace ComboStrap; 5 6 7class PageImagePath extends MetadataWikiPath 8{ 9 10 public const PERSISTENT_NAME = "path"; 11 const PROPERTY_NAME = "image-path"; 12 13 14 public static function createFromParent(Metadata $metadata): PageImagePath 15 { 16 return (new PageImagePath($metadata)); 17 } 18 19 20 public function getDescription(): string 21 { 22 return "The path of the image"; 23 } 24 25 public function getLabel(): string 26 { 27 return "Path"; 28 } 29 30 static public function getName(): string 31 { 32 return self::PROPERTY_NAME; 33 } 34 35 static public function getPersistentName(): string 36 { 37 return self::PERSISTENT_NAME; 38 } 39 40 41 public function getPersistenceType(): string 42 { 43 return Metadata::PERSISTENT_METADATA; 44 } 45 46 public function getMutable(): bool 47 { 48 return true; 49 } 50 51 public function getFormControlWidth(): int 52 { 53 return 8; 54 } 55 56 57 public function setFromStoreValue($value): Metadata 58 { 59 DokuPath::addRootSeparatorIfNotPresent($value); 60 $pageImage = PageImage::create($value, $this->getResource()); 61 if (!$pageImage->getImage()->exists()) { 62 throw new ExceptionCombo("The image ($value) does not exists", $this->getCanonical()); 63 } 64 return parent::setFromStoreValue($value); 65 } 66 67 68} 69