|
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 function trigger_error; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Class used for converting your mapping information between the |
|
26
|
|
|
* supported formats: yaml, xml, and php/annotation. |
|
27
|
|
|
* |
|
28
|
|
|
* @link www.doctrine-project.org |
|
29
|
|
|
* @since 2.0 |
|
30
|
|
|
* @author Jonathan Wage <[email protected]> |
|
31
|
|
|
* |
|
32
|
|
|
* @deprecated 3.0 This class is being removed from the ORM and won't have any replacement |
|
33
|
|
|
*/ |
|
34
|
|
|
class ClassMetadataExporter |
|
35
|
|
|
{ |
|
36
|
|
|
/** |
|
37
|
|
|
* @var array |
|
38
|
|
|
*/ |
|
39
|
|
|
private static $_exporterDrivers = [ |
|
40
|
|
|
'xml' => Driver\XmlExporter::class, |
|
41
|
|
|
'yaml' => Driver\YamlExporter::class, |
|
42
|
|
|
'yml' => Driver\YamlExporter::class, |
|
43
|
|
|
'php' => Driver\PhpExporter::class, |
|
44
|
|
|
'annotation' => Driver\AnnotationExporter::class |
|
45
|
|
|
]; |
|
46
|
|
|
|
|
47
|
6 |
|
public function __construct() |
|
48
|
|
|
{ |
|
49
|
6 |
|
@trigger_error(self::class . ' is deprecated and will be removed in Doctrine 3.0', E_USER_DEPRECATED); |
|
50
|
6 |
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Registers a new exporter driver class under a specified name. |
|
54
|
|
|
* |
|
55
|
|
|
* @param string $name |
|
56
|
|
|
* @param string $class |
|
57
|
|
|
* |
|
58
|
|
|
* @return void |
|
59
|
|
|
*/ |
|
60
|
|
|
public static function registerExportDriver($name, $class) |
|
61
|
|
|
{ |
|
62
|
|
|
self::$_exporterDrivers[$name] = $class; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Gets an exporter driver instance. |
|
67
|
|
|
* |
|
68
|
|
|
* @param string $type The type to get (yml, xml, etc.). |
|
69
|
|
|
* @param string|null $dest The directory where the exporter will export to. |
|
70
|
|
|
* |
|
71
|
|
|
* @return Driver\AbstractExporter |
|
72
|
|
|
* |
|
73
|
|
|
* @throws ExportException |
|
74
|
|
|
*/ |
|
75
|
6 |
|
public function getExporter($type, $dest = null) |
|
76
|
|
|
{ |
|
77
|
6 |
|
if ( ! isset(self::$_exporterDrivers[$type])) { |
|
78
|
|
|
throw ExportException::invalidExporterDriverType($type); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
6 |
|
$class = self::$_exporterDrivers[$type]; |
|
82
|
|
|
|
|
83
|
6 |
|
return new $class($dest); |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|