Skip to content

Commit

Permalink
Merge branch '4' into 5
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Dec 14, 2022
2 parents 50f6318 + c143e86 commit 8bacd1d
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 8 deletions.
10 changes: 9 additions & 1 deletion _legacy/AddElementToAreaMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace DNADesign\Elemental\GraphQL;

use SilverStripe\Dev\Deprecation;
use DNADesign\Elemental\Models\BaseElement;
use DNADesign\Elemental\Models\ElementalArea;
use DNADesign\Elemental\Services\ReorderElements;
Expand All @@ -12,16 +13,23 @@
use SilverStripe\GraphQL\MutationCreator;
use SilverStripe\GraphQL\OperationResolver;
use SilverStripe\GraphQL\Scaffolding\StaticSchema;
use SilverStripe\GraphQL\Manager;

if (!class_exists(MutationCreator::class)) {
return;
}

/**
* @deprecated 4.8..5.0 Use silverstripe/graphql:^4 functionality.
* @deprecated 4.8.0 Use silverstripe/graphql:^4 functionality instead
*/
class AddElementToAreaMutation extends MutationCreator implements OperationResolver
{
public function __construct(Manager $manager = null)
{
Deprecation::notice('4.8.0', 'Use silverstripe/graphql:^4 functionality instead', Deprecation::SCOPE_CLASS);
parent::__construct($manager);
}

public function attributes()
{
return [
Expand Down
10 changes: 9 additions & 1 deletion _legacy/DeleteBlocksMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,28 @@

namespace DNADesign\Elemental\GraphQL;

use SilverStripe\Dev\Deprecation;
use DNADesign\Elemental\Models\BaseElement;
use GraphQL\Type\Definition\Type;
use SilverStripe\GraphQL\MutationCreator;
use SilverStripe\GraphQL\Scaffolding\Scaffolders\CRUD\Delete;
use SilverStripe\GraphQL\Manager;

if (!class_exists(MutationCreator::class)) {
return;
}

/**
* @deprecated 4.8..5.0 Use silverstripe/graphql:^4 functionality.
* @deprecated 4.8.0 Use silverstripe/graphql:^4 functionality instead
*/
class DeleteBlocksMutation extends MutationCreator
{
public function __construct(Manager $manager = null)
{
Deprecation::notice('4.8.0', 'Use silverstripe/graphql:^4 functionality instead', Deprecation::SCOPE_CLASS);
parent::__construct($manager);
}

public function attributes()
{
return [
Expand Down
10 changes: 9 additions & 1 deletion _legacy/DuplicateElementMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace DNADesign\Elemental\GraphQL;

use SilverStripe\Dev\Deprecation;
use DNADesign\Elemental\Models\BaseElement;
use DNADesign\Elemental\Models\ElementalArea;
use DNADesign\Elemental\Services\ReorderElements;
Expand All @@ -13,16 +14,23 @@
use SilverStripe\GraphQL\MutationCreator;
use SilverStripe\GraphQL\OperationResolver;
use SilverStripe\GraphQL\Scaffolding\StaticSchema;
use SilverStripe\GraphQL\Manager;

if (!class_exists(MutationCreator::class)) {
return;
}

/**
* @deprecated 4.8..5.0 Use silverstripe/graphql:^4 functionality.
* @deprecated 4.8.0 Use silverstripe/graphql:^4 functionality instead
*/
class DuplicateElementMutation extends MutationCreator implements OperationResolver
{
public function __construct(Manager $manager = null)
{
Deprecation::notice('4.8.0', 'Use silverstripe/graphql:^4 functionality instead', Deprecation::SCOPE_CLASS);
parent::__construct($manager);
}

public function attributes()
{
return [
Expand Down
8 changes: 7 additions & 1 deletion _legacy/ElementsResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace DNADesign\Elemental\GraphQL;

use SilverStripe\Dev\Deprecation;
use GraphQL\Type\Definition\ResolveInfo;
use SilverStripe\GraphQL\OperationResolver;
use SilverStripe\ORM\DataList;
Expand All @@ -11,7 +12,7 @@
}

/**
* @deprecated 4.8..5.0 Use silverstripe/graphql:^4 functionality.
* @deprecated 4.8.0 Use silverstripe/graphql:^4 functionality instead
*/
class ElementsResolver implements OperationResolver
{
Expand All @@ -23,6 +24,11 @@ class ElementsResolver implements OperationResolver
* @return mixed|DataList
* @throws \Exception
*/
public function __construct()
{
Deprecation::notice('4.8.0', 'Use silverstripe/graphql:^4 functionality instead', Deprecation::SCOPE_CLASS);
}

public function resolve($object, array $args, $context, ResolveInfo $info)
{
if (!$object->canView($context['currentUser'])) {
Expand Down
8 changes: 7 additions & 1 deletion _legacy/ReadOneAreaResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace DNADesign\Elemental\GraphQL;

use SilverStripe\Dev\Deprecation;
use DNADesign\Elemental\Models\ElementalArea;
use Exception;
use GraphQL\Type\Definition\ResolveInfo;
Expand All @@ -14,10 +15,15 @@
}

/**
* @deprecated 4.8..5.0 Use silverstripe/graphql:^4 functionality.
* @deprecated 4.8.0 Use silverstripe/graphql:^4 functionality instead
*/
class ReadOneAreaResolver implements OperationResolver
{
public function __construct()
{
Deprecation::notice('4.8.0', 'Use silverstripe/graphql:^4 functionality instead', Deprecation::SCOPE_CLASS);
}

public function resolve($object, array $args, $context, ResolveInfo $info)
{
$idKey = StaticSchema::inst()->formatField('ID');
Expand Down
8 changes: 7 additions & 1 deletion _legacy/ReadOneBlockResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace DNADesign\Elemental\GraphQL;

use SilverStripe\Dev\Deprecation;
use DNADesign\Elemental\Models\BaseElement;
use GraphQL\Type\Definition\ResolveInfo;
use SilverStripe\Core\Injector\Injector;
Expand All @@ -14,10 +15,15 @@
}

/**
* @deprecated 4.8..5.0 Use silverstripe/graphql:^4 functionality.
* @deprecated 4.8.0 Use silverstripe/graphql:^4 functionality instead
*/
class ReadOneBlockResolver
{
public function __construct()
{
Deprecation::notice('4.8.0', 'Use silverstripe/graphql:^4 functionality instead', Deprecation::SCOPE_CLASS);
}

public static function resolve($obj, array $args, array $context, ResolveInfo $info)
{
$idKey = StaticSchema::inst()->formatField('ID');
Expand Down
10 changes: 9 additions & 1 deletion _legacy/SortBlockMutationCreator.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace DNADesign\Elemental\GraphQL;

use SilverStripe\Dev\Deprecation;
use DNADesign\Elemental\Models\BaseElement;
use DNADesign\Elemental\Services\ReorderElements;
use GraphQL\Type\Definition\ResolveInfo;
Expand All @@ -10,6 +11,7 @@
use SilverStripe\GraphQL\OperationResolver;
use SilverStripe\GraphQL\Scaffolding\StaticSchema;
use InvalidArgumentException;
use SilverStripe\GraphQL\Manager;

if (!interface_exists(OperationResolver::class)) {
return;
Expand All @@ -20,10 +22,16 @@
* orders for the block and its siblings. Only the source block will have a new version written, all siblings
* will be updated underneath the ORM to avoid this.
*
* @deprecated 4.8..5.0 Use silverstripe/graphql:^4 functionality.
* @deprecated 4.8.0 Use silverstripe/graphql:^4 functionality instead
*/
class SortBlockMutationCreator extends MutationCreator implements OperationResolver
{
public function __construct(Manager $manager = null)
{
Deprecation::notice('4.8.0', 'Use silverstripe/graphql:^4 functionality instead', Deprecation::SCOPE_CLASS);
parent::__construct($manager);
}

public function attributes()
{
return [
Expand Down
9 changes: 8 additions & 1 deletion _legacy/Types/ObjectType.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace DNADesign\Elemental\GraphQL\Types;

use SilverStripe\Dev\Deprecation;
use GraphQL\Type\Definition\CustomScalarType;
use SilverStripe\GraphQL\TypeCreator;

Expand All @@ -10,10 +11,16 @@
/**
* Creates a "scalar" type that is a single dimension object - represented as an associative array on the PHP side.
*
* @deprecated 4.8..5.0 Use silverstripe/graphql:^4 functionality.
* @deprecated 4.8.0 Use silverstripe/graphql:^4 functionality instead
*/
class ObjectType extends TypeCreator
{
public function __construct()
{
Deprecation::notice('4.8.0', 'Use silverstripe/graphql:^4 functionality instead', Deprecation::SCOPE_CLASS);
parent::__construct();
}

public function toType()
{
return new CustomScalarType([
Expand Down
3 changes: 3 additions & 0 deletions src/Extensions/ElementalAreaUsedOnTableExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public function updateUsageExcludedClasses(array &$excludedClasses)
*/
public function updateUsage(ArrayList &$usage, DataObject &$record)
{
Deprecation::withNoReplacement(function () {
Deprecation::notice('4.5.0', 'Use updateUsageExcludedClasses() instead');
});
// noop
}

Expand Down
4 changes: 4 additions & 0 deletions tests/TopPage/TopPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use DNADesign\Elemental\Models\ElementalArea;
use DNADesign\Elemental\TopPage;
use Page;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\ORM\DataObject;

Expand Down Expand Up @@ -164,6 +165,9 @@ public function testNewBlock(bool $populateTopPage): void
*/
public function testPageDuplication(int $fixedPageID): void
{
if (Deprecation::isEnabled()) {
$this->markTestSkipped('Test calls deprecated code');
}
/** @var TopPage\DataExtension $extension */
$extension = singleton(TopPage\DataExtension::class);
$extension->withFixedTopPage($fixedPageID, function () use ($fixedPageID) {
Expand Down

0 comments on commit 8bacd1d

Please sign in to comment.