88use App \Entity \Period ;
99use App \State \Util \AbstractPersistProcessor ;
1010use App \Util \DateTimeUtil ;
11- use FOS \HttpCacheBundle \CacheManager ;
1211
1312/**
1413 * @template-extends AbstractPersistProcessor<Period>
1514 */
1615class PeriodPersistProcessor extends AbstractPersistProcessor {
1716 public function __construct (
18- ProcessorInterface $ decorated ,
19- private readonly CacheManager $ cacheManager
17+ ProcessorInterface $ decorated
2018 ) {
2119 parent ::__construct ($ decorated );
2220 }
@@ -25,32 +23,29 @@ public function __construct(
2523 * @param Period $data
2624 */
2725 public function onBefore ($ data , Operation $ operation , array $ uriVariables = [], array $ context = []): Period {
28- $ this -> moveDaysAndScheduleEntries ($ data , $ context ['previous_data ' ] ?? null );
26+ self :: moveDaysAndScheduleEntries ($ data , $ context ['previous_data ' ] ?? null );
2927 self ::removeExtraDays ($ data );
3028 self ::addMissingDays ($ data );
3129
3230 return $ data ;
3331 }
3432
35- public function moveDaysAndScheduleEntries (Period $ period , ?Period $ originalPeriod = null ) {
33+ public static function moveDaysAndScheduleEntries (Period $ period , ?Period $ originalPeriod = null ) {
3634 if (!$ originalPeriod ) {
3735 return ;
3836 }
3937
40- $ deltaMinutes = DateTimeUtil::differenceInMinutes ($ originalPeriod ->start , $ period ->start );
41- if (0 === $ deltaMinutes ) {
42- return ;
43- }
44-
45- // start date shifts --> purge schedule_entries subresource to reflect changes in dates + numbers
46- $ this ->cacheManager ->invalidateTags (["/api/periods/ {$ period ->getId ()}/schedule_entries " ]);
47-
4838 // moveScheduleEntries === true: scheduleEntries move relative to the start date (no change of offset needed -> return)
4939 // moveScheduleEntries === false: scheduleEntries stay absolutely on the scheduled calendar date (change of offset needed)
5040 if ($ period ->moveScheduleEntries ) {
5141 return ;
5242 }
5343
44+ $ deltaMinutes = DateTimeUtil::differenceInMinutes ($ originalPeriod ->start , $ period ->start );
45+ if (0 === $ deltaMinutes ) {
46+ return ;
47+ }
48+
5449 // Move ScheduleEntries
5550 // --> existing scheduleEntries outside the new period boundary are not possible (validation should have already failed)
5651 foreach ($ period ->scheduleEntries as $ scheduleEntry ) {
0 commit comments