/** * Invalidate cache on $mediaId * * @param MediaInterface $media */ protected function invalidate($media) { $tags = array($this->tagManager->formatMediaIdTag($media->getId())); $nodeUsage = $media->getUseReferences(NodeInterface::ENTITY_TYPE); foreach ($nodeUsage as $nodeId) { $tags[] = $this->tagManager->formatNodeIdTag($nodeId); } $contentUsage = $media->getUseReferences(ContentInterface::ENTITY_TYPE); foreach ($contentUsage as $contentId) { $tags[] = $this->tagManager->formatContentIdTag($contentId); } $contentTypeUsage = $media->getUseReferences(ContentTypeInterface::ENTITY_TYPE); foreach ($contentTypeUsage as $contentTypeId) { $tags[] = $this->tagManager->formatContentTypeTag($contentTypeId); } $this->cacheableManager->invalidateTags($tags); }
/** * @param MediaInterface $mixed * * @return FacadeInterface */ public function transform($mixed) { $facade = $this->newFacade(); $facade->id = $mixed->getId(); $facade->name = $mixed->getName(); $facade->mimeType = $mixed->getMimeType(); $mediaFolder = $mixed->getMediaFolder(); $facade->isDeletable = !$mixed->isUsed() && $this->authorizationChecker->isGranted(TreeFolderPanelStrategy::ROLE_ACCESS_DELETE_MEDIA, $mediaFolder); $facade->alt = $this->multiLanguageChoiceManager->choose($mixed->getAlts()); $facade->title = $this->multiLanguageChoiceManager->choose($mixed->getTitles()); $facade->original = $this->generateMediaUrl($mixed->getFilesystemName()); $facade->thumbnail = $this->generateMediaUrl($mixed->getThumbnail()); if ($this->hasGroup(MediaAdminGroupContext::MEDIA_ALTERNATIVES)) { $alternatives = $mixed->getAlternatives(); foreach ($alternatives as $format => $alternativeName) { $facade->addAlternative($format, $this->generateMediaUrl($alternativeName)); $facade->addLink('_self_format_' . $format, $this->generateRoute('open_orchestra_media_admin_media_override', array('format' => $format, 'mediaId' => $mixed->getId()))); } } $facade->isEditable = false; if ($this->authorizationChecker->isGranted(TreeFolderPanelStrategy::ROLE_ACCESS_UPDATE_MEDIA, $mediaFolder)) { $facade->isEditable = true; } $facade->addLink('_self_select', $mixed->getId()); $facade->addLink('_api_full', $this->generateRoute('open_orchestra_api_media_show', array('mediaId' => $mixed->getId()))); if ($this->hasGroup(MediaAdminGroupContext::MEDIA_ADVANCED_LINKS)) { $facade->addLink('_self_select_format', $this->generateRoute('open_orchestra_media_admin_media_select_format', array('mediaId' => $mixed->getId()))); if ($facade->isEditable) { $facade->addLink('_self_crop', $this->generateRoute('open_orchestra_media_admin_media_crop', array('mediaId' => $mixed->getId()))); $facade->addLink('_self_meta', $this->generateRoute('open_orchestra_media_admin_media_meta', array('mediaId' => $mixed->getId()))); } } if ($facade->isDeletable) { $facade->addLink('_self_delete', $this->generateRoute('open_orchestra_api_media_delete', array('mediaId' => $mixed->getId()))); } return $facade; }
/** * @param MediaInterface $media * * @param MediaInterface $media * @param string $format * @param string $style * * @return string */ public function displayMediaForWysiwyg(MediaInterface $media, $format = '', $style = '') { return $this->render('OpenOrchestraMediaBundle:BBcode/WysiwygDisplay:audio.html.twig', array('media_id' => $media->getId(), 'style' => $style)); }
/** * @param MediaInterface $media * * @param MediaInterface $media * @param string $format * * @return string */ public function displayMediaForWysiwyg(MediaInterface $media, $format = '') { return $this->render('OpenOrchestraMediaBundle:BBcode/WysiwygDisplay:thumbnail.html.twig', array('media_url' => $this->getFileUrl($media->getThumbnail()), 'media_alt' => $media->getAlt($this->request->getLocale()), 'media_id' => $media->getId())); }