/** * @param GenericEvent $event */ public function updateChannel(GenericEvent $event) { $channel = $event->getSubject(); if (!$channel instanceof ChannelInterface) { return; } $oldLocales = $this->repository->getDeletedLocalesForChannel($channel); $newLocales = $channel->getLocales(); $updatedLocales = []; foreach ($oldLocales as $locale) { $locale->removeChannel($channel); $updatedLocales[] = $locale; if (null !== $this->completeness) { $this->completeness->scheduleForChannelAndLocale($channel, $locale); } } foreach ($newLocales as $locale) { if (!$locale->hasChannel($channel)) { $locale->addChannel($channel); $updatedLocales[] = $locale; } } if (!empty($updatedLocales)) { $this->saver->saveAll($updatedLocales); } }