. */ namespace Doctrine\ORM\Tools\Export; use Doctrine\ORM\Tools\Export\ExportException; /** * Class used for converting your mapping information between the * supported formats: yaml, xml, and php/annotation. * * @link www.doctrine-project.org * @since 2.0 * @author Jonathan Wage */ class ClassMetadataExporter { /** * @var array */ private static $_exporterDrivers = array( 'xml' => 'Doctrine\ORM\Tools\Export\Driver\XmlExporter', 'yaml' => 'Doctrine\ORM\Tools\Export\Driver\YamlExporter', 'yml' => 'Doctrine\ORM\Tools\Export\Driver\YamlExporter', 'php' => 'Doctrine\ORM\Tools\Export\Driver\PhpExporter', 'annotation' => 'Doctrine\ORM\Tools\Export\Driver\AnnotationExporter' ); /** * Registers a new exporter driver class under a specified name. * * @param string $name * @param string $class * * @return void */ public static function registerExportDriver($name, $class) { self::$_exporterDrivers[$name] = $class; } /** * Gets an exporter driver instance. * * @param string $type The type to get (yml, xml, etc.). * @param string|null $dest The directory where the exporter will export to. * * @return Driver\AbstractExporter * * @throws ExportException */ public function getExporter($type, $dest = null) { if ( ! isset(self::$_exporterDrivers[$type])) { throw ExportException::invalidExporterDriverType($type); } $class = self::$_exporterDrivers[$type]; return new $class($dest); } }