From 177adbdfc74581dcb297a2f902580b400916358f Mon Sep 17 00:00:00 2001 From: holtkamp Date: Thu, 22 Dec 2011 09:38:55 -0200 Subject: [PATCH] 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. --- .../Tools/Export/Driver/AbstractExporter.php | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php index 14f654130..41ec6fdf6 100644 --- a/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php +++ b/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php @@ -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); } }