File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed
Classes/GraphQL/Resolver/Type Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 20
20
use Neos \Flow \Annotations as Flow ;
21
21
use Neos \Flow \Persistence \PersistenceManagerInterface ;
22
22
use Neos \Media \Domain \Model \AssetCollection ;
23
+ use Neos \Media \Domain \Model \Tag ;
23
24
use Neos \Media \Domain \Repository \AssetCollectionRepository ;
24
25
use Neos \Media \Domain \Repository \AssetRepository ;
25
26
use Neos \Neos \Domain \Model \Site ;
@@ -83,8 +84,14 @@ public function tags(Types\AssetCollection $assetCollection): Types\Tags
83
84
{
84
85
/** @var AssetCollection $originalAssetCollection */
85
86
$ originalAssetCollection = $ this ->assetCollectionRepository ->findByIdentifier ($ assetCollection ->id ->value );
86
- return $ originalAssetCollection ?
87
- Types \Tags::fromArray ($ originalAssetCollection ->getTags ()->toArray ()) : Types \Tags::empty ();
87
+
88
+ return $ originalAssetCollection ? Types \Tags::fromArray (array_map (
89
+ fn (Tag $ tag ) => instantiate (Types \Tag::class, [
90
+ 'id ' => $ this ->persistenceManager ->getIdentifierByObject ($ tag ),
91
+ 'label ' => $ tag ->getLabel (),
92
+ ]),
93
+ $ originalAssetCollection ->getTags ()->toArray ()
94
+ )) : Types \Tags::empty ();
88
95
}
89
96
90
97
public function parent (Types \AssetCollection $ assetCollection ): ?Types \AssetCollectionParent
Original file line number Diff line number Diff line change 15
15
*/
16
16
17
17
use Flowpack \Media \Ui \GraphQL \MediaApi ;
18
+ use Flowpack \Media \Ui \GraphQL \Resolver \Type \AssetCollectionResolver ;
18
19
use Flowpack \Media \Ui \GraphQL \Types ;
19
20
use Flowpack \Media \Ui \Tests \Functional \AbstractMediaTestCase ;
20
21
use Neos \Flow \Persistence \Doctrine \PersistenceManager ;
@@ -37,6 +38,7 @@ public function setUp(): void
37
38
}
38
39
39
40
$ this ->mediaApi = $ this ->objectManager ->get (MediaApi::class);
41
+ $ this ->assetCollectionResolver = $ this ->objectManager ->get (AssetCollectionResolver::class);
40
42
}
41
43
42
44
public function testCreateTag (): void
@@ -63,4 +65,21 @@ public function testDeleteTag(): void
63
65
$ deletedTag = $ this ->mediaApi ->tag ($ tag ->id );
64
66
$ this ->assertNull ($ deletedTag );
65
67
}
68
+
69
+ public function testTagAssetCollection (): void
70
+ {
71
+ $ assetCollection = $ this ->mediaApi ->createAssetCollection (
72
+ Types \AssetCollectionTitle::fromString ('Test Collection ' )
73
+ );
74
+ $ tag = $ this ->mediaApi ->createTag ('Test Tag ' , $ assetCollection ->id );
75
+ $ createdTag = $ this ->mediaApi ->tag ($ tag ->id );
76
+
77
+ $ resolvedTags = $ this ->assetCollectionResolver ->tags ($ assetCollection );
78
+ $ this ->assertCount (1 , $ resolvedTags ->tags );
79
+ $ this ->assertEquals (
80
+ $ createdTag ,
81
+ $ resolvedTags ->tags [0 ],
82
+ 'The tag should be associated with the asset collection '
83
+ );
84
+ }
66
85
}
You can’t perform that action at this time.
0 commit comments