Update ParserKrokiTag.php
This commit is contained in:
parent
7fa4213178
commit
e6b5ced343
@ -59,6 +59,12 @@ class ParserKrokiTag {
|
||||
'wireviz'
|
||||
];
|
||||
|
||||
/** @var string[] Output format types */
|
||||
public const OUTPUT_FORMAT_TYPES = [
|
||||
'svg',
|
||||
'png'
|
||||
];
|
||||
|
||||
/**
|
||||
* Constructor method for MyClass.
|
||||
*
|
||||
@ -83,6 +89,16 @@ class ParserKrokiTag {
|
||||
return in_array( strtolower( $string ), array_map( 'strtolower', self::DIAGRAM_TYPES ), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if $string is one of avaliable output format extensions.
|
||||
*
|
||||
* @param string $string string to check
|
||||
* @return bool {true} if output format compare to one of avaliable types, {false} if not compare
|
||||
*/
|
||||
private static function validOutputFormatType( string $string ): bool {
|
||||
return in_array( strtolower( $string ), array_map( 'strtolower', self::OUTPUT_FORMAT_TYPES ), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* - Add tracking categories
|
||||
* - Split parser cache for preview, where Graph uses different HTML
|
||||
@ -186,10 +202,10 @@ class ParserKrokiTag {
|
||||
|
||||
$output_format = $args['output_format'] ?? 'svg';
|
||||
|
||||
//TODO: add check for format onlt png or svg
|
||||
|
||||
//DEBUG
|
||||
echo $output_format;
|
||||
// Check for format only png or svg
|
||||
if ( !self::validOutputFormatType( $output_format ) ) {
|
||||
return $this->formatError( wfMessage( 'kroki-error-unknown-language' ) );
|
||||
}
|
||||
|
||||
// set post fields
|
||||
$requestParams = [
|
||||
@ -247,10 +263,10 @@ class ParserKrokiTag {
|
||||
|
||||
$output_format = $args['output_format'] ?? 'svg';
|
||||
|
||||
//TODO: add check for format onlt png or svg
|
||||
|
||||
//DEBUG
|
||||
echo $output_format;
|
||||
// Check for format only png or svg
|
||||
if ( !self::validOutputFormatType( $output_format ) ) {
|
||||
return $this->formatError( wfMessage( 'kroki-error-unknown-language' ) );
|
||||
}
|
||||
|
||||
// set post fields
|
||||
$requestParams = [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user