/** * @param MediaInfoStorageItem $mediaItem * @param array $operations * * @return string */ public function getPreviewUrl(MediaInfoStorageItem $mediaItem, array $operations = array()) { $ops = array(); foreach ($operations as $op) { $ops[] = join('_', $op); } $operationSting = join('/', $ops); $return = $this->prefix . "/" . $mediaItem->getId() . '/' . $mediaItem->getName() . '/' . $operationSting; $this->calls[] = array('method' => 'getPreviewUrl', 'params' => array($mediaItem->getId(), $operations), 'return' => $return); return $return; }
protected function validateMediaInfoStorageItem(array $itemArray, MediaInfoStorageItem $infoStorageItem) { $this->assertEquals($itemArray['id'], $infoStorageItem->getId()); $this->assertEquals($itemArray['name'], $infoStorageItem->getName()); $this->assertEquals($itemArray['size'], $infoStorageItem->getSize()); $this->assertEquals($itemArray['filePath'], $infoStorageItem->getFilePath()); $this->assertEquals($itemArray['lastModified'], $infoStorageItem->getLastModified()); }
/** * @param MediaInfoStorageItem $mediaItem * @param string $cdnType * @param array $operations * * @return string */ protected function createRequestParameterValue(MediaInfoStorageItem $mediaItem, $cdnType, array $operations = array()) { $params = array('id' => $mediaItem->getId(), 'websiteid' => $mediaItem->getWebsiteId(), 'type' => $cdnType, 'date' => $mediaItem->getLastModified()); if (!empty($operations)) { $params['chain'] = $this->convertOperationsToChainString($operations); } return urlencode(\json_encode($params)); }
/** * @return array */ protected function createTestDataForMovedResponse() { $websiteId = $this->websiteId; $mediaId = 'MEDIA-00000000-0000-0000-0000-000000000001-MEDIA'; $uploadData = time() - 3600; $mediaItem = new MediaInfoStorageItem($mediaId, FS::joinPath($this->getMediaFileDirectory($websiteId), 'logo.jpg'), 'logo.jpg', time(), 10, time(), FS::joinPath($this->getMediaFileDirectory($websiteId), '/icon_jpg.png'), $websiteId); $infoStorageMock = $this->createMediaItemInfoStorageMock(array($mediaItem->getId() => $mediaItem)); $mediaContext = $this->createMediaContext($infoStorageMock); $httpRequestMock = $this->createHttpRequestMock(); $mediaRequest = new MediaRequest($mediaId, MediaRequest::TYPE_STREAM, $uploadData - 1); return array($mediaContext, $httpRequestMock, $mediaRequest, '\\Render\\MediaCDNHelper\\MediaResponse\\MovedResponse'); }
/** * @param MediaInfoStorageItem $mediaItem * @param MediaRequest $mediaRequest * * @return string */ private function uniqueKey(MediaInfoStorageItem $mediaItem, MediaRequest $mediaRequest) { return md5(json_encode(array('id' => $mediaItem->getId(), 'type' => $mediaRequest->getCdnType(), 'operations' => $mediaRequest->getOperations()))); }
/** * @param MediaInfoStorageItem $mediaItem * * @return array */ protected function getMediaInfo($mediaItem) { return array('id' => $mediaItem->getId(), 'file' => basename($mediaItem->getFilePath()), 'name' => $mediaItem->getName(), 'size' => $mediaItem->getSize(), 'lastModified' => $mediaItem->getLastModified()); }
/** * @param MediaInfoStorageItem $mediaItem * @param $useIcon * * @return string */ private function getBaseFilenameForCache(MediaInfoStorageItem $mediaItem, $useIcon) { if ($useIcon) { return basename($mediaItem->getIconFilePath()); } else { $extension = $this->getExtensionFromFilename(basename($mediaItem->getFilePath())); return $mediaItem->getId() . '.' . $extension; } }
/** * @param MediaInfoStorageItem $mediaItem * @param $filename * @param array $operations * * @param string $cdnType * * @return string */ protected function createImageUrl(MediaInfoStorageItem $mediaItem, $filename, array $operations, $cdnType) { $call = array('id' => $mediaItem->getId(), 'type' => $cdnType, 'operations' => $operations); $this->addMediaCall($call); return parent::createImageUrl($mediaItem, $filename, $operations, $cdnType); }