1
0
mirror of synced 2024-12-13 06:46:03 +03:00

Moved Doctrine_Migration_Builder and Doctrine_Import_Builder to Doctrine_Builder_Migration and Doctrine_Builder_Record. Updated code to work with new class names.

This commit is contained in:
jwage 2008-01-23 16:47:58 +00:00
parent 04d945a194
commit 8cc89beb41
11 changed files with 131 additions and 102 deletions

View File

@ -974,7 +974,7 @@ final class Doctrine
*/ */
public static function generateMigrationClass($className, $migrationsPath) public static function generateMigrationClass($className, $migrationsPath)
{ {
$builder = new Doctrine_Migration_Builder($migrationsPath); $builder = new Doctrine_Builder_Migration($migrationsPath);
return $builder->generateMigrationClass($className); return $builder->generateMigrationClass($className);
} }
@ -988,7 +988,7 @@ final class Doctrine
*/ */
public static function generateMigrationsFromDb($migrationsPath) public static function generateMigrationsFromDb($migrationsPath)
{ {
$builder = new Doctrine_Migration_Builder($migrationsPath); $builder = new Doctrine_Builder_Migration($migrationsPath);
return $builder->generateMigrationsFromDb(); return $builder->generateMigrationsFromDb();
} }
@ -1002,7 +1002,7 @@ final class Doctrine
*/ */
public static function generateMigrationsFromModels($migrationsPath, $modelsPath = null) public static function generateMigrationsFromModels($migrationsPath, $modelsPath = null)
{ {
$builder = new Doctrine_Migration_Builder($migrationsPath); $builder = new Doctrine_Builder_Migration($migrationsPath);
return $builder->generateMigrationsFromModels($modelsPath); return $builder->generateMigrationsFromModels($modelsPath);
} }

View File

@ -1,44 +1,37 @@
<?php <?php
/* /*
* $Id$ * $Id: Builder.php 3570 2008-01-22 22:52:53Z jwage $
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* This software consists of voluntary contributions made by many individuals * This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see * and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>. * <http://www.phpdoctrine.org>.
*/ */
Doctrine::autoload('Doctrine_Import_Builder');
/** /**
* @package Doctrine * Doctrine_Builder
* @url http://www.phpdoctrine.org *
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @package Doctrine
* @author Jukka Hassinen <Jukka.Hassinen@BrainAlliance.com> * @subpackage Builder
* @version $Id$ * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
*/ * @link www.phpdoctrine.com
* @since 1.0
/** * @version $Revision: 3570 $
* class Doctrine_Import_Builder_BaseClass * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* Builds a Doctrine_Record base class definition based on a schema. * @author Jonathan H. Wage <jonwage@gmail.com>
* */
* @package Doctrine abstract class Doctrine_Builder
* @subpackage Import {
* @link www.phpdoctrine.com
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Import_Builder_BaseClass extends Doctrine_Import_Builder
{
} }

View File

@ -1,42 +1,45 @@
<?php <?php
/* /*
* $Id$ * $Id: Exception.php 3570 2008-01-22 22:52:53Z jwage $
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* This software consists of voluntary contributions made by many individuals * This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see * and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>. * <http://www.phpdoctrine.org>.
*/ */
Doctrine::autoload('Doctrine_Import_Exception'); Doctrine::autoload('Doctrine_Exception');
/** /**
* @package Doctrine * @package Doctrine
* @subpackage Import * @subpackage Import
* @url http://www.phpdoctrine.org * @url http://www.phpdoctrine.org
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @author Jukka Hassinen <Jukka.Hassinen@BrainAlliance.com> * @author Jukka Hassinen <Jukka.Hassinen@BrainAlliance.com>
* @version $Id$ * @version $Id: Exception.php 3570 2008-01-22 22:52:53Z jwage $
*/ */
/** /**
* class Doctrine_Import_Builder_Exception * Doctrine_Builder_Exception
* @package Doctrine *
* @subpackage Import * @package Doctrine
* @link www.phpdoctrine.com * @subpackage Builder
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.phpdoctrine.com
* @since 1.0 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version $Revision$ * @since 1.0
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @version $Revision: 3570 $
*/ * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
class Doctrine_Import_Builder_Exception extends Doctrine_Import_Exception * @author Jonathan H. Wage <jonwage@gmail.com>
{ } */
class Doctrine_Builder_Exception extends Doctrine_Exception
{
}

View File

@ -23,7 +23,7 @@
* Doctrine_Migration_Builder * Doctrine_Migration_Builder
* *
* @package Doctrine * @package Doctrine
* @subpackage Migration * @subpackage Builder
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Jonathan H. Wage <jwage@mac.com> * @author Jonathan H. Wage <jwage@mac.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
@ -31,7 +31,7 @@
* @since 1.0 * @since 1.0
* @version $Revision: 2939 $ * @version $Revision: 2939 $
*/ */
class Doctrine_Migration_Builder class Doctrine_Builder_Migration extends Doctrine_Builder
{ {
/** /**
* migrationsPath * migrationsPath

View File

@ -26,7 +26,7 @@
* based on a database schema. * based on a database schema.
* *
* @package Doctrine * @package Doctrine
* @subpackage Import * @subpackage Builder
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @since 1.0 * @since 1.0
@ -36,7 +36,7 @@
* @author Nicolas Bérard-Nault <nicobn@php.net> * @author Nicolas Bérard-Nault <nicobn@php.net>
* @author Jonathan H. Wage <jwage@mac.com> * @author Jonathan H. Wage <jwage@mac.com>
*/ */
class Doctrine_Import_Builder class Doctrine_Builder_Record
{ {
/** /**
* Path * Path
@ -625,7 +625,7 @@ END;
public function buildDefinition(array $definition) public function buildDefinition(array $definition)
{ {
if ( ! isset($definition['className'])) { if ( ! isset($definition['className'])) {
throw new Doctrine_Import_Builder_Exception('Missing class name.'); throw new Doctrine_Builder_Exception('Missing class name.');
} }
$abstract = isset($definition['abstract']) && $definition['abstract'] === true ? 'abstract ':null; $abstract = isset($definition['abstract']) && $definition['abstract'] === true ? 'abstract ':null;
@ -667,7 +667,7 @@ END;
public function buildRecord(array $definition) public function buildRecord(array $definition)
{ {
if ( !isset($definition['className'])) { if ( !isset($definition['className'])) {
throw new Doctrine_Import_Builder_Exception('Missing class name.'); throw new Doctrine_Builder_Exception('Missing class name.');
} }
if ($this->generateBaseClasses()) { if ($this->generateBaseClasses()) {
@ -802,7 +802,7 @@ END;
} }
if (isset($bytes) && $bytes === false) { if (isset($bytes) && $bytes === false) {
throw new Doctrine_Import_Builder_Exception("Couldn't write file " . $writePath); throw new Doctrine_Builder_Exception("Couldn't write file " . $writePath);
} }
} }
} }

View File

@ -207,7 +207,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
continue; continue;
} }
$builder = new Doctrine_Import_Builder(); $builder = new Doctrine_Builder_Record();
$builder->setTargetPath($directory); $builder->setTargetPath($directory);
$builder->setOptions($options); $builder->setOptions($options);

View File

@ -146,7 +146,7 @@ class Doctrine_Import_Schema
*/ */
public function importSchema($schema, $format = 'yml', $directory = null, $models = array()) public function importSchema($schema, $format = 'yml', $directory = null, $models = array())
{ {
$builder = new Doctrine_Import_Builder(); $builder = new Doctrine_Builder_Record();
$builder->setTargetPath($directory); $builder->setTargetPath($directory);
$builder->setOptions($this->getOptions()); $builder->setOptions($this->getOptions());

View File

@ -22,15 +22,13 @@
/** /**
* Doctrine_Migration * Doctrine_Migration
* *
* this class represents a database view
*
* @package Doctrine * @package Doctrine
* @subpackage Migration * @subpackage Migration
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @since 1.0
* @version $Revision: 1080 $ * @version $Revision: 1080 $
* @author Jonathan H. Wage <jwage@mac.com> * @author Jonathan H. Wage <jonwage@gmail.com>
*/ */
class Doctrine_Migration class Doctrine_Migration
{ {

View File

@ -0,0 +1,35 @@
<?php
/*
* $Id: Diff.php 1080 2007-02-10 18:17:08Z jwage $
*
* 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
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
/**
* Doctrine_Migration_Diff
*
* @package Doctrine
* @subpackage Migration
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision: 1080 $
* @author Jonathan H. Wage <jonwage@gmail.com>
*/
class Doctrine_Migration_Diff
{
}

View File

@ -266,7 +266,7 @@ abstract class Doctrine_Record_Generator extends Doctrine_Record_Abstract
{ {
$options['className'] = $this->_options['className']; $options['className'] = $this->_options['className'];
$builder = new Doctrine_Import_Builder(); $builder = new Doctrine_Builder_Record();
if ($this->_options['generateFiles']) { if ($this->_options['generateFiles']) {
if (isset($this->_options['generatePath']) && $this->_options['generatePath']) { if (isset($this->_options['generatePath']) && $this->_options['generatePath']) {

View File

@ -36,7 +36,7 @@ class Doctrine_Import_Builder_TestCase extends Doctrine_UnitTestCase
{ {
$table = $this->conn->getTable('Phonenumber'); $table = $this->conn->getTable('Phonenumber');
$builder = new Doctrine_Import_Builder(); $builder = new Doctrine_Builder_Record();
$rel = $builder->buildRelationDefinition($table->getRelations()); $rel = $builder->buildRelationDefinition($table->getRelations());