1 | <?php |
||
2 | namespace DNADesign\Elemental\GraphQL; |
||
3 | |||
4 | use DNADesign\Elemental\Models\BaseElement; |
||
5 | use DNADesign\Elemental\Services\ReorderElements; |
||
6 | use GraphQL\Type\Definition\ResolveInfo; |
||
0 ignored issues
–
show
|
|||
7 | use GraphQL\Type\Definition\Type; |
||
0 ignored issues
–
show
The type
GraphQL\Type\Definition\Type was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths
Loading history...
|
|||
8 | use SilverStripe\Core\Convert; |
||
9 | use SilverStripe\Core\Injector\Injector; |
||
10 | use SilverStripe\GraphQL\MutationCreator; |
||
0 ignored issues
–
show
The type
SilverStripe\GraphQL\MutationCreator was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths
Loading history...
|
|||
11 | use SilverStripe\GraphQL\OperationResolver; |
||
0 ignored issues
–
show
The type
SilverStripe\GraphQL\OperationResolver was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths
Loading history...
|
|||
12 | use SilverStripe\ORM\DataObject; |
||
13 | use SilverStripe\ORM\Queries\SQLUpdate; |
||
14 | |||
15 | /** |
||
16 | * Given a source block ID and the ID of the block to reorder the source block after, update all affected sort |
||
17 | * orders for the block and its siblings. Only the source block will have a new version written, all siblings |
||
18 | * will be updated underneath the ORM to avoid this. |
||
19 | */ |
||
20 | class SortBlockMutationCreator extends MutationCreator implements OperationResolver |
||
21 | { |
||
22 | public function attributes() |
||
23 | { |
||
24 | return [ |
||
25 | 'name' => 'sortBlock', |
||
26 | 'description' => 'Changes the sort position of an element' |
||
27 | ]; |
||
28 | } |
||
29 | |||
30 | public function type() |
||
31 | { |
||
32 | return $this->manager->getType('Block'); |
||
33 | } |
||
34 | |||
35 | public function args() |
||
36 | { |
||
37 | return [ |
||
38 | 'ID' => ['type' => Type::nonNull(Type::id())], |
||
39 | 'AfterBlockID' => ['type' => Type::nonNull(Type::id())], |
||
40 | ]; |
||
41 | } |
||
42 | |||
43 | public function resolve($object, array $args, $context, ResolveInfo $info) |
||
44 | { |
||
45 | $element = BaseElement::get()->byID($args['ID']); |
||
46 | |||
47 | if (!$element) { |
||
0 ignored issues
–
show
|
|||
48 | throw new InvalidArgumentException(sprintf( |
||
0 ignored issues
–
show
|
|||
49 | '%s#%s not found', |
||
50 | BaseElement::class, |
||
51 | $args['ID'] |
||
52 | )); |
||
53 | } |
||
54 | |||
55 | if (!$element->canEdit($context['currentUser'])) { |
||
56 | throw new InvalidArgumentException( |
||
57 | 'Changing the sort order of blocks is not allowed for the current user' |
||
58 | ); |
||
59 | } |
||
60 | |||
61 | $reorderingService = Injector::inst()->create(ReorderElements::class, $element); |
||
62 | return $reorderingService->reorder($args['AfterBlockID']); |
||
63 | } |
||
64 | } |
||
65 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths