public function accepts($sFileName, $sMimeType = null) { $aName = explode('.', $sFileName); $sExtension = null; if (count($aName) > 1) { $sExtension = array_pop($aName); } $sFileName = implode('.', $aName); $oDocumentType = null; if ($sMimeType !== null) { $oDocumentType = DocumentTypeQuery::findDocumentTypeByMimetype($sMimeType); } if ($oDocumentType === null && $sExtension !== null) { $oDocumentType = DocumentTypeQuery::findDocumentTypeByExtension($sExtension); } if ($oDocumentType === null) { if ($sExtension === null) { throw new LocalizedException("wns.file_upload.unknown_document_type", null, 'error'); } if ($sMimeType == null) { throw new LocalizedException("wns.file_upload.unknown_mimetype", null, 'error'); } throw new LocalizedException("wns.file_upload.document_type_not_found", array('extension' => $sExtension, 'mimetype' => $sMimeType)); } return $oDocumentType->getId(); }
/** * @deprecated use DocumentTypeQuery::findDocumentTypeByExtension() */ public static function getDocumentTypeByExtension($sExtension = null) { return DocumentTypeQuery::findDocumentTypeByExtension($sExtension); }