99use Ibexa \Contracts \Core \Repository \Values \Content \Field ;
1010use Ibexa \Core \FieldType \Date \Value as DateValue ;
1111use Ibexa \Core \FieldType \DateAndTime \Value as DateAndTimeValue ;
12+ use Netgen \Bundle \IbexaScheduledVisibilityBundle \Configuration \ScheduledVisibilityConfiguration ;
1213use Netgen \Bundle \IbexaScheduledVisibilityBundle \Enums \VisibilityUpdateResult ;
13- use Netgen \Bundle \IbexaScheduledVisibilityBundle \ScheduledVisibility \Registry ;
1414use OutOfBoundsException ;
1515
1616use function in_array ;
1717
1818final class ScheduledVisibilityService
1919{
2020 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 ,
2622 ) {}
2723
2824 /**
@@ -34,7 +30,7 @@ public function updateVisibilityIfNeeded(Content $content): VisibilityUpdateResu
3430 return VisibilityUpdateResult::NoChange;
3531 }
3632
37- $ handler = $ this ->registry -> get ( $ this -> type );
33+ $ handler = $ this ->configurationService -> getHandler ( );
3834
3935 if ($ this ->shouldBeHidden ($ content ) && !$ handler ->isHidden ($ content )) {
4036 $ handler ->hide ($ content );
@@ -53,13 +49,13 @@ public function updateVisibilityIfNeeded(Content $content): VisibilityUpdateResu
5349
5450 public function accept (Content $ content ): bool
5551 {
56- $ enabled = $ this ->enabled ;
57- if (!$ enabled ) {
52+ if (!$ this ->configurationService ->isEnabled ()) {
5853 return false ;
5954 }
6055
61- $ allowedAll = $ this ->allContentTypes ;
62- $ allowedContentTypes = $ this ->allowedContentTypes ;
56+ $ allowedAll = $ this ->configurationService ->isAllContentTypes ();
57+ $ allowedContentTypes = $ this ->configurationService ->getAllowedContentTypes ();
58+
6359 $ contentType = $ content ->getContentType ();
6460 if (!$ allowedAll && !in_array ($ contentType ->identifier , $ allowedContentTypes , true )) {
6561 return false ;
0 commit comments