Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -10,20 +10,19 @@
|
||||
*/
|
||||
|
||||
namespace IPS\gallery\api\GraphQL;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use IPS\Api\GraphQL\Types;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gallery mutations GraphQL API
|
||||
*/
|
||||
abstract class _Mutation
|
||||
abstract class Mutation
|
||||
{
|
||||
/**
|
||||
* Get the supported query types in this app
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -10,30 +10,30 @@
|
||||
*/
|
||||
|
||||
namespace IPS\gallery\api\GraphQL;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use IPS\Api\GraphQL\Types;
|
||||
use IPS\gallery\api\GraphQL\Queries\Image;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forums queries for GraphQL API
|
||||
*/
|
||||
abstract class _Query
|
||||
abstract class Query
|
||||
{
|
||||
/**
|
||||
* Get the supported query types in this app
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function queries()
|
||||
public static function queries() : array
|
||||
{
|
||||
return [
|
||||
'image' => new \IPS\gallery\api\GraphQL\Queries\Image(),
|
||||
'image' => new Image(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -10,13 +10,17 @@
|
||||
*/
|
||||
|
||||
namespace IPS\gallery\api\GraphQL;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use IPS\Api\GraphQL\Types;
|
||||
use IPS\gallery\api\GraphQL\Types\AlbumCommentType;
|
||||
use IPS\gallery\api\GraphQL\Types\AlbumItemType;
|
||||
use IPS\gallery\api\GraphQL\Types\AlbumType;
|
||||
use IPS\gallery\api\GraphQL\Types\ImageCommentType;
|
||||
use IPS\gallery\api\GraphQL\Types\ImageType;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -25,42 +29,42 @@ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
* so we'll generate singletons here.
|
||||
* @todo automate this somehow?
|
||||
*/
|
||||
class _TypeRegistry
|
||||
class TypeRegistry
|
||||
{
|
||||
/**
|
||||
* Returns the album instance
|
||||
*
|
||||
* @var \IPS\gallery\api\GraphQL\Types\AlbumType
|
||||
* @var AlbumType|null
|
||||
*/
|
||||
protected static $album;
|
||||
protected static ?AlbumType $album = null;
|
||||
|
||||
/**
|
||||
* Returns the album comment instance
|
||||
*
|
||||
* @var \IPS\gallery\api\GraphQL\Types\AlbumCommentType
|
||||
* @var AlbumCommentType|null
|
||||
*/
|
||||
protected static $albumComment;
|
||||
protected static ?AlbumCommentType $albumComment = null;
|
||||
|
||||
/**
|
||||
* Returns the album item instance
|
||||
*
|
||||
* @var \IPS\gallery\api\GraphQL\Types\AlbumItemType
|
||||
* @var AlbumItemType|null
|
||||
*/
|
||||
protected static $albumItem;
|
||||
protected static ?AlbumItemType $albumItem = null;
|
||||
|
||||
/**
|
||||
* Returns the image instance
|
||||
*
|
||||
* @var \IPS\gallery\api\GraphQL\Types\ImageType
|
||||
* @var ImageType|null
|
||||
*/
|
||||
protected static $image;
|
||||
protected static ?ImageType $image = null;
|
||||
|
||||
/**
|
||||
* Returns the Image comment instance
|
||||
*
|
||||
* @var \IPS\gallery\api\GraphQL\Types\ImageCommentType
|
||||
* @var ImageCommentType|null
|
||||
*/
|
||||
protected static $imageComment;
|
||||
protected static ?ImageCommentType $imageComment = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -71,42 +75,42 @@ class _TypeRegistry
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ImageType
|
||||
* @return AlbumType
|
||||
*/
|
||||
public static function album() : \IPS\gallery\api\GraphQL\Types\AlbumType
|
||||
public static function album() : AlbumType
|
||||
{
|
||||
return self::$album ?: (self::$album = new \IPS\gallery\api\GraphQL\Types\AlbumType());
|
||||
return self::$album ?: (self::$album = new AlbumType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AlbumCommentType
|
||||
*/
|
||||
public static function albumComment() : \IPS\gallery\api\GraphQL\Types\AlbumCommentType
|
||||
public static function albumComment() : AlbumCommentType
|
||||
{
|
||||
return self::$albumComment ?: (self::$albumComment = new \IPS\gallery\api\GraphQL\Types\AlbumCommentType());
|
||||
return self::$albumComment ?: (self::$albumComment = new AlbumCommentType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AlbumCommentType
|
||||
* @return AlbumItemType
|
||||
*/
|
||||
public static function albumItem() : \IPS\gallery\api\GraphQL\Types\AlbumItemType
|
||||
public static function albumItem() : AlbumItemType
|
||||
{
|
||||
return self::$albumItem ?: (self::$albumItem = new \IPS\gallery\api\GraphQL\Types\AlbumItemType());
|
||||
return self::$albumItem ?: (self::$albumItem = new AlbumItemType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ImageType
|
||||
*/
|
||||
public static function image() : \IPS\gallery\api\GraphQL\Types\ImageType
|
||||
public static function image() : ImageType
|
||||
{
|
||||
return self::$image ?: (self::$image = new \IPS\gallery\api\GraphQL\Types\ImageType());
|
||||
return self::$image ?: (self::$image = new ImageType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ImageCommentType
|
||||
*/
|
||||
public static function imageComment() : \IPS\gallery\api\GraphQL\Types\ImageCommentType
|
||||
public static function imageComment() : ImageCommentType
|
||||
{
|
||||
return self::$imageComment ?: (self::$imageComment = new \IPS\gallery\api\GraphQL\Types\ImageCommentType());
|
||||
return self::$imageComment ?: (self::$imageComment = new ImageCommentType());
|
||||
}
|
||||
}
|
||||
@@ -11,53 +11,44 @@
|
||||
|
||||
namespace IPS\gallery\api\GraphQL\Types;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use IPS\Api\GraphQL\TypeRegistry;
|
||||
use IPS\Content\Api\GraphQL\CommentType;
|
||||
use IPS\gallery\api\GraphQL\TypeRegistry;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* AlbumCommentType for GraphQL API
|
||||
*/
|
||||
class _AlbumCommentType extends \IPS\Content\Api\GraphQL\CommentType
|
||||
class AlbumCommentType extends CommentType
|
||||
{
|
||||
/*
|
||||
* @brief The item classname we use for this type
|
||||
*/
|
||||
protected static $commentClass = '\IPS\gallery\Album\Comment';
|
||||
protected static string $commentClass = '\IPS\gallery\Album\Comment';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type name
|
||||
*/
|
||||
protected static $typeName = 'gallery_AlbumComment';
|
||||
protected static string $typeName = 'gallery_AlbumComment';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type description
|
||||
*/
|
||||
protected static $typeDescription = 'An album comment';
|
||||
protected static string $typeDescription = 'An album comment';
|
||||
|
||||
/**
|
||||
* Get the item type that goes with this item type
|
||||
*
|
||||
* @return ObjectType
|
||||
*/
|
||||
public static function getItemType()
|
||||
public static function getItemType(): ObjectType
|
||||
{
|
||||
return \IPS\gallery\api\GraphQL\TypeRegistry::album();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the fields available in this type
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fields()
|
||||
{
|
||||
$defaultFields = parent::fields();
|
||||
return $defaultFields;
|
||||
return TypeRegistry::album();
|
||||
}
|
||||
}
|
||||
@@ -11,46 +11,48 @@
|
||||
|
||||
namespace IPS\gallery\api\GraphQL\Types;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use IPS\Api\GraphQL\TypeRegistry;
|
||||
use IPS\Content\Api\GraphQL\ItemType;
|
||||
use IPS\gallery\api\GraphQL\TypeRegistry;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* AlbumItemType for GraphQL API
|
||||
*/
|
||||
class _AlbumItemType extends \IPS\Content\Api\GraphQL\ItemType
|
||||
class AlbumItemType extends ItemType
|
||||
{
|
||||
/*
|
||||
* @brief The item classname we use for this type
|
||||
*/
|
||||
protected static $itemClass = '\IPS\gallery\Album\Item';
|
||||
protected static string $itemClass = '\IPS\gallery\Album\Item';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type name
|
||||
*/
|
||||
protected static $typeName = 'gallery_AlbumItem';
|
||||
protected static string $typeName = 'gallery_AlbumItem';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type description
|
||||
*/
|
||||
protected static $typeDescription = 'An album';
|
||||
protected static string $typeDescription = 'An album';
|
||||
|
||||
/*
|
||||
* @brief Follow data passed in to FollowType resolver
|
||||
*/
|
||||
protected static $followData = array('app' => 'gallery', 'area' => 'album');
|
||||
protected static array $followData = array('app' => 'gallery', 'area' => 'album');
|
||||
|
||||
/**
|
||||
* Return the fields available in this type
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fields()
|
||||
public function fields(): array
|
||||
{
|
||||
// Extend our fields with image-specific stuff
|
||||
$defaultFields = parent::fields();
|
||||
@@ -68,8 +70,8 @@ class _AlbumItemType extends \IPS\Content\Api\GraphQL\ItemType
|
||||
*
|
||||
* @return ObjectType
|
||||
*/
|
||||
protected static function getCommentType()
|
||||
protected static function getCommentType(): ObjectType
|
||||
{
|
||||
return \IPS\gallery\api\GraphQL\TypeRegistry::albumComment();
|
||||
return TypeRegistry::albumComment();
|
||||
}
|
||||
}
|
||||
@@ -12,45 +12,47 @@
|
||||
namespace IPS\gallery\api\GraphQL\Types;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use IPS\Api\GraphQL\TypeRegistry;
|
||||
use IPS\Node\Api\GraphQL\NodeType;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* AlbumType for GraphQL API
|
||||
*/
|
||||
class _AlbumType extends \IPS\Node\Api\GraphQL\NodeType
|
||||
class AlbumType extends NodeType
|
||||
{
|
||||
/*
|
||||
* @brief The item classname we use for this type
|
||||
*/
|
||||
protected static $nodeClass = '\IPS\gallery\Album';
|
||||
protected static string $nodeClass = '\IPS\gallery\Album';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type name
|
||||
*/
|
||||
protected static $typeName = 'gallery_Album';
|
||||
protected static string $typeName = 'gallery_Album';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type description
|
||||
*/
|
||||
protected static $typeDescription = 'An album';
|
||||
protected static string $typeDescription = 'An album';
|
||||
|
||||
/*
|
||||
* @brief Follow data passed in to FollowType resolver
|
||||
*/
|
||||
protected static $followData = array('app' => 'gallery', 'area' => 'album');
|
||||
protected static array $followData = array('app' => 'gallery', 'area' => 'album');
|
||||
|
||||
/**
|
||||
* Return the fields available in this type
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fields()
|
||||
public function fields(): array
|
||||
{
|
||||
$defaultFields = parent::fields();
|
||||
$albumFields = array(
|
||||
@@ -91,7 +93,7 @@ class _AlbumType extends \IPS\Node\Api\GraphQL\NodeType
|
||||
*
|
||||
* @return ObjectType
|
||||
*/
|
||||
public static function getItemType()
|
||||
public static function getItemType(): ObjectType
|
||||
{
|
||||
return \IPS\gallery\api\GraphQL\TypeRegistry::image();
|
||||
}
|
||||
|
||||
@@ -11,53 +11,44 @@
|
||||
|
||||
namespace IPS\gallery\api\GraphQL\Types;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use IPS\Api\GraphQL\TypeRegistry;
|
||||
use IPS\Content\Api\GraphQL\CommentType;
|
||||
use IPS\gallery\api\GraphQL\TypeRegistry;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* ImageCommentType for GraphQL API
|
||||
*/
|
||||
class _ImageCommentType extends \IPS\Content\Api\GraphQL\CommentType
|
||||
class ImageCommentType extends CommentType
|
||||
{
|
||||
/*
|
||||
* @brief The item classname we use for this type
|
||||
*/
|
||||
protected static $commentClass = '\IPS\gallery\Image\Comment';
|
||||
protected static string $commentClass = '\IPS\gallery\Image\Comment';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type name
|
||||
*/
|
||||
protected static $typeName = 'gallery_ImageComment';
|
||||
protected static string $typeName = 'gallery_ImageComment';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type description
|
||||
*/
|
||||
protected static $typeDescription = 'An image comment';
|
||||
protected static string $typeDescription = 'An image comment';
|
||||
|
||||
/**
|
||||
* Get the item type that goes with this item type
|
||||
*
|
||||
* @return ObjectType
|
||||
*/
|
||||
public static function getItemType()
|
||||
public static function getItemType(): ObjectType
|
||||
{
|
||||
return \IPS\gallery\api\GraphQL\TypeRegistry::image();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the fields available in this type
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fields()
|
||||
{
|
||||
$defaultFields = parent::fields();
|
||||
return $defaultFields;
|
||||
return TypeRegistry::image();
|
||||
}
|
||||
}
|
||||
@@ -12,45 +12,50 @@
|
||||
namespace IPS\gallery\api\GraphQL\Types;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use IPS\Api\GraphQL\TypeRegistry;
|
||||
use IPS\Content\Api\GraphQL\ItemType;
|
||||
use IPS\File;
|
||||
use IPS\gallery\Album;
|
||||
use IPS\GeoLocation;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* ImageType for GraphQL API
|
||||
*/
|
||||
class _ImageType extends \IPS\Content\Api\GraphQL\ItemType
|
||||
class ImageType extends ItemType
|
||||
{
|
||||
/*
|
||||
* @brief The item classname we use for this type
|
||||
*/
|
||||
protected static $itemClass = '\IPS\gallery\Image';
|
||||
protected static string $itemClass = '\IPS\gallery\Image';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type name
|
||||
*/
|
||||
protected static $typeName = 'gallery_Image';
|
||||
protected static string $typeName = 'gallery_Image';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type description
|
||||
*/
|
||||
protected static $typeDescription = 'An image';
|
||||
protected static string $typeDescription = 'An image';
|
||||
|
||||
/*
|
||||
* @brief Follow data passed in to FollowType resolver
|
||||
*/
|
||||
protected static $followData = array('app' => 'gallery', 'area' => 'image');
|
||||
protected static array $followData = array('app' => 'gallery', 'area' => 'image');
|
||||
|
||||
/**
|
||||
* Return the fields available in this type
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fields()
|
||||
public function fields(): array
|
||||
{
|
||||
// Extend our fields with image-specific stuff
|
||||
$defaultFields = parent::fields();
|
||||
@@ -72,7 +77,7 @@ class _ImageType extends \IPS\Content\Api\GraphQL\ItemType
|
||||
'resolve' => function ($image) {
|
||||
if( $image->album_id )
|
||||
{
|
||||
return \IPS\gallery\Album::load( $image->album_id );
|
||||
return Album::load( $image->album_id );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -111,19 +116,19 @@ class _ImageType extends \IPS\Content\Api\GraphQL\ItemType
|
||||
'maskedFileName' => [
|
||||
'type' => TypeRegistry::string(),
|
||||
'resolve' => function ($image) {
|
||||
return (string) \IPS\File::get( 'gallery_Images', $image->masked_file_name )->url;
|
||||
return (string) File::get( 'gallery_Images', $image->masked_file_name )->url;
|
||||
}
|
||||
],
|
||||
'originalFileName' => [
|
||||
'type' => TypeRegistry::string(),
|
||||
'resolve' => function ($image) {
|
||||
return (string) \IPS\File::get( 'gallery_Images', $image->original_file_name )->url;
|
||||
return (string) File::get( 'gallery_Images', $image->original_file_name )->url;
|
||||
}
|
||||
],
|
||||
'smallFileName' => [
|
||||
'type' => TypeRegistry::string(),
|
||||
'resolve' => function ($image) {
|
||||
return (string) \IPS\File::get( 'gallery_Images', $image->small_file_name )->url;
|
||||
return (string) File::get( 'gallery_Images', $image->small_file_name )->url;
|
||||
}
|
||||
],
|
||||
'fileSize' => [
|
||||
@@ -133,11 +138,11 @@ class _ImageType extends \IPS\Content\Api\GraphQL\ItemType
|
||||
}
|
||||
],
|
||||
'location' => [
|
||||
'type' => \IPS\GeoLocation\Api\GraphQL\TypeRegistry::geolocation(),
|
||||
'type' => GeoLocation\Api\GraphQL\TypeRegistry::geolocation(),
|
||||
'resolve' => function ($image) {
|
||||
if( $image->gps_raw )
|
||||
{
|
||||
return \IPS\GeoLocation::buildFromJson( $image->gps_raw );
|
||||
return GeoLocation::buildFromJson( $image->gps_raw );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -197,7 +202,7 @@ class _ImageType extends \IPS\Content\Api\GraphQL\ItemType
|
||||
*
|
||||
* @return ObjectType
|
||||
*/
|
||||
protected static function getCommentType()
|
||||
protected static function getCommentType(): ObjectType
|
||||
{
|
||||
return \IPS\gallery\api\GraphQL\TypeRegistry::imageComment();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user