@@ -23,7 +23,28 @@ public function __construct(
23
23
public function find (string $ path , ?string $ salesChannelDomainId ): ?RedirectEntity
24
24
{
25
25
$ context = new Context (new SystemSource ());
26
- $ criteria = (new Criteria ())
26
+ $ criteria = $ this ->getCriteria ($ path , $ salesChannelDomainId );
27
+
28
+ $ redirect = $ this ->tinectRedirectsRedirectRepository ->search ($ criteria , $ context )->first ();
29
+
30
+ if ($ redirect instanceof RedirectEntity) {
31
+ return $ redirect ;
32
+ }
33
+
34
+ return null ;
35
+ }
36
+
37
+ public function findId (string $ path , ?string $ salesChannelDomainId ): ?string
38
+ {
39
+ $ context = new Context (new SystemSource ());
40
+ $ criteria = $ this ->getCriteria ($ path , $ salesChannelDomainId );
41
+
42
+ return $ this ->tinectRedirectsRedirectRepository ->searchIds ($ criteria , $ context )->firstId ();
43
+ }
44
+
45
+ private function getCriteria (string $ path , ?string $ salesChannelDomainId ): Criteria
46
+ {
47
+ return (new Criteria ())
27
48
->addFilter (new EqualsFilter ('source ' , $ path ))
28
49
->addFilter (
29
50
new MultiFilter (MultiFilter::CONNECTION_OR , [
@@ -33,13 +54,5 @@ public function find(string $path, ?string $salesChannelDomainId): ?RedirectEnti
33
54
)
34
55
->addSorting (new FieldSorting ('salesChannelDomainId ' , FieldSorting::DESCENDING ))
35
56
->setLimit (1 );
36
-
37
- $ redirect = $ this ->tinectRedirectsRedirectRepository ->search ($ criteria , $ context )->first ();
38
-
39
- if ($ redirect instanceof RedirectEntity) {
40
- return $ redirect ;
41
- }
42
-
43
- return null ;
44
57
}
45
58
}
0 commit comments