/** * @param Event $event * @param $mediaData * @param $locale * @return bool * @throws EventDependencyNotFoundException * @throws \Sulu\Bundle\MediaBundle\Media\Exception\MediaNotFoundException */ protected function addMedia(Event $event, $mediaData, $locale) { $media = $this->mediaManager->getById($mediaData, $locale); if (!$media) { throw new EventDependencyNotFoundException(MediaManager::ENTITY_NAME_MEDIA, $mediaData); } $media = $media->getEntity(); $event->addMedia($media); $this->entityManager->persist($media); return true; }