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

[2.0] Some small cleanups.

This commit is contained in:
romanb 2009-12-21 11:06:27 +00:00
parent eff87be568
commit 60b9fb7c5b
7 changed files with 54 additions and 55 deletions

View File

@ -4,6 +4,16 @@
# Upgrade from 2.0-ALPHA3 to 2.0-ALPHA4
## CLI Controller changes
CLI main object changed its name and namespace. Renamed from Doctrine\ORM\Tools\Cli to Doctrine\ORM\Tools\Cli\CliController.
Doctrine\ORM\Tools\Cli\CliController methods addTasks and addTask are now fluent.
## CLI Tasks documentation
Tasks have implemented a new way to build documentation. Although it is still possible to define the help manually by extending the basicHelp and extendedHelp, they are now optional.
With new required method AbstractTask::buildDocumentation, its implementation defines the TaskDocumentation instance (accessible through AbstractTask::getDocumentation()), basicHelp and extendedHelp are now not necessary to be implemented.
## Changes in Method Signatures
* A bunch of Methods on both Doctrine\DBAL\Platforms\AbstractPlatform and Doctrine\DBAL\Schema\AbstractSchemaManager
@ -14,14 +24,17 @@
* Doctrine\ORM\AbstractQuery::setExpireResultCache() -> expireResultCache()
* Doctrine\ORM\Query::setExpireQueryCache() -> expireQueryCache()
## WARNING: Change in SchemaTool behaviour
## SchemaTool Changes
* "doctrine schema-tool --drop" now always drops the complete database instead of
only those tables defined by the current database model. The previous method had
problems when foreign keys of orphaned tables pointed to tables that were schedulded
for deletion.
* Use "doctrine schema-tool --update" to get a save incremental update for your
database schema without deleting any unused tables, sequences or foreign keys.
* Use "doctrine schema-tool --complete-update" to do a full incremental update of
your schema.
* "doctrine schema-tool --drop" now always drops the complete database instead of only those tables defined by the
current database model. The previous method had problems when foreign keys of orphaned tables pointed to
tables that were schedulded for deletion.
* Use "doctrine schema-tool --update" to get a save incremental update for your database schema without
deleting any unused tables, sequences or foreign keys.
* Use "doctrine schema-tool --complete-update" to do a full incremental update of your schema.
# Upgrade from 2.0-ALPHA2 to 2.0-ALPHA3
@ -59,14 +72,3 @@ The new behavior is as if the option were set to FALSE all the time, basically d
* Doctrine\ORM\Configuration#getCacheDir() to getProxyDir()
* Doctrine\ORM\Configuration#setCacheDir($dir) to setProxyDir($dir)
# Upgrade from 2.0-ALPHA3 to 2.0-ALPHA4
## CLI Controller changes
CLI main object changed its name and namespace. Renamed from Doctrine\ORM\Tools\Cli to Doctrine\ORM\Tools\Cli\CliController.
Doctrine\ORM\Tools\Cli\CliController methods addTasks and addTask are now fluent.
## CLI Tasks documentation
Tasks have implemented a new way to build documentation. Although it is still possible to define the help manually by extending the basicHelp and extendedHelp, they are now optional.
With new required method AbstractTask::buildDocumentation, its implementation defines the TaskDocumentation instance (accessible through AbstractTask::getDocumentation()), basicHelp and extendedHelp are now not necessary to be implemented.

View File

@ -2,7 +2,7 @@
require 'Doctrine/Common/ClassLoader.php';
$classLoader = new \Doctrine\Common\ClassLoader();
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine');
$classLoader->register();
$cli = new \Doctrine\ORM\Tools\Cli\CliController();

View File

@ -394,4 +394,5 @@ abstract class AssociationMapping
$platform->quoteIdentifier($this->joinTable['name']) :
$this->joinTable['name'];
}
}

View File

@ -41,7 +41,7 @@ use Doctrine\Common\DoctrineException;
* @author Jonathan H. Wage <jonwage@gmail.com>
* @since 2.0
*/
final class ClassMetadata extends ClassMetadataInfo
class ClassMetadata extends ClassMetadataInfo
{
/**
* The ReflectionClass instance of the mapped class.
@ -319,32 +319,31 @@ final class ClassMetadata extends ClassMetadataInfo
public function __sleep()
{
return array(
'associationMappings',
'associationMappings', // unserialization bottleneck with many assocs
'changeTrackingPolicy',
'columnNames',
'columnNames', //TODO: Not really needed. Can use fieldMappings[$fieldName]['columnName']
'customRepositoryClassName',
'discriminatorColumn',
'discriminatorValue',
'discriminatorMap',
'fieldMappings',
'fieldNames',
'fieldNames', //TODO: Not all of this stuff needs to be serialized. Only type, columnName and fieldName.
'generatorType',
'identifier',
'idGenerator',
'idGenerator', //TODO: Does not really need to be serialized. Could be moved to runtime.
'inheritanceType',
'inheritedAssociationFields',
//'insertSql',
'inverseMappings', //TODO: Remove!
'isIdentifierComposite',
'isMappedSuperclass',
'isVersioned',
'lifecycleCallbacks',
'name',
'namespace',
//'namespace',
'parentClasses',
'primaryTable',
'rootEntityName',
'sequenceGeneratorDefinition',
//'sequenceGeneratorDefinition',
'subClasses',
'versionField'
);

View File

@ -124,6 +124,7 @@ class ClassMetadataInfo
* The namespace the entity class is contained in.
*
* @var string
* @todo Not really needed. Usage could be localized.
*/
public $namespace;
@ -229,12 +230,8 @@ class ClassMetadataInfo
* - <b>scale</b> (integer, optional, schema-only)
* The scale of a decimal column. Only valid if the column type is decimal.
*
* - <b>index (string, optional, schema-only)</b>
* Whether an index should be generated for the column.
* The value specifies the name of the index. To create a multi-column index,
* just use the same name for several mappings.
*
* - <b>foreignKey (string, optional, schema-only)</b>
* - <b>unique (string, optional, schema-only)</b>
* Whether a unique constraint should be generated for the column.
*
* @var array
*/
@ -255,6 +252,7 @@ class ClassMetadataInfo
* This is the reverse lookup map of $_fieldNames.
*
* @var array
* @todo We could get rid of this array by just using $fieldMappings[$fieldName]['columnName'].
*/
public $columnNames = array();
@ -369,13 +367,6 @@ class ClassMetadataInfo
*/
public $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT;
/**
* The SQL INSERT string for entities of this class.
*
* @var string
*/
//public $insertSql;
/**
* A map of field names to class names, where the field names are association
* fields that have been inherited from another class and values are the names

View File

@ -26,13 +26,6 @@ use Doctrine\Common\DoctrineException,
Doctrine\Common\Cli\OptionGroup,
Doctrine\ORM\Tools\Export\ClassMetadataExporter;
if ( ! class_exists('sfYaml', false)) {
require_once __DIR__ . '/../../../../../vendor/sfYaml/sfYaml.class.php';
require_once __DIR__ . '/../../../../../vendor/sfYaml/sfYamlDumper.class.php';
require_once __DIR__ . '/../../../../../vendor/sfYaml/sfYamlInline.class.php';
require_once __DIR__ . '/../../../../../vendor/sfYaml/sfYamlParser.class.php';
}
/**
* CLI Task to convert your mapping information between the various formats
*
@ -166,6 +159,13 @@ class ConvertMappingTask extends AbstractTask
private function _isDoctrine1Schema(array $from)
{
if ( ! class_exists('sfYaml', false)) {
require_once __DIR__ . '/../../../../../vendor/sfYaml/sfYaml.class.php';
require_once __DIR__ . '/../../../../../vendor/sfYaml/sfYamlDumper.class.php';
require_once __DIR__ . '/../../../../../vendor/sfYaml/sfYamlInline.class.php';
require_once __DIR__ . '/../../../../../vendor/sfYaml/sfYamlParser.class.php';
}
$files = glob(current($from) . '/*.yml');
if ($files) {
$array = \sfYaml::load($files[0]);

View File

@ -235,7 +235,6 @@ class UnitOfWork implements PropertyChangedListener
{
$this->_em = $em;
$this->_evm = $em->getEventManager();
$this->_commitOrderCalculator = new Internal\CommitOrderCalculator();
$this->_useCExtension = $this->_em->getConfiguration()->getUseCExtension();
}
@ -818,14 +817,16 @@ class UnitOfWork implements PropertyChangedListener
);
}
$calc = $this->getCommitOrderCalculator();
// See if there are any new classes in the changeset, that are not in the
// commit order graph yet (dont have a node).
$newNodes = array();
foreach ($entityChangeSet as $oid => $entity) {
$className = get_class($entity);
if ( ! $this->_commitOrderCalculator->hasClass($className)) {
if ( ! $calc->hasClass($className)) {
$class = $this->_em->getClassMetadata($className);
$this->_commitOrderCalculator->addClass($class);
$calc->addClass($class);
$newNodes[] = $class;
}
}
@ -835,15 +836,15 @@ class UnitOfWork implements PropertyChangedListener
foreach ($class->associationMappings as $assoc) {
if ($assoc->isOwningSide && $assoc->isOneToOne()) {
$targetClass = $this->_em->getClassMetadata($assoc->targetEntityName);
if ( ! $this->_commitOrderCalculator->hasClass($targetClass->name)) {
$this->_commitOrderCalculator->addClass($targetClass);
if ( ! $calc->hasClass($targetClass->name)) {
$calc->addClass($targetClass);
}
$this->_commitOrderCalculator->addDependency($targetClass, $class);
$calc->addDependency($targetClass, $class);
}
}
}
return $this->_commitOrderCalculator->getCommitOrder();
return $calc->getCommitOrder();
}
/**
@ -1637,6 +1638,9 @@ class UnitOfWork implements PropertyChangedListener
*/
public function getCommitOrderCalculator()
{
if ($this->_commitOrderCalculator === null) {
$this->_commitOrderCalculator = new Internal\CommitOrderCalculator;
}
return $this->_commitOrderCalculator;
}
@ -1658,7 +1662,9 @@ class UnitOfWork implements PropertyChangedListener
$this->_collectionUpdates =
$this->_extraUpdates =
$this->_orphanRemovals = array();
$this->_commitOrderCalculator->clear();
if ($this->_commitOrderCalculator !== null) {
$this->_commitOrderCalculator->clear();
}
}
/**