Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
FileEmptyException example
UploadedFile
$file
,
string
$sourceEntity
,
string
$delimiter
= ';',
string
$enclosure
= '"',
string
$escape
= '\\'
)
: MappingCollection
{
if
(
$this
->fileService->
detectType
(
$file
)
!== 'text/csv'
)
{
throw
new
UnexpectedFileTypeException
(
$file
->
getClientMimeType
(
)
, 'text/csv'
)
;
}
if
(
$file
->
getSize
(
)
< 1
)
{
throw
new
FileEmptyException
(
$file
->
getFilename
(
)
)
;
}
$filePath
=
$file
->
getRealPath
(
)
;
if
(
!
$filePath
)
{
throw
new
\
RuntimeException
(
'File does not exists'
)
;
}
$fileHandle
=
fopen
(
$filePath
, 'rb'
)
;
if
(
!
$fileHandle
)
{
throw
new
FileNotReadableException
(
$filePath
)
;
}