Ejemplo n.º 1
0
 /**
  * Set the current file adapter object
  *
  * @param mixed $fileAdapter
  * @param string $filePath
  *
  * @return $this
  */
 public function setFileAdapter($fileAdapter, $filePath = null)
 {
     $adapterFactory = new MediaModelFileAdapter();
     $this->fileAdapter = $adapterFactory->getFileAdapter($fileAdapter);
     $this->fileAdapter->setFilePath($filePath);
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Return a file type object
  *
  * @param string $filePath
  * @param MediaModelFileAdapterInterface $fileAdapter
  *
  * @return mixed|false
  */
 public function getFileType($filePath, $fileAdapter)
 {
     // Loop through the available file types and match this file accordingly
     foreach ($this->getAvailableFileTypes() as $availableFileType) {
         /** @var MediaModelFileTypeInterface $mimeType */
         // Detect the MIME-type
         $mimeType = $fileAdapter->setFilePath($filePath)->getMimeType();
         if (in_array($mimeType, $availableFileType->getMimeTypes())) {
             return $availableFileType;
         }
         /** @var $availableFileType MediaModelFileTypeAbstract */
         if (in_array(JFile::getExt($filePath), $availableFileType->getExtensions())) {
             return $availableFileType;
         }
     }
     return false;
 }