2009-10-05 08:29:26 +04:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* This software consists of voluntary contributions made by many individuals
|
2012-05-26 16:37:00 +04:00
|
|
|
* and is licensed under the MIT license. For more information, see
|
2009-10-05 08:29:26 +04:00
|
|
|
* <http://www.doctrine-project.org>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Doctrine\ORM\Tools\Export;
|
|
|
|
|
2010-04-14 18:31:50 +04:00
|
|
|
use Doctrine\ORM\Tools\Export\ExportException,
|
2010-03-19 07:19:15 +03:00
|
|
|
Doctrine\ORM\EntityManager;
|
2009-10-05 08:29:26 +04:00
|
|
|
|
|
|
|
/**
|
2010-03-05 19:35:00 +03:00
|
|
|
* Class used for converting your mapping information between the
|
2009-10-05 08:29:26 +04:00
|
|
|
* supported formats: yaml, xml, and php/annotation.
|
|
|
|
*
|
2012-05-26 16:37:00 +04:00
|
|
|
*
|
2009-10-05 08:29:26 +04:00
|
|
|
* @link www.doctrine-project.org
|
|
|
|
* @since 2.0
|
|
|
|
* @author Jonathan Wage <jonwage@gmail.com>
|
|
|
|
*/
|
|
|
|
class ClassMetadataExporter
|
|
|
|
{
|
2010-03-19 07:19:15 +03:00
|
|
|
private static $_exporterDrivers = array(
|
2009-10-05 08:29:26 +04:00
|
|
|
'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'
|
|
|
|
);
|
|
|
|
|
2009-10-07 02:38:34 +04:00
|
|
|
/**
|
2010-03-19 07:19:15 +03:00
|
|
|
* Register a new exporter driver class under a specified name
|
2009-10-07 02:38:34 +04:00
|
|
|
*
|
2010-03-19 07:19:15 +03:00
|
|
|
* @param string $name
|
|
|
|
* @param string $class
|
|
|
|
*/
|
|
|
|
public static function registerExportDriver($name, $class)
|
|
|
|
{
|
|
|
|
self::$_exporterDrivers[$name] = $class;
|
|
|
|
}
|
|
|
|
|
2009-10-07 02:38:34 +04:00
|
|
|
/**
|
2010-03-19 07:19:15 +03:00
|
|
|
* Get a exporter driver instance
|
2009-10-07 02:38:34 +04:00
|
|
|
*
|
2010-03-19 07:19:15 +03:00
|
|
|
* @param string $type The type to get (yml, xml, etc.)
|
|
|
|
* @param string $source The directory where the exporter will export to
|
|
|
|
* @return AbstractExporter $exporter
|
2009-10-07 02:38:34 +04:00
|
|
|
*/
|
2010-04-14 22:18:10 +04:00
|
|
|
public function getExporter($type, $dest = null)
|
2009-10-06 02:09:29 +04:00
|
|
|
{
|
2010-03-19 07:19:15 +03:00
|
|
|
if ( ! isset(self::$_exporterDrivers[$type])) {
|
|
|
|
throw ExportException::invalidExporterDriverType($type);
|
2009-10-06 02:09:29 +04:00
|
|
|
}
|
2010-02-26 04:28:09 +03:00
|
|
|
|
2010-03-19 07:19:15 +03:00
|
|
|
$class = self::$_exporterDrivers[$type];
|
2010-03-05 19:35:00 +03:00
|
|
|
|
2010-04-14 18:31:50 +04:00
|
|
|
return new $class($dest);
|
2009-10-05 08:29:26 +04:00
|
|
|
}
|
2012-05-26 16:37:00 +04:00
|
|
|
}
|