32
32
*/
33
33
class AssetsHelper implements ProtectedContextAwareInterface
34
34
{
35
-
36
35
/**
37
36
* @Flow\Inject
38
37
* @var AssetRepository
@@ -54,55 +53,55 @@ class AssetsHelper implements ProtectedContextAwareInterface
54
53
/**
55
54
* @return QueryResultInterface<AssetInterface> | null
56
55
*/
57
- public function findByTag (Tag | string $ tag ): ?QueryResultInterface
56
+ public function findByTag (? Tag $ tag ): ?QueryResultInterface
58
57
{
59
- if (is_string ($ tag )) {
60
- $ tag = $ this ->tagRepository ->findOneByLabel ($ tag );
61
- }
62
-
63
58
if (!$ tag ) {
64
59
return null ;
65
60
}
66
-
67
- try {
68
- return $ this ->assetRepository ->findByTag ($ tag );
69
- } catch (InvalidQueryException ) {
70
- }
71
-
72
- return null ;
61
+ return $ this ->assetRepository ->findByTag ($ tag );
73
62
}
74
63
75
64
/**
76
65
* @return QueryResultInterface<AssetInterface> | null
77
66
*/
78
- public function findByCollection ( AssetCollection | string $ collection ): ?QueryResultInterface
67
+ public function findByTagLabel (? string $ tagLabel ): ?QueryResultInterface
79
68
{
80
- if (is_string ( $ collection ) ) {
81
- $ collection = $ this -> assetCollectionRepository -> findOneByTitle ( $ collection ) ;
69
+ if (! $ tagLabel ) {
70
+ return null ;
82
71
}
72
+ $ tag = $ this ->tagRepository ->findOneByLabel ($ tagLabel );
73
+ return $ this ->findByTag ($ tag );
74
+ }
83
75
76
+ /**
77
+ * @return QueryResultInterface<AssetInterface> | null
78
+ */
79
+ public function findByCollection (?AssetCollection $ collection ): ?QueryResultInterface
80
+ {
84
81
if (!$ collection ) {
85
82
return null ;
86
83
}
84
+ return $ this ->assetRepository ->findByAssetCollection ($ collection );
85
+ }
87
86
88
- try {
89
- return $ this ->assetRepository ->findByAssetCollection ($ collection );
90
- } catch (InvalidQueryException ) {
87
+ /**
88
+ * @return QueryResultInterface<AssetInterface> | null
89
+ */
90
+ public function findByCollectionTitle (?string $ collectionTitle ): ?QueryResultInterface
91
+ {
92
+ if (!$ collectionTitle ) {
93
+ return null ;
91
94
}
92
-
93
- return null ;
95
+ $ collection = $ this -> assetCollectionRepository -> findOneByTitle ( $ collectionTitle );
96
+ return $ this -> findByCollection ( $ collection ) ;
94
97
}
95
98
96
99
/**
97
100
* @param Tag[] $tags
98
101
* @return QueryResultInterface<AssetInterface> | null
99
102
*/
100
- public function findBySearchTerm (string $ searchTerm , array $ tags = [], AssetCollection | string $ collection = null ): ?QueryResultInterface
103
+ public function search (string $ searchTerm , array $ tags = [], AssetCollection $ collection = null ): ?QueryResultInterface
101
104
{
102
- if (is_string ($ collection )) {
103
- $ collection = $ this ->assetCollectionRepository ->findOneByTitle ($ collection );
104
- }
105
-
106
105
if (!$ searchTerm ) {
107
106
return null ;
108
107
}
0 commit comments