Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

@@ -10,25 +10,29 @@
*/
namespace IPS\gallery\api\GraphQL\Queries;
use GraphQL\Type\Definition\ObjectType;
use IPS\Api\GraphQL\SafeException;
use IPS\Api\GraphQL\TypeRegistry;
use IPS\gallery\api\GraphQL\Types\ImageType;
use IPS\gallery\Image as ImageClass;
use OutOfRangeException;
use function defined;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Image query for GraphQL API
*/
class _Image
class Image
{
/*
* @brief Query description
*/
public static $description = "Returns a gallery image";
public static string $description = "Returns a gallery image";
/*
* Query arguments
@@ -43,7 +47,7 @@ class _Image
/**
* Return the query return type
*/
public function type()
public function type() : ImageType
{
return \IPS\gallery\api\GraphQL\TypeRegistry::image();
}
@@ -51,25 +55,26 @@ class _Image
/**
* Resolves this query
*
* @param mixed Value passed into this resolver
* @param array Arguments
* @param array Context values
* @return \IPS\gallery\Image
* @param mixed $val
* @param array $args
* @param array $context
* @param array $info
* @return ImageClass
*/
public function resolve($val, $args, $context, $info)
public function resolve( mixed $val, array $args, array $context, array $info ) : ImageClass
{
try
{
$image = \IPS\gallery\Image::loadAndCheckPerms( $args['id'] );
$image = ImageClass::loadAndCheckPerms( $args['id'] );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException )
{
throw new \IPS\Api\GraphQL\SafeException( 'NO_IMAGE', '1F294/2', 400 );
throw new SafeException( 'NO_IMAGE', '1F294/2', 400 );
}
if( !$image->can('read') )
{
throw new \IPS\Api\GraphQL\SafeException( 'INVALID_ID', '2F294/9', 403 );
throw new SafeException( 'INVALID_ID', '2F294/9', 403 );
}
return $image;