# Source for file Schema.php

Documentation is available at Schema.php

1. <?php
2. /*
3. * $Id: Schema.php 1838 2007-06-26 00:58:21Z nicobn $
4. *
5. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
9. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
13. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16. *
17. * This software consists of voluntary contributions made by many individuals
18. * and is licensed under the LGPL. For more information, see
19. * <http://www.phpdoctrine.com>.
20. */
22. /**
23. * class Doctrine_Export_Schema
24. *
25. * Different methods to import a XML schema. The logic behind using two different
26. * methods is simple. Some people will like the idea of producing Doctrine_Record
27. * objects directly, which is totally fine. But in fast and growing application,
28. * table definitions tend to be a little bit more volatile. importArr() can be used
29. * to output a table definition in a PHP file. This file can then be stored
30. * independantly from the object itself.
31. *
32. * @package Doctrine
33. * @category Object Relational Mapping
34. * @link www.phpdoctrine.com
35. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
36. * @version $Revision: 1838 $
37. * @author Nicolas Bérard-Nault <nicobn@gmail.com>
38. */
39. abstract class Doctrine_Export_Schema
40. {
41. /**
42. * build
43. *
44. * Build the schema string to be dumped to file
45. *
46. * @param string $array
47. * @return void
48. */
49. abstract function build($array);
51. /**
52. * dump
53. *
54. * Dump the array to the schema file
55. *
56. * @param string $array
57. * @param string $schema
58. * @return void
59. */
60. abstract function dump($array, $schema);
62. /**
63. * buildSchema
64. *
65. * Build schema array that can be dumped to file
66. *
67. * @param string $directory
68. * @return void
69. */
70. public function buildSchema($directory)
71. {
72. // we need to figure out how we can build all the model information for the passed directory/directories
73. return array();
74. }
76. /**
77. * exportSchema
78. *
79. * @param string $schema
80. * @param string $directory
81. * @return void
82. */
83. public function exportSchema($schema, $directory)
84. {
85. $array = $this->buildSchema($directory);
87. $this->dump($arr, $schema);
88. }
89. }