/** * @param object $entity The entity * @param bool $new Is new */ private function saveMedia($entity, $new = false) { if (!$entity instanceof Media) { return; } $this->mediaManager->saveMedia($entity, $new); }
/** * @covers Kunstmaan\MediaBundle\Helper\MediaManager::saveMedia */ public function testUpdateMediaWithCustomHandler() { $media = new Media(); $handler = $this->getCustomHandler($media); $handler->expects($this->once())->method('updateMedia')->with($this->equalTo($media)); $this->object->addHandler($handler); $this->object->saveMedia($media); }
/** * @param object $entity The entity * @param bool $new Is new */ private function saveMedia($entity, $new = false) { if (!$entity instanceof Media) { return; } $this->mediaManager->saveMedia($entity, $new); $url = $entity->getUrl(); $handler = $this->mediaManager->getHandler($entity); if (isset($this->fileUrlMap[$url]) && $handler instanceof FileHandler) { $handler->fileSystem->rename(preg_replace('~^' . preg_quote($handler->mediaPath, '~') . '~', '/', $this->fileUrlMap[$url]), preg_replace('~^' . preg_quote($handler->mediaPath, '~') . '~', '/', $url)); unset($this->fileUrlMap[$url]); } }