1<?php
2
3namespace ComboStrap;
4
5use ComboStrap\Meta\Api\Metadata;
6use ComboStrap\Meta\Api\MetadataImage;
7
8/**
9 * The first image used as blog image (ie svg first then raster)
10 * (Used to get feedback information to the user in the metadata manager)
11 */
12class FirstImage extends MetadataImage
13{
14
15
16    public const PROPERTY_NAME = "first-image";
17
18    public static function createForPage(ResourceCombo $resource): FirstImage
19    {
20        return (new FirstImage())
21            ->setResource($resource);
22    }
23
24    static public function getDescription(): string
25    {
26        return "The first image";
27    }
28
29    static public function getLabel(): string
30    {
31        return "First Image";
32    }
33
34    public static function getName(): string
35    {
36        return self::PROPERTY_NAME;
37    }
38
39
40    static public function isMutable(): bool
41    {
42        return false;
43    }
44
45    /**
46     * @return WikiPath
47     * @throws ExceptionNotFound
48     */
49    public function getValue(): WikiPath
50    {
51        $contextPage = $this->getResource();
52        try {
53            return FirstSvgIllustration::createForPage($contextPage)->getValue();
54        } catch (ExceptionNotFound $e) {
55            return FirstRasterImage::createForPage($contextPage)->getValue();
56        }
57
58    }
59
60
61    static public function getPersistenceType(): string
62    {
63        return Metadata::DERIVED_METADATA;
64    }
65
66    static     public function getDrive(): string
67    {
68        return WikiPath::MEDIA_DRIVE;
69    }
70
71    static public function isOnForm(): bool
72    {
73        return true;
74    }
75}
76