NFePHP\Common\Files\FilesFolders::getFilePath PHP Метод

getFilePath() публичный статический Метод

getFilePath
public static getFilePath ( string $tpAmb = '2', string $dirbase = '', string $subdir = '' ) : string
$tpAmb string
$dirbase string
$subdir string
Результат string
    public static function getFilePath($tpAmb = '2', $dirbase = '', $subdir = '')
    {
        $path = $dirbase . DIRECTORY_SEPARATOR . self::getAmbiente($tpAmb) . DIRECTORY_SEPARATOR . $subdir;
        if (!is_dir($path)) {
            if (!mkdir($path, 0777, true)) {
                throw new Exception\RuntimeException("Não foi possivel criar o diretorio {$folder}. Verifique as permissões");
            }
        }
        return $path;
    }

Usage Example

Пример #1
0
 /**
  * zGravaFile
  * Grava os dados no diretorio das NFe
  * @param string $tpAmb ambiente
  * @param string $filename nome do arquivo
  * @param string $data dados a serem salvos
  * @param string $subFolder 
  * @param string $anomes 
  * @throws Exception\RuntimeException
  */
 protected function zGravaFile($tipo = '', $tpAmb = '2', $filename = '', $data = '', $subFolder = 'temporarias', $anomes = '')
 {
     if ($anomes == '') {
         $anomes = date('Ym');
     }
     $path = '';
     if ($tipo == 'nfe') {
         $path = $this->aConfig['pathNFeFiles'];
     } elseif ($tipo == 'cte') {
         $path = $this->aConfig['pathCTeFiles'];
     } elseif ($tipo == 'mdfe') {
         $path = $this->aConfig['pathMDFeFiles'];
     }
     $pathTemp = Files\FilesFolders::getFilePath($tpAmb, $path, $subFolder) . DIRECTORY_SEPARATOR . $anomes;
     if (!Files\FilesFolders::saveFile($pathTemp, $filename, $data)) {
         $msg = 'Falha na gravação no diretório. ' . $pathTemp;
         throw new Exception\RuntimeException($msg);
     }
 }