1
0
mirror of synced 2025-01-29 19:41:45 +03:00

Allow ExporterDrivers that implement the exportClassMetadata() function to return FALSE when no content is available/needs to be written to a file by the AbstractExporter, preventing empty files to be generated foreach processed ClassMetadataInfo instance.

This commit is contained in:
holtkamp 2011-12-22 09:38:55 -02:00 committed by Benjamin Eberlei
parent bd49aa5d2c
commit 21cfe4ba9f

View File

@ -111,16 +111,18 @@ abstract class AbstractExporter
}
foreach ($this->_metadata as $metadata) {
$output = $this->exportClassMetadata($metadata);
$path = $this->_generateOutputPath($metadata);
$dir = dirname($path);
if ( ! is_dir($dir)) {
mkdir($dir, 0777, true);
//In case output is returned, write it to a file, skip otherwise
if($output = $this->exportClassMetadata($metadata)){
$path = $this->_generateOutputPath($metadata);
$dir = dirname($path);
if ( ! is_dir($dir)) {
mkdir($dir, 0777, true);
}
if (file_exists($path) && !$this->_overwriteExistingFiles) {
throw ExportException::attemptOverwriteExistingFile($path);
}
file_put_contents($path, $output);
}
if (file_exists($path) && !$this->_overwriteExistingFiles) {
throw ExportException::attemptOverwriteExistingFile($path);
}
file_put_contents($path, $output);
}
}