diff --git a/common/report/class.Report.php b/common/report/class.Report.php index c4a5af576..460d520f0 100755 --- a/common/report/class.Report.php +++ b/common/report/class.Report.php @@ -141,6 +141,17 @@ public function getMessage(): string return $this->message; } + public function getAllMessages(): string + { + $messages = [$this->getMessage()]; + + foreach ($this->children as $child) { + $messages[] = $child->getAllMessages(); + } + + return implode(', ', $messages); + } + /** * Update message of the report * diff --git a/core/kernel/classes/class.Property.php b/core/kernel/classes/class.Property.php index 07c4d5988..f8e1c031c 100644 --- a/core/kernel/classes/class.Property.php +++ b/core/kernel/classes/class.Property.php @@ -155,6 +155,17 @@ public function getDomain() return $returnValue; } + public function getRelatedClass(): ?core_kernel_classes_Class + { + try { + $class = $this->getDomain()->get(0); + + return $class instanceof core_kernel_classes_Class ? $class : null; + } catch (common_Exception $exception) { + return null; + } + } + /** * Short description of method setDomain * @@ -227,6 +238,17 @@ public function setRange(core_kernel_classes_Class $class) return (bool) $returnValue; } + public function getAlias(): ?string + { + $container = $this->getOnePropertyValue($this->getProperty(GenerisRdf::PROPERTY_ALIAS)); + + if ($container instanceof core_kernel_classes_Literal) { + return $container->__toString(); + } + + return null; + } + public function getDependsOnPropertyCollection(): DependsOnPropertyCollection { if (!isset($this->dependsOnPropertyCollection)) { diff --git a/test/unit/ReportTest.php b/test/unit/ReportTest.php index 9c3edb077..8a58916ba 100644 --- a/test/unit/ReportTest.php +++ b/test/unit/ReportTest.php @@ -378,4 +378,16 @@ public function testCreateWithInterpolation(): void self::assertSame('my data test', $unSerialized->getMessage()); self::assertSame('my data test', $unSerialized->translateMessage()); } + + public function testGetAllMessages(): void + { + $report = Report::createInfo('1') + ->add( + Report::createSuccess('2') + ->add(Report::createWarning('3') + ) + ); + + self::assertEquals('1, 2, 3', $report->getAllMessages()); + } }