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,25 +10,31 @@
|
||||
*/
|
||||
|
||||
namespace IPS\forums\api\GraphQL\Mutations;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use IPS\Api\GraphQL\SafeException;
|
||||
use IPS\Api\GraphQL\TypeRegistry;
|
||||
use IPS\forums\api\GraphQL\Types\ForumType;
|
||||
use IPS\forums\Forum;
|
||||
use IPS\Node\Api\GraphQL\NodeMutator;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
use function intval;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark forum read mutation for GraphQL API
|
||||
*/
|
||||
class _MarkForumRead extends \IPS\Node\Api\GraphQL\NodeMutator
|
||||
class MarkForumRead extends NodeMutator
|
||||
{
|
||||
/*
|
||||
* @brief Query description
|
||||
*/
|
||||
public static $description = "Mark a forum as read";
|
||||
public static string $description = "Mark a forum as read";
|
||||
|
||||
/*
|
||||
* Mutation arguments
|
||||
@@ -42,8 +48,10 @@ class _MarkForumRead extends \IPS\Node\Api\GraphQL\NodeMutator
|
||||
|
||||
/**
|
||||
* Return the mutation return type
|
||||
*
|
||||
* @return ForumType
|
||||
*/
|
||||
public function type()
|
||||
public function type() : ForumType
|
||||
{
|
||||
return \IPS\forums\api\GraphQL\TypeRegistry::forum();
|
||||
}
|
||||
@@ -51,20 +59,19 @@ class _MarkForumRead extends \IPS\Node\Api\GraphQL\NodeMutator
|
||||
/**
|
||||
* Resolves this mutation
|
||||
*
|
||||
* @param mixed Value passed into this resolver
|
||||
* @param array Arguments
|
||||
* @param array Context values
|
||||
* @return \IPS\forums\Forum
|
||||
* @param mixed $val Value passed into this resolver
|
||||
* @param array $args Arguments
|
||||
* @return Forum
|
||||
*/
|
||||
public function resolve($val, $args)
|
||||
public function resolve( mixed $val, array $args ) : Forum
|
||||
{
|
||||
try
|
||||
{
|
||||
$forum = \IPS\forums\Forum::loadAndCheckPerms( \intval( $args['id'] ) );
|
||||
$forum = Forum::loadAndCheckPerms( intval( $args['id'] ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
throw new \IPS\Api\GraphQL\SafeException( 'INVALID_NODE', 'GQL/0004/2', 403 );
|
||||
throw new SafeException( 'INVALID_NODE', 'GQL/0004/2', 403 );
|
||||
}
|
||||
|
||||
$this->_markRead( $forum );
|
||||
|
||||
Reference in new issue
Block a user