Skip to content

Commit e8eba9d

Browse files
committed
Allow override schemaFile
1 parent 2713a61 commit e8eba9d

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/SchemaValidatableElementInterface.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ interface SchemaValidatableElementInterface extends ElementInterface
1616
/**
1717
* Validate the given DOMDocument against the schema set for this element
1818
*
19+
* @param \DOMDocument $document
20+
* @param string|null $schemaFile
1921
* @return \DOMDocument
22+
*
23+
* @throws \SimpleSAML\XML\Exception\IOException
2024
* @throws \SimpleSAML\XML\Exception\SchemaViolationException
2125
*/
22-
public static function schemaValidate(DOMDocument $document): DOMDocument;
26+
public static function schemaValidate(DOMDocument $document, ?string $schemaFile = null): DOMDocument;
2327
}

src/SchemaValidatableElementTrait.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,22 @@ trait SchemaValidatableElementTrait
2929
/**
3030
* Validate the given DOMDocument against the schema set for this element
3131
*
32+
* @param \DOMDocument $document
33+
* @param string|null $schemaFile
3234
* @return \DOMDocument
35+
*
36+
* @throws \SimpleSAML\XML\Exception\IOException
3337
* @throws \SimpleSAML\XML\Exception\SchemaViolationException
3438
*/
35-
public static function schemaValidate(DOMDocument $document): DOMDocument
39+
public static function schemaValidate(DOMDocument $document, ?string $schemaFile = null): DOMDocument
3640
{
3741
$internalErrors = libxml_use_internal_errors(true);
3842
libxml_clear_errors();
3943

40-
$schemaFile = self::getSchemaFile();
44+
if ($schemaFile === null) {
45+
$schemaFile = self::getSchemaFile();
46+
}
47+
4148
// Must suppress the warnings here in order to throw them as an error below.
4249
$result = @$document->schemaValidate($schemaFile);
4350

0 commit comments

Comments
 (0)