Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / lib / Doctrine / ORM / Tools / Export / ClassMetadataExporter.php
1 <?php
2 /*
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.
14  *
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>.
18  */
19
20 namespace Doctrine\ORM\Tools\Export;
21
22 use Doctrine\ORM\Tools\Export\ExportException,
23     Doctrine\ORM\EntityManager;
24
25 /**
26  * Class used for converting your mapping information between the
27  * supported formats: yaml, xml, and php/annotation.
28  *
29  * 
30  * @link    www.doctrine-project.org
31  * @since   2.0
32  * @author  Jonathan Wage <jonwage@gmail.com>
33  */
34 class ClassMetadataExporter
35 {
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'
42     );
43
44     /**
45      * Register a new exporter driver class under a specified name
46      *
47      * @param string $name
48      * @param string $class
49      */
50     public static function registerExportDriver($name, $class)
51     {
52         self::$_exporterDrivers[$name] = $class;
53     }
54
55     /**
56      * Get a exporter driver instance
57      *
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
61      */
62     public function getExporter($type, $dest = null)
63     {
64         if ( ! isset(self::$_exporterDrivers[$type])) {
65             throw ExportException::invalidExporterDriverType($type);
66         }
67
68         $class = self::$_exporterDrivers[$type];
69
70         return new $class($dest);
71     }
72 }