| Conditions | 1 |
| Paths | 1 |
| Total Lines | 20 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 1 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | 1 | public static function build(): iterable |
|
| 16 | { |
||
| 17 | 1 | yield 'linkCollectionToCollection' => fn () => [ |
|
| 18 | 1 | 'type' => Type::nonNull(_types()->getOutput(Collection::class)), |
|
| 19 | 1 | 'description' => 'This will link all images from the source collection to the target collection. The returned collection is the target', |
|
| 20 | 1 | 'args' => [ |
|
| 21 | 1 | 'sourceCollection' => Type::nonNull(_types()->getId(Collection::class)), |
|
| 22 | 1 | 'targetCollection' => Type::nonNull(_types()->getId(Collection::class)), |
|
| 23 | 1 | ], |
|
| 24 | 1 | 'resolve' => function ($root, array $args): Collection { |
|
| 25 | 1 | $sourceCollection = $args['sourceCollection']->getEntity(); |
|
| 26 | 1 | $targetCollection = $args['targetCollection']->getEntity(); |
|
| 27 | |||
| 28 | 1 | Helper::throwIfDenied($targetCollection, 'update'); |
|
| 29 | |||
| 30 | /** @var CollectionRepository $collectionRepository */ |
||
| 31 | 1 | $collectionRepository = _em()->getRepository(Collection::class); |
|
| 32 | 1 | $collectionRepository->linkCollectionToCollection($sourceCollection, $targetCollection); |
|
| 33 | |||
| 34 | 1 | return $targetCollection; |
|
|
|
|||
| 35 | 1 | }, |
|
| 39 |