Example #1
0
 /**
  * @param MediaInterface|null $interface
  * @param File                $file
  * @param string              $thumb
  * @return bool
  */
 protected function createNewImageRecord(MediaInterface $interface = null, File $file, $thumb = '')
 {
     if (null === $interface) {
         return false;
     }
     if (false == ($row = $interface->find(['hash' => $file->getHash()]))) {
         return $interface->insert([$interface->getFieldOriginalName() => $file->getOriginalName(), $interface->getFieldSaveName() => $file->getFilename(), $interface->getFieldSavePath() => str_replace(DIRECTORY_SEPARATOR, '/', $file->getRelativePath()), $interface->getFieldThumbnilPath() => $thumb, $interface->getFieldHash() => $file->getHash(), $interface->getFieldSize() => $file->getSize(), $interface->getFieldExt() => $file->getExtension()]);
     }
     return $row['id'];
 }