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());
 }
示例#2
0
 /**
  * @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));
 }
示例#3
0
 /**
  * @param MediaInfoStorageItem $mediaItem
  * @param string               $filePath
  * @param string               $cmsCacheFilePath
  *
  * @return bool
  */
 protected function isCmsCacheFileValid(MediaInfoStorageItem $mediaItem, $filePath, $cmsCacheFilePath)
 {
     $orgFileTime = @\filemtime($filePath);
     $cacheFileTime = @\filemtime($cmsCacheFilePath);
     $cacheFileSize = @\filesize($cmsCacheFilePath);
     if (empty($orgFileTime) || empty($cacheFileTime) || empty($cacheFileSize)) {
         return false;
     }
     if ($orgFileTime >= $cacheFileTime) {
         return false;
     }
     if ($mediaItem->getLastModified() >= $cacheFileTime) {
         return false;
     }
     return true;
 }
示例#4
0
 protected function validateRequest(MediaRequest $mediaRequest, MediaInfoStorageItem $mediaItem)
 {
     $requestDate = $mediaRequest->getDate();
     if (!empty($requestDate) && $requestDate != $mediaItem->getLastModified()) {
         throw new OldMediaRequest();
     }
     $filePath = $mediaItem->getFilePath();
     if (!is_file($filePath) || !is_readable($filePath)) {
         throw new MediaItemFileNotExists();
     }
 }