|
|
|
@ -17,6 +17,13 @@ class AppExtension extends AbstractExtension
@@ -17,6 +17,13 @@ class AppExtension extends AbstractExtension
|
|
|
|
|
$this, |
|
|
|
|
'jIdenticon' |
|
|
|
|
] |
|
|
|
|
), |
|
|
|
|
new TwigFilter( |
|
|
|
|
'format_type', |
|
|
|
|
[ |
|
|
|
|
$this, |
|
|
|
|
'formatType' |
|
|
|
|
] |
|
|
|
|
) |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
@ -50,4 +57,71 @@ class AppExtension extends AbstractExtension
@@ -50,4 +57,71 @@ class AppExtension extends AbstractExtension
|
|
|
|
|
$format |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function formatType( |
|
|
|
|
mixed $value, |
|
|
|
|
int $code |
|
|
|
|
): string |
|
|
|
|
{ |
|
|
|
|
switch ($code) |
|
|
|
|
{ |
|
|
|
|
case \Kvazar\Index\Manticore::TYPE_NULL: |
|
|
|
|
|
|
|
|
|
return '[null]'; |
|
|
|
|
|
|
|
|
|
case \Kvazar\Index\Manticore::TYPE_BOOL: |
|
|
|
|
|
|
|
|
|
return sprintf( |
|
|
|
|
'[bool:%s]', |
|
|
|
|
$value ? 'true' : 'false' |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
case \Kvazar\Index\Manticore::TYPE_INT: |
|
|
|
|
|
|
|
|
|
return sprintf( |
|
|
|
|
'[int:%d]', |
|
|
|
|
$value |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
case \Kvazar\Index\Manticore::TYPE_FLOAT: |
|
|
|
|
|
|
|
|
|
return sprintf( |
|
|
|
|
'[float:%s]', |
|
|
|
|
$value |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
case \Kvazar\Index\Manticore::TYPE_STRING: |
|
|
|
|
|
|
|
|
|
return (string) nl2br( |
|
|
|
|
$value |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
case \Kvazar\Index\Manticore::TYPE_BIN: |
|
|
|
|
|
|
|
|
|
return '[binary]'; |
|
|
|
|
|
|
|
|
|
case \Kvazar\Index\Manticore::TYPE_JSON: |
|
|
|
|
|
|
|
|
|
return '[json]'; |
|
|
|
|
|
|
|
|
|
case \Kvazar\Index\Manticore::TYPE_XML: |
|
|
|
|
|
|
|
|
|
return '[xml]'; |
|
|
|
|
|
|
|
|
|
case \Kvazar\Index\Manticore::TYPE_BASE_64: |
|
|
|
|
|
|
|
|
|
return '[base64]'; |
|
|
|
|
|
|
|
|
|
case \Kvazar\Index\Manticore::TYPE_ARRAY: |
|
|
|
|
|
|
|
|
|
return '[array]'; |
|
|
|
|
|
|
|
|
|
case \Kvazar\Index\Manticore::TYPE_OBJECT: |
|
|
|
|
|
|
|
|
|
return '[array]'; |
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
return '[undefined]'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |