9
9
use Ibexa \Contracts \Core \Repository \Values \Content \Field ;
10
10
use Ibexa \Core \FieldType \Date \Value as DateValue ;
11
11
use Ibexa \Core \FieldType \DateAndTime \Value as DateAndTimeValue ;
12
+ use Netgen \Bundle \IbexaScheduledVisibilityBundle \Configuration \ScheduledVisibilityConfiguration ;
12
13
use Netgen \Bundle \IbexaScheduledVisibilityBundle \Enums \VisibilityUpdateResult ;
13
- use Netgen \Bundle \IbexaScheduledVisibilityBundle \ScheduledVisibility \Registry ;
14
14
use OutOfBoundsException ;
15
15
16
16
use function in_array ;
17
17
18
18
final class ScheduledVisibilityService
19
19
{
20
20
public function __construct (
21
- private readonly Registry $ registry ,
22
- private readonly string $ type ,
23
- private readonly bool $ enabled ,
24
- private readonly bool $ allContentTypes ,
25
- private readonly array $ allowedContentTypes ,
21
+ private ScheduledVisibilityConfiguration $ configurationService ,
26
22
) {}
27
23
28
24
/**
@@ -34,7 +30,7 @@ public function updateVisibilityIfNeeded(Content $content): VisibilityUpdateResu
34
30
return VisibilityUpdateResult::NoChange;
35
31
}
36
32
37
- $ handler = $ this ->registry -> get ( $ this -> type );
33
+ $ handler = $ this ->configurationService -> getHandler ( );
38
34
39
35
if ($ this ->shouldBeHidden ($ content ) && !$ handler ->isHidden ($ content )) {
40
36
$ handler ->hide ($ content );
@@ -53,13 +49,13 @@ public function updateVisibilityIfNeeded(Content $content): VisibilityUpdateResu
53
49
54
50
public function accept (Content $ content ): bool
55
51
{
56
- $ enabled = $ this ->enabled ;
57
- if (!$ enabled ) {
52
+ if (!$ this ->configurationService ->isEnabled ()) {
58
53
return false ;
59
54
}
60
55
61
- $ allowedAll = $ this ->allContentTypes ;
62
- $ allowedContentTypes = $ this ->allowedContentTypes ;
56
+ $ allowedAll = $ this ->configurationService ->isAllContentTypes ();
57
+ $ allowedContentTypes = $ this ->configurationService ->getAllowedContentTypes ();
58
+
63
59
$ contentType = $ content ->getContentType ();
64
60
if (!$ allowedAll && !in_array ($ contentType ->identifier , $ allowedContentTypes , true )) {
65
61
return false ;
0 commit comments