private function getFileBack($fileType, $allMiraklFiles, $frontFile, $shopId, $tmpFilePath)
    {

        try {
            $backType = $this->getFileBackType($fileType);

            // this file type has no backs
            if (!$backType) {
                return null;
            }

            $files = array_filter(
                $allMiraklFiles,
                function ($aFile) use ($backType) {
                    return $aFile['type'] == $backType;
                }
            );

            // No back has been found in Mirakl files
            if (empty($files)) {
                return null;
            }

            $file = end($files);
            // check if extension of file is correct
            $this->checkExtensionFile($file['file_name'], $file, $shopId);
            // save file
            $tmpFile = $tmpFilePath . '/' . time() . preg_replace("/[^A-Za-z0-9\.]/", '', $file['file_name']);
            file_put_contents($tmpFile, $this->mirakl->downloadDocuments(array($file['id'])));

            return array('filePath' => $tmpFile, 'fileObject' => $file);

        } catch (Exception $e) {
            throw new Exception(
                'Document ' .
                $frontFile['id'] .
                ' (type: ' .
                $fileType .
                ') for Mirakl for shop ' .
                $shopId .
                ' will not be uploaded because file of type ' .
                $backType .
                ' not uploaded in Mirakl or uploaded with wrong extension'
            );
        }
    }
private function getFileBack($fileType, $allMiraklFiles, $frontFile, $shopId, $tmpFilePath)
    {

        try {
            $backType = $this->getFileBackType($fileType);

            // this file type has no backs
            if (!$backType) {
                return null;
            }

            $files = array_filter(
                $allMiraklFiles,
                function ($aFile) use ($backType) {
                    return $aFile['type'] == $backType;
                }
            );

            // No back has been found in Mirakl files
            if (empty($files)) {
                return null;
            }

            $file = end($files);
            // check if extension of file is correct
            $this->checkExtensionFile($file['file_name'], $file, $shopId);
            // save file
            $tmpFile = $tmpFilePath . '/' . time() . preg_replace("/[^A-Za-z0-9\.]/", '', $file['file_name']);
            file_put_contents($tmpFile, $this->mirakl->downloadDocuments(array($file['id'])));

            return array('filePath' => $tmpFile, 'fileObject' => $file);

        } catch (Exception $e) {
            throw new Exception(
                'Document ' .
                $frontFile['id'] .
                ' (type: ' .
                $fileType .
                ') for Mirakl for shop ' .
                $shopId .
                ' will not be uploaded because file of type ' .
                $backType .
                ' not uploaded in Mirakl or uploaded with wrong extension'
            );
        }
    }
private function getFileBack ( $ fileType , $ allMiraklFiles , $ frontFile , $ shopId , $ tmpFilePath ) { try { $ backType = $ this -> getFileBackType ( $ fileType ) ; // this file type has no backs if ( ! $ backType ) { return null ; } $ files = array_filter ( $ allMiraklFiles , function ( $ aFile ) use ( $ backType ) { return $ aFile [ 'type' ] == $ backType ; } ) ; // No back has been found in Mirakl files if ( empty ( $ files ) ) { return null ; } $ file = end ( $ files ) ; // check if extension of file is correct $ this -> checkExtensionFile ( $ file [ 'file_name' ] , $ file , $ shopId ) ; // save file $ tmpFile = $ tmpFilePath . '/' . time ( ) . preg_replace ( "/[^A-Za-z0-9\.]/" , '' , $ file [ 'file_name' ] ) ; file_put_contents ( $ tmpFile , $ this -> mirakl -> downloadDocuments ( array ( $ file [ 'id' ] ) ) ) ; return array ( 'filePath' => $ tmpFile , 'fileObject' => $ file ) ; } catch ( Exception $ e ) { throw new Exception ( 'Document ' . $ frontFile [ 'id' ] . ' (type: ' . $ fileType . ') for Mirakl for shop ' . $ shopId . ' will not be uploaded because file of type ' . $ backType . ' not uploaded in Mirakl or uploaded with wrong extension' ) ; } }
get file corresponding to the back of a file type

@param $fileType
@param $allMiraklFiles
@param $frontFile
@param $shopId
@return array|null
@throws Exception
get file corresponding to the back of a file type