setResource($page); } static public function getDescription(): string { return "The featured image from the closest ancestor page"; } static public function getLabel(): string { return "Ancestor Image"; } public static function getName(): string { return self::PROPERTY_NAME; } static public function getPersistenceType(): string { return Metadata::DERIVED_METADATA; } static public function isMutable(): bool { return false; } public function getValue(): WikiPath { $contextPage = $this->getResource(); $actual = $contextPage; while (true) { try { $actual = $actual->getParent(); } catch (ExceptionNotFound $e) { break; } try { return FeaturedImage::createFromResourcePage($actual)->getValue(); } catch (ExceptionNotFound $e) { // ok } } throw new ExceptionNotFound(); } static public function getDrive(): string { return WikiPath::MEDIA_DRIVE; } static public function isOnForm(): bool { return true; } }