3 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15 * This software consists of voluntary contributions made by many individuals
16 * and is licensed under the MIT license. For more information, see
17 * <http://www.doctrine-project.org>.
20 namespace Doctrine\ORM\Tools\Export;
22 use Doctrine\ORM\Tools\Export\ExportException,
23 Doctrine\ORM\EntityManager;
26 * Class used for converting your mapping information between the
27 * supported formats: yaml, xml, and php/annotation.
30 * @link www.doctrine-project.org
32 * @author Jonathan Wage <jonwage@gmail.com>
34 class ClassMetadataExporter
36 private static $_exporterDrivers = array(
37 'xml' => 'Doctrine\ORM\Tools\Export\Driver\XmlExporter',
38 'yaml' => 'Doctrine\ORM\Tools\Export\Driver\YamlExporter',
39 'yml' => 'Doctrine\ORM\Tools\Export\Driver\YamlExporter',
40 'php' => 'Doctrine\ORM\Tools\Export\Driver\PhpExporter',
41 'annotation' => 'Doctrine\ORM\Tools\Export\Driver\AnnotationExporter'
45 * Register a new exporter driver class under a specified name
48 * @param string $class
50 public static function registerExportDriver($name, $class)
52 self::$_exporterDrivers[$name] = $class;
56 * Get a exporter driver instance
58 * @param string $type The type to get (yml, xml, etc.)
59 * @param string $source The directory where the exporter will export to
60 * @return AbstractExporter $exporter
62 public function getExporter($type, $dest = null)
64 if ( ! isset(self::$_exporterDrivers[$type])) {
65 throw ExportException::invalidExporterDriverType($type);
68 $class = self::$_exporterDrivers[$type];
70 return new $class($dest);