Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[2.0] Code cleanups. Preparations for DDC-193. Fixed DDC-399, type co…

…nfiguration remains global for now but the irritating instance methods on the Configuration have been removed. Use Type::addType et al. Added TODOs for naming standards.
  • Loading branch information...
commit a53c2fbd6c2df5453c79edf693b5299c0133abf5 1 parent ed94a34
romanb authored
Showing with 498 additions and 903 deletions.
  1. +8 −85 UPGRADE_TO_2_0
  2. +35 −0 UPGRADE_TO_ALPHA3
  3. +36 −0 UPGRADE_TO_ALPHA4
  4. +1 −0  lib/Doctrine/Common/Cache/ApcCache.php
  5. +3 −30 lib/Doctrine/DBAL/Configuration.php
  6. +1 −1  lib/Doctrine/DBAL/Connection.php
  7. +1 −0  lib/Doctrine/DBAL/Logging/EchoSqlLogger.php
  8. +1 −0  lib/Doctrine/DBAL/Logging/SqlLogger.php
  9. +1 −1  lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
  10. +1 −0  lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
  11. +1 −0  lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
  12. +5 −4 lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
  13. +1 −0  lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
  14. +3 −3 lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
  15. +19 −0 lib/Doctrine/DBAL/Types/StringType.php
  16. +22 −7 lib/Doctrine/DBAL/Types/Type.php
  17. +3 −0  lib/Doctrine/ORM/AbstractQuery.php
  18. +98 −11 lib/Doctrine/ORM/Configuration.php
  19. +4 −1 lib/Doctrine/ORM/EntityManager.php
  20. +1 −1  lib/Doctrine/ORM/EntityRepository.php
  21. +1 −1  lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
  22. +5 −5 lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
  23. +68 −141 lib/Doctrine/ORM/Mapping/AssociationMapping.php
  24. +13 −16 lib/Doctrine/ORM/Mapping/ClassMetadata.php
  25. +8 −9 lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
  26. +38 −290 lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
  27. +4 −2 lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
  28. +3 −2 lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php
  29. +8 −34 lib/Doctrine/ORM/Mapping/ManyToManyMapping.php
  30. +10 −14 lib/Doctrine/ORM/Mapping/OneToManyMapping.php
  31. +14 −107 lib/Doctrine/ORM/Mapping/OneToOneMapping.php
  32. +3 −4 lib/Doctrine/ORM/PersistentCollection.php
  33. +4 −4 lib/Doctrine/ORM/Persisters/ManyToManyPersister.php
  34. +3 −4 lib/Doctrine/ORM/Persisters/OneToManyPersister.php
  35. +6 −6 lib/Doctrine/ORM/Persisters/StandardEntityPersister.php
  36. +1 −1  lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php
  37. +2 −4 lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php
  38. +20 −75 lib/Doctrine/ORM/Query/Parser.php
  39. +4 −4 lib/Doctrine/ORM/Query/SqlWalker.php
  40. +2 −2 lib/Doctrine/ORM/Tools/Export/Driver/AnnotationExporter.php
  41. +3 −3 lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php
  42. +3 −3 lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php
  43. +5 −5 lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php
  44. +4 −4 lib/Doctrine/ORM/Tools/SchemaTool.php
  45. +4 −2 lib/Doctrine/ORM/UnitOfWork.php
  46. +2 −2 tests/Doctrine/Tests/DBAL/Schema/TableTest.php
  47. +9 −9 tests/Doctrine/Tests/ORM/Associations/OneToOneMappingTest.php
  48. +2 −2 tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php
  49. +3 −3 tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php
  50. +1 −1  tests/Doctrine/Tests/OrmFunctionalTestCase.php
View
93 UPGRADE_TO_2_0
@@ -1,102 +1,25 @@
-> **NOTE**
-> This document does not describe how to upgrade from Doctrine 1.x to Doctrine 2 as this is a more
-> complicated process.
-# Upgrade from 2.0-ALPHA4 to 2.0 ...
+# Upgrade from 2.0-ALPHA4 to 2.0-BETA1
-## Default Property for Field Mappings removed
+## Default Property for Field Mappings
-The "default" option for database column defaults has been removed. If desired database column defaults can
-be implemented by using the @columnDefinition annotation (or the approriate XML and YAML equivalents).
-
-Additionally keep in mind that Doctrine's focus in on objects and you can specifiy default values for an Entitiy's
-mapped fields inside PHP easily. Upon persist() invocation these values are saved as if they were default values.
+The "default" option for database column defaults has been removed. If desired, database column defaults can
+be implemented by using the columnDefinition attribute of the @Column annotation (or the approriate XML and YAML equivalents).
+Prefer PHP default values, if possible.
## Partial Objects
+xxx
+
## XML Mapping Driver
The 'inheritance-type' attribute changed to take last bit of ClassMetadata constant names, i.e.
NONE, SINGLE_TABLE, INHERITANCE_TYPE_JOINED
-## Change of PreUpdate Event Listener
+## PreUpdate Event Listeners
Event Listeners listening to the 'preUpdate' event can only affect the primitive values of entity changesets
by using the API on the `PreUpdateEventArgs` instance passed to the preUpdate listener method. Any changes
to the state of the entitys properties won't affect the database UPDATE statement anymore. This gives drastic
performance benefits for the preUpdate event.
-# 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\Common\Cli\CliController.
-Doctrine\Common\Cli\CliController now only deals with namespaces. Ready to go, Core, Dbal and Orm are available and you can subscribe new tasks by retrieving the namespace and including new task. Example:
-
- [php]
- $cli->getNamespace('Core')->addTask('my-example', '\MyProject\Tools\Cli\Tasks\MyExampleTask');
-
-
-## 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
- have changed quite significantly by adopting the new Schema instance objects.
-
-## Renamed Methods
-
- * Doctrine\ORM\AbstractQuery::setExpireResultCache() -> expireResultCache()
- * Doctrine\ORM\Query::setExpireQueryCache() -> expireQueryCache()
-
-## 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.
-
-
-# Upgrade from 2.0-ALPHA2 to 2.0-ALPHA3
-
-This section details the changes made to Doctrine 2.0-ALPHA3 to make it easier for you
-to upgrade your projects to use this version.
-
-## CLI Changes
-
-The $args variable used in the cli-config.php for configuring the Doctrine CLI has been renamed to $globalArguments.
-
-## Proxy class changes
-
-You are now required to make supply some minimalist configuration with regards to proxy objects. That involves 2 new configuration options. First, the directory where generated proxy classes should be placed needs to be specified. Secondly, you need to configure the namespace used for proxy classes. The following snippet shows an example:
-
- [php]
- // step 1: configure directory for proxy classes
- // $config instanceof Doctrine\ORM\Configuration
- $config->setProxyDir('/path/to/myproject/lib/MyProject/Generated/Proxies');
- $config->setProxyNamespace('MyProject\Generated\Proxies');
-
-Note that proxy classes behave exactly like any other classes when it comes to class loading. Therefore you need to make sure the proxy classes can be loaded by some class loader. If you place the generated proxy classes in a namespace and directory under your projects class files, like in the example above, it would be sufficient to register the MyProject namespace on a class loader. Since the proxy classes are contained in that namespace and adhere to the standards for class loading, no additional work is required.
-Generating the proxy classes into a namespace within your class library is the recommended setup.
-
-Entities with initialized proxy objects can now be serialized and unserialized properly from within the same application.
-
-For more details refer to the Configuration section of the manual.
-
-## Removed allowPartialObjects configuration option
-
-The allowPartialObjects configuration option together with the `Configuration#getAllowPartialObjects` and `Configuration#setAllowPartialObjects` methods have been removed.
-The new behavior is as if the option were set to FALSE all the time, basically disallowing partial objects globally. However, you can still use the `Query::HINT_FORCE_PARTIAL_LOAD` query hint to force a query to return partial objects for optimization purposes.
-
-## Renamed Methods
-
-* Doctrine\ORM\Configuration#getCacheDir() to getProxyDir()
-* Doctrine\ORM\Configuration#setCacheDir($dir) to setProxyDir($dir)
-
View
35 UPGRADE_TO_ALPHA3
@@ -0,0 +1,35 @@
+# Upgrade from 2.0-ALPHA2 to 2.0-ALPHA3
+
+This section details the changes made to Doctrine 2.0-ALPHA3 to make it easier for you
+to upgrade your projects to use this version.
+
+## CLI Changes
+
+The $args variable used in the cli-config.php for configuring the Doctrine CLI has been renamed to $globalArguments.
+
+## Proxy class changes
+
+You are now required to make supply some minimalist configuration with regards to proxy objects. That involves 2 new configuration options. First, the directory where generated proxy classes should be placed needs to be specified. Secondly, you need to configure the namespace used for proxy classes. The following snippet shows an example:
+
+ [php]
+ // step 1: configure directory for proxy classes
+ // $config instanceof Doctrine\ORM\Configuration
+ $config->setProxyDir('/path/to/myproject/lib/MyProject/Generated/Proxies');
+ $config->setProxyNamespace('MyProject\Generated\Proxies');
+
+Note that proxy classes behave exactly like any other classes when it comes to class loading. Therefore you need to make sure the proxy classes can be loaded by some class loader. If you place the generated proxy classes in a namespace and directory under your projects class files, like in the example above, it would be sufficient to register the MyProject namespace on a class loader. Since the proxy classes are contained in that namespace and adhere to the standards for class loading, no additional work is required.
+Generating the proxy classes into a namespace within your class library is the recommended setup.
+
+Entities with initialized proxy objects can now be serialized and unserialized properly from within the same application.
+
+For more details refer to the Configuration section of the manual.
+
+## Removed allowPartialObjects configuration option
+
+The allowPartialObjects configuration option together with the `Configuration#getAllowPartialObjects` and `Configuration#setAllowPartialObjects` methods have been removed.
+The new behavior is as if the option were set to FALSE all the time, basically disallowing partial objects globally. However, you can still use the `Query::HINT_FORCE_PARTIAL_LOAD` query hint to force a query to return partial objects for optimization purposes.
+
+## Renamed Methods
+
+* Doctrine\ORM\Configuration#getCacheDir() to getProxyDir()
+* Doctrine\ORM\Configuration#setCacheDir($dir) to setProxyDir($dir)
View
36 UPGRADE_TO_ALPHA4
@@ -0,0 +1,36 @@
+# 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\Common\Cli\CliController.
+Doctrine\Common\Cli\CliController now only deals with namespaces. Ready to go, Core, Dbal and Orm are available and you can subscribe new tasks by retrieving the namespace and including new task. Example:
+
+ [php]
+ $cli->getNamespace('Core')->addTask('my-example', '\MyProject\Tools\Cli\Tasks\MyExampleTask');
+
+
+## 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
+ have changed quite significantly by adopting the new Schema instance objects.
+
+## Renamed Methods
+
+ * Doctrine\ORM\AbstractQuery::setExpireResultCache() -> expireResultCache()
+ * Doctrine\ORM\Query::setExpireQueryCache() -> expireQueryCache()
+
+## 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.
View
1  lib/Doctrine/Common/Cache/ApcCache.php
@@ -32,6 +32,7 @@
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author David Abdemoulaie <dave@hobodave.com>
+ * @todo Rename: APCCache
*/
class ApcCache extends AbstractCache
{
View
33 lib/Doctrine/DBAL/Configuration.php
@@ -46,7 +46,7 @@ class Configuration
* @var array
*/
protected $_attributes = array();
-
+
/**
* Creates a new DBAL configuration instance.
*/
@@ -56,7 +56,7 @@ public function __construct()
'sqlLogger' => null
);
}
-
+
/**
* Sets the SQL logger to use. Defaults to NULL which means SQL logging is disabled.
*
@@ -66,7 +66,7 @@ public function setSqlLogger($logger)
{
$this->_attributes['sqlLogger'] = $logger;
}
-
+
/**
* Gets the SQL logger that is used.
*
@@ -76,31 +76,4 @@ public function getSqlLogger()
{
return $this->_attributes['sqlLogger'];
}
-
- /**
- * Defines new custom types to be supported by Doctrine
- *
- * @param array $types Key-value map of types to include
- * @param boolean $override Optional flag to support only inclusion or also override
- */
- public function setCustomTypes(array $types, $override = false)
- {
- foreach ($types as $name => $typeClassName) {
- $method = (Type::hasType($name) && $override ? 'override' : 'add') . 'Type';
-
- Type::$method($name, $typeClassName);
- }
- }
-
- /**
- * Overrides existent types in Doctrine
- *
- * @param array $types Key-value map of types to override
- */
- public function setTypeOverrides(array $overrides)
- {
- foreach ($override as $name => $typeClassName) {
- Type::overrideType($name, $typeClassName);
- }
- }
}
View
2  lib/Doctrine/DBAL/Connection.php
@@ -66,7 +66,7 @@ class Connection
*/
const FETCH_ASSOC = 2;
const FETCH_BOTH = 4;
- const FETCH_COLUMN = 7;
+ //const FETCH_COLUMN = 7; Apparently not used.
const FETCH_NUM = 3;
const ATTR_AUTOCOMMIT = 0;
View
1  lib/Doctrine/DBAL/Logging/EchoSqlLogger.php
@@ -7,6 +7,7 @@
*
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
+ * @todo Rename: EchoSQLLogger
*/
class EchoSqlLogger implements SqlLogger
{
View
1  lib/Doctrine/DBAL/Logging/SqlLogger.php
@@ -7,6 +7,7 @@
*
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
+ * @todo Rename: SQLLogger
*/
interface SqlLogger
{
View
2  lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
@@ -579,7 +579,7 @@ public function getDropForeignKeySQL($foreignKey, $table)
*/
public function getCreateTableSQL(Table $table, $createFlags=self::CREATE_INDEXES)
{
- if (!is_int($createFlags)) {
+ if ( ! is_int($createFlags)) {
throw new \InvalidArgumentException("Second argument of AbstractPlatform::getCreateTableSQL() has to be integer.");
}
View
1  lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
@@ -32,6 +32,7 @@
* @author Roman Borschel <roman@code-factory.org>
* @author Jonathan H. Wage <jonwage@gmail.com>
* @author Benjamin Eberlei <kontakt@beberlei.de>
+ * @todo Rename: MsSQLPlatform
*/
class MsSqlPlatform extends AbstractPlatform
{
View
1  lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
@@ -32,6 +32,7 @@
* @since 2.0
* @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de>
+ * @todo Rename: MySQLPlatform
*/
class MySqlPlatform extends AbstractPlatform
{
View
9 lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
@@ -21,7 +21,8 @@
namespace Doctrine\DBAL\Platforms;
-use Doctrine\DBAL\Schema\TableDiff;
+use Doctrine\DBAL\Schema\TableDiff,
+ Doctrine\DBAL\Schema\Table;
/**
* PostgreSqlPlatform.
@@ -30,6 +31,7 @@
* @author Roman Borschel <roman@code-factory.org>
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
* @author Benjamin Eberlei <kontakt@beberlei.de>
+ * @todo Rename: PostgreSQLPlatform
*/
class PostgreSqlPlatform extends AbstractPlatform
{
@@ -281,7 +283,7 @@ public function getCreateDatabaseSQL($name)
{
return 'CREATE DATABASE ' . $name;
}
-
+
/**
* drop an existing database
*
@@ -293,9 +295,8 @@ public function getDropDatabaseSQL($name)
{
return 'DROP DATABASE ' . $name;
}
-
+
/**
- * getAdvancedForeignKeyOptions
* Return the FOREIGN KEY query section dealing with non-standard options
* as MATCH, INITIALLY DEFERRED, ON UPDATE, ...
*
View
1  lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
@@ -30,6 +30,7 @@
* @since 2.0
* @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de>
+ * @todo Rename: SQLitePlatform
*/
class SqlitePlatform extends AbstractPlatform
{
View
6 lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
@@ -21,9 +21,9 @@
namespace Doctrine\DBAL\Schema;
-use \Doctrine\DBAL\Types;
-use \Doctrine\DBAL\DBALException;
-use \Doctrine\DBAL\Platforms\AbstractPlatform;
+use Doctrine\DBAL\Types;
+use Doctrine\DBAL\DBALException;
+use Doctrine\DBAL\Platforms\AbstractPlatform;
/**
* Base class for schema managers. Schema managers are used to inspect and/or
View
19 lib/Doctrine/DBAL/Types/StringType.php
@@ -1,4 +1,23 @@
<?php
+/*
+ * $Id$
+ *
+ * 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.doctrine-project.org>.
+ */
namespace Doctrine\DBAL\Types;
View
29 lib/Doctrine/DBAL/Types/Type.php
@@ -1,4 +1,23 @@
<?php
+/*
+ * $Id$
+ *
+ * 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.doctrine-project.org>.
+ */
namespace Doctrine\DBAL\Types;
@@ -33,7 +52,6 @@
'object' => 'Doctrine\DBAL\Types\ObjectType',
'boolean' => 'Doctrine\DBAL\Types\BooleanType',
'integer' => 'Doctrine\DBAL\Types\IntegerType',
- 'int' => 'Doctrine\DBAL\Types\IntegerType',
'smallint' => 'Doctrine\DBAL\Types\SmallIntType',
'bigint' => 'Doctrine\DBAL\Types\BigIntType',
'string' => 'Doctrine\DBAL\Types\StringType',
@@ -41,12 +59,11 @@
'datetime' => 'Doctrine\DBAL\Types\DateTimeType',
'date' => 'Doctrine\DBAL\Types\DateType',
'time' => 'Doctrine\DBAL\Types\TimeType',
- 'decimal' => 'Doctrine\DBAL\Types\DecimalType',
- 'double' => 'Doctrine\DBAL\Types\DoubleType'
+ 'decimal' => 'Doctrine\DBAL\Types\DecimalType'
);
/* Prevent instantiation and force use of the factory method. */
- private function __construct() {}
+ final private function __construct() {}
/**
* Converts a value from its PHP representation to its database representation
@@ -125,7 +142,6 @@ public static function getType($name)
if ( ! isset(self::$_typesMap[$name])) {
throw DBALException::unknownColumnType($name);
}
-
self::$_typeObjects[$name] = new self::$_typesMap[$name]();
}
@@ -136,8 +152,7 @@ public static function getType($name)
* Adds a custom type to the type map.
*
* @static
- * @param string $name Name of the type. This should correspond to what
- * getName() returns.
+ * @param string $name Name of the type. This should correspond to what getName() returns.
* @param string $className The class name of the custom type.
* @throws DBALException
*/
View
3  lib/Doctrine/ORM/AbstractQuery.php
@@ -472,6 +472,9 @@ public function execute($params = array(), $hydrationMode = null)
{
// If there are still pending insertions in the UnitOfWork we need to flush
// in order to guarantee a correct result.
+ //TODO: Think this over. Its tricky. Not doing this can lead to strange results
+ // potentially, but doing it could result in endless loops when querying during
+ // a flush, i.e. inside an event listener.
if ($this->_em->getUnitOfWork()->hasPendingInsertions()) {
$this->_em->flush();
}
View
109 lib/Doctrine/ORM/Configuration.php
@@ -38,7 +38,6 @@ class Configuration extends \Doctrine\DBAL\Configuration
public function __construct()
{
parent::__construct();
-
$this->_attributes = array_merge($this->_attributes, array(
'resultCacheImpl' => null,
'queryCacheImpl' => null,
@@ -46,11 +45,8 @@ public function __construct()
'metadataDriverImpl' => null,
'proxyDir' => null,
'useCExtension' => false,
- 'namedQueries' => array(),
- 'namedNativeQueries' => array(),
'autoGenerateProxyClasses' => true,
- 'proxyNamespace' => null,
- 'entityNamespaces' => array()
+ 'proxyNamespace' => null
));
}
@@ -96,11 +92,21 @@ public function setAutoGenerateProxyClasses($bool)
$this->_attributes['autoGenerateProxyClasses'] = $bool;
}
+ /**
+ * Gets the namespace where proxy classes reside.
+ *
+ * @return string
+ */
public function getProxyNamespace()
{
return $this->_attributes['proxyNamespace'];
}
+ /**
+ * Sets the namespace where proxy classes reside.
+ *
+ * @param string $ns
+ */
public function setProxyNamespace($ns)
{
$this->_attributes['proxyNamespace'] = $ns;
@@ -119,7 +125,7 @@ public function setMetadataDriverImpl($driverImpl)
}
/**
- * Add a namespace alias for entities.
+ * Adds a namespace under a certain alias.
*
* @param string $alias
* @param string $namespace
@@ -130,7 +136,7 @@ public function addEntityNamespace($alias, $namespace)
}
/**
- * Get the namespace of a given entity namespace
+ * Resolves a registered namespace alias to the full namespace.
*
* @param string $entityNamespaceAlias
* @return string
@@ -138,11 +144,11 @@ public function addEntityNamespace($alias, $namespace)
*/
public function getEntityNamespace($entityNamespaceAlias)
{
- if (isset($this->_attributes['entityNamespaces'][$entityNamespaceAlias])) {
- return trim($this->_attributes['entityNamespaces'][$entityNamespaceAlias], '\\');
+ if ( ! isset($this->_attributes['entityNamespaces'][$entityNamespaceAlias])) {
+ throw ORMException::unknownEntityNamespace($entityNamespaceAlias);
}
- throw ORMException::unknownEntityNamespace($entityNamespaceAlias);
+ return trim($this->_attributes['entityNamespaces'][$entityNamespaceAlias], '\\');
}
/**
@@ -153,7 +159,7 @@ public function getEntityNamespace($entityNamespaceAlias)
*/
public function setEntityNamespaces(array $entityNamespaces)
{
- $this->_attributes['entityNamespaces'] = $entityNamespaces;
+ $this->_attributes['entityNamespaces'] = $entityNamespaces;
}
/**
@@ -273,6 +279,9 @@ public function addNamedQuery($name, $dql)
*/
public function getNamedQuery($name)
{
+ if ( ! isset($this->_attributes['namedQueries'][$name])) {
+ throw ORMException::namedQueryNotFound($name);
+ }
return $this->_attributes['namedQueries'][$name];
}
@@ -297,6 +306,9 @@ public function addNamedNativeQuery($name, $sql, Query\ResultSetMapping $rsm)
*/
public function getNamedNativeQuery($name)
{
+ if ( ! isset($this->_attributes['namedNativeQueries'][$name])) {
+ throw ORMException::namedNativeQueryNotFound($name);
+ }
return $this->_attributes['namedNativeQueries'][$name];
}
@@ -319,4 +331,79 @@ public function ensureProductionSettings()
throw ORMException::proxyClassesAlwaysRegenerating();
}
}
+
+ /**
+ * Registers a custom DQL function that produces a string value.
+ * Such a function can then be used in any DQL statement in any place where string
+ * functions are allowed.
+ *
+ * @param string $name
+ * @param string $className
+ */
+ public function addCustomStringFunction($name, $className)
+ {
+ $this->_attributes['customStringFunctions'][strtolower($name)] = $className;
+ }
+
+ /**
+ * Gets the implementation class name of a registered custom string DQL function.
+ *
+ * @param string $name
+ * @return string
+ */
+ public function getCustomStringFunction($name)
+ {
+ return isset($this->_attributes['customStringFunctions'][$name]) ?
+ $this->_attributes['customStringFunctions'][$name] : null;
+ }
+
+ /**
+ * Registers a custom DQL function that produces a numeric value.
+ * Such a function can then be used in any DQL statement in any place where numeric
+ * functions are allowed.
+ *
+ * @param string $name
+ * @param string $className
+ */
+ public function addCustomNumericFunction($name, $className)
+ {
+ $this->_attributes['customNumericFunctions'][strtolower($name)] = $className;
+ }
+
+ /**
+ * Gets the implementation class name of a registered custom numeric DQL function.
+ *
+ * @param string $name
+ * @return string
+ */
+ public function getCustomNumericFunction($name)
+ {
+ return isset($this->_attributes['customNumericFunctions'][$name]) ?
+ $this->_attributes['customNumericFunctions'][$name] : null;
+ }
+
+ /**
+ * Registers a custom DQL function that produces a date/time value.
+ * Such a function can then be used in any DQL statement in any place where date/time
+ * functions are allowed.
+ *
+ * @param string $name
+ * @param string $className
+ */
+ public function addCustomDatetimeFunction($name, $className)
+ {
+ $this->_attributes['customDatetimeFunctions'][strtolower($name)] = $className;
+ }
+
+ /**
+ * Gets the implementation class name of a registered custom date/time DQL function.
+ *
+ * @param string $name
+ * @return string
+ */
+ public function getCustomDatetimeFunction($name)
+ {
+ return isset($this->_attributes['customDatetimeFunctions'][$name]) ?
+ $this->_attributes['customDatetimeFunctions'][$name] : null;
+ }
}
View
5 lib/Doctrine/ORM/EntityManager.php
@@ -353,6 +353,9 @@ public function close()
*
* The entity will be entered into the database at or before transaction
* commit or as a result of the flush operation.
+ *
+ * NOTE: The persist operation always considers entities that are not yet known to
+ * this EntityManager as NEW. Do not pass detached entities to the persist operation.
*
* @param object $object The instance to make managed and persistent.
*/
@@ -456,7 +459,7 @@ public function getRepository($entityName)
}
$metadata = $this->getClassMetadata($entityName);
- $customRepositoryClassName = $metadata->getCustomRepositoryClass();
+ $customRepositoryClassName = $metadata->customRepositoryClassName;
if ($customRepositoryClassName !== null) {
$repository = new $customRepositoryClassName($this, $metadata);
View
2  lib/Doctrine/ORM/EntityRepository.php
@@ -57,7 +57,7 @@ class EntityRepository
* @param EntityManager $em The EntityManager to use.
* @param ClassMetadata $classMetadata The class descriptor.
*/
- public function __construct($em, \Doctrine\ORM\Mapping\ClassMetadata $class)
+ public function __construct($em, Mapping\ClassMetadata $class)
{
$this->_entityName = $class->name;
$this->_em = $em;
View
2  lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
@@ -254,7 +254,7 @@ protected function _gatherScalarRowData(&$data, &$cache)
$fieldName = $this->_rsm->fieldMappings[$key];
$classMetadata = $this->_em->getClassMetadata($this->_rsm->declaringClasses[$key]);
$cache[$key]['fieldName'] = $fieldName;
- $cache[$key]['type'] = Type::getType($classMetadata->getTypeOfField($fieldName));
+ $cache[$key]['type'] = Type::getType($classMetadata->fieldMappings[$fieldName]['type']);
$cache[$key]['dqlAlias'] = $this->_rsm->columnOwnerMap[$key];
} else {
// Meta column (has meaning in relational schema only, i.e. foreign keys or discriminator columns).
View
10 lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
@@ -83,8 +83,8 @@ protected function _prepare()
}
if ( ! $assoc->isManyToMany()) {
// Mark any non-collection opposite sides as fetched, too.
- if ($assoc->mappedByFieldName) {
- $this->_hints['fetched'][$className][$assoc->mappedByFieldName] = true;
+ if ($assoc->mappedBy) {
+ $this->_hints['fetched'][$className][$assoc->mappedBy] = true;
} else {
if (isset($class->inverseMappings[$sourceClassName][$assoc->sourceFieldName])) {
$inverseAssoc = $class->inverseMappings[$sourceClassName][$assoc->sourceFieldName];
@@ -353,14 +353,14 @@ protected function _hydrateRow(array &$data, array &$cache, array &$result)
$targetClass->reflFields[$inverseAssoc->sourceFieldName]->setValue($element, $parentObject);
$this->_uow->setOriginalEntityProperty(spl_object_hash($element), $inverseAssoc->sourceFieldName, $parentObject);
}
- } else if ($parentClass === $targetClass && $relation->mappedByFieldName) {
+ } else if ($parentClass === $targetClass && $relation->mappedBy) {
// Special case: bi-directional self-referencing one-one on the same class
$targetClass->reflFields[$relationField]->setValue($element, $parentObject);
}
} else {
// For sure bidirectional, as there is no inverse side in unidirectional mappings
- $targetClass->reflFields[$relation->mappedByFieldName]->setValue($element, $parentObject);
- $this->_uow->setOriginalEntityProperty(spl_object_hash($element), $relation->mappedByFieldName, $parentObject);
+ $targetClass->reflFields[$relation->mappedBy]->setValue($element, $parentObject);
+ $this->_uow->setOriginalEntityProperty(spl_object_hash($element), $relation->mappedBy, $parentObject);
}
// Update result pointer
$this->_resultPointers[$dqlAlias] = $element;
View
209 lib/Doctrine/ORM/Mapping/AssociationMapping.php
@@ -50,69 +50,110 @@
* @var integer
*/
const FETCH_EAGER = 3;
-
+
+ /**
+ * READ-ONLY: Whether the association cascades delete() operations from the source entity
+ * to the target entity/entities.
+ *
+ * @var boolean
+ */
public $isCascadeRemove;
+
+ /**
+ * READ-ONLY: Whether the association cascades save() operations from the source entity
+ * to the target entity/entities.
+ *
+ * @var boolean
+ */
public $isCascadePersist;
+
+ /**
+ * READ-ONLY: Whether the association cascades refresh() operations from the source entity
+ * to the target entity/entities.
+ *
+ * @var boolean
+ */
public $isCascadeRefresh;
+
+ /**
+ * READ-ONLY: Whether the association cascades merge() operations from the source entity
+ * to the target entity/entities.
+ *
+ * @var boolean
+ */
public $isCascadeMerge;
+
+ /**
+ * READ-ONLY: Whether the association cascades detach() operations from the source entity
+ * to the target entity/entities.
+ *
+ * @var boolean
+ */
public $isCascadeDetach;
-
+
/**
- * The fetch mode used for the association.
+ * READ-ONLY: The fetch mode used for the association.
*
* @var integer
*/
public $fetchMode;
-
+
/**
- * Flag that indicates whether the class that defines this mapping is
+ * READ-ONLY: Flag that indicates whether the class that defines this mapping is
* the owning side of the association.
*
* @var boolean
*/
public $isOwningSide = true;
-
+
/**
- * The name of the source Entity (the Entity that defines this mapping).
+ * READ-ONLY: The name of the source Entity (the Entity that defines this mapping).
*
* @var string
*/
public $sourceEntityName;
-
+
/**
- * The name of the target Entity (the Enitity that is the target of the
+ * READ-ONLY: The name of the target Entity (the Enitity that is the target of the
* association).
*
* @var string
*/
public $targetEntityName;
-
+
/**
- * Identifies the field on the source class (the class this AssociationMapping
+ * READ-ONLY: Identifies the field on the source class (the class this AssociationMapping
* belongs to) that represents the association and stores the reference to the
* other entity/entities.
*
* @var string
*/
public $sourceFieldName;
-
+
/**
- * Identifies the field on the owning side that controls the mapping for the
- * association. This is only set on the inverse side of an association.
+ * READ-ONLY: Identifies the field on the owning side of a bidirectional association that
+ * controls the mapping for the association. This is only set on the inverse side
+ * of an association.
*
* @var string
*/
- public $mappedByFieldName;
-
+ public $mappedBy;
+
/**
- * The join table definition, if any.
+ * READ-ONLY: Identifies the field on the inverse side of a bidirectional association.
+ * This is only set on the owning side of an association.
+ *
+ * @var string
+ */
+ public $inversedBy;
+
+ /**
+ * READ-ONLY: The join table definition, if any.
*
* @var array
*/
public $joinTable = array();
- //protected $_joinTableInsertSql;
-
/**
* Initializes a new instance of a class derived from AssociationMapping.
*
@@ -124,7 +165,7 @@ public function __construct(array $mapping)
$this->_validateAndCompleteMapping($mapping);
}
}
-
+
/**
* Validates & completes the mapping. Mapping defaults are applied here.
*
@@ -159,9 +200,12 @@ protected function _validateAndCompleteMapping(array $mapping)
}
$this->joinTable = $mapping['joinTable'];
}
+ if (isset($mapping['inversedBy'])) {
+ $this->inversedBy = $mapping['inversedBy'];
+ }
} else {
$this->isOwningSide = false;
- $this->mappedByFieldName = $mapping['mappedBy'];
+ $this->mappedBy = $mapping['mappedBy'];
}
// Optional attributes for both sides
@@ -184,63 +228,8 @@ protected function _validateAndCompleteMapping(array $mapping)
$this->isCascadeMerge = in_array('merge', $cascades);
$this->isCascadeDetach = in_array('detach', $cascades);
}
-
- /**
- * Whether the association cascades delete() operations from the source entity
- * to the target entity/entities.
- *
- * @return boolean
- */
- public function isCascadeRemove()
- {
- return $this->isCascadeRemove;
- }
-
- /**
- * Whether the association cascades save() operations from the source entity
- * to the target entity/entities.
- *
- * @return boolean
- */
- public function isCascadePersist()
- {
- return $this->isCascadePersist;
- }
-
- /**
- * Whether the association cascades refresh() operations from the source entity
- * to the target entity/entities.
- *
- * @return boolean
- */
- public function isCascadeRefresh()
- {
- return $this->isCascadeRefresh;
- }
/**
- * Whether the association cascades merge() operations from the source entity
- * to the target entity/entities.
- *
- * @return boolean
- */
- public function isCascadeMerge()
- {
- return $this->isCascadeMerge;
- }
-
- /**
- * Whether the association cascades detach() operations from the source entity
- * to the target entity/entities.
- *
- * @return boolean
- */
- public function isCascadeDetach()
- {
- return $this->isCascadeDetach;
- }
-
- /**
* Whether the target entity/entities of the association are eagerly fetched.
*
* @return boolean
@@ -249,7 +238,7 @@ public function isEagerlyFetched()
{
return $this->fetchMode == self::FETCH_EAGER;
}
-
+
/**
* Whether the target entity/entities of the association are lazily fetched.
*
@@ -259,17 +248,7 @@ public function isLazilyFetched()
{
return $this->fetchMode == self::FETCH_LAZY;
}
-
- /**
- * Whether the source entity of this association represents the owning side.
- *
- * @return boolean
- */
- public function isOwningSide()
- {
- return $this->isOwningSide;
- }
-
+
/**
* Whether the source entity of this association represents the inverse side.
*
@@ -279,58 +258,6 @@ public function isInverseSide()
{
return ! $this->isOwningSide;
}
-
- /**
- * Gets the name of the source entity class.
- *
- * @return string
- */
- public function getSourceEntityName()
- {
- return $this->sourceEntityName;
- }
-
- /**
- * Gets the name of the target entity class.
- *
- * @return string
- */
- public function getTargetEntityName()
- {
- return $this->targetEntityName;
- }
-
- /**
- * Gets the join table definition, if any.
- *
- * @return array
- */
- public function getJoinTable()
- {
- return $this->joinTable;
- }
-
- /**
- * Get the name of the field the association is mapped into.
- *
- * @return string
- */
- public function getSourceFieldName()
- {
- return $this->sourceFieldName;
- }
-
- /**
- * Gets the field name of the owning side in a bi-directional association.
- * This is only set on the inverse side. When invoked on the owning side,
- * NULL is returned.
- *
- * @return string
- */
- public function getMappedByFieldName()
- {
- return $this->mappedByFieldName;
- }
/**
* Whether the association is a one-to-one association.
@@ -397,7 +324,7 @@ public function hasCascades()
/**
*
* @param $platform
- * @return unknown_type
+ * @return string
*/
public function getQuotedJoinTableName($platform)
{
View
29 lib/Doctrine/ORM/Mapping/ClassMetadata.php
@@ -208,6 +208,17 @@ public function setFieldValue($entity, $field, $value)
}
/**
+ * Gets the specified field's value off the given entity.
+ *
+ * @param object $entity
+ * @param string $field
+ */
+ public function getFieldValue($entity, $field)
+ {
+ return $this->reflFields[$field]->getValue($entity);
+ }
+
+ /**
* Sets the field mapped to the specified column to the specified value on the given entity.
*
* @param object $entity
@@ -235,21 +246,7 @@ protected function _storeAssociationMapping(AssociationMapping $assocMapping)
$refProp->setAccessible(true);
$this->reflFields[$sourceFieldName] = $refProp;
}
-
- /**
- * Dispatches the lifecycle event of the given entity to the registered
- * lifecycle callbacks and lifecycle listeners.
- *
- * @param string $event The lifecycle event.
- * @param Entity $entity The Entity on which the event occured.
- */
- public function invokeLifecycleCallbacks($lifecycleEvent, $entity)
- {
- foreach ($this->lifecycleCallbacks[$lifecycleEvent] as $callback) {
- $entity->$callback();
- }
- }
-
+
/**
* Gets the (possibly quoted) column name of a mapped field for safe use
* in an SQL statement.
@@ -316,7 +313,7 @@ public function __sleep()
'idGenerator', //TODO: Does not really need to be serialized. Could be moved to runtime.
'inheritanceType',
'inheritedAssociationFields',
- 'inverseMappings', //TODO: Remove!
+ 'inverseMappings', //TODO: Remove! DDC-193
'isIdentifierComposite',
'isMappedSuperclass',
'isVersioned',
View
17 lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
@@ -143,10 +143,8 @@ public function getMetadataFor($className)
}
}
- $cacheKey = "$realClassName\$CLASSMETADATA";
-
if ($this->_cacheDriver) {
- if (($cached = $this->_cacheDriver->fetch($cacheKey)) !== false) {
+ if (($cached = $this->_cacheDriver->fetch("$realClassName\$CLASSMETADATA")) !== false) {
$this->_loadedMetadata[$realClassName] = $cached;
} else {
foreach ($this->_loadMetadata($realClassName) as $loadedClassName) {
@@ -206,8 +204,9 @@ protected function _loadMetadata($name)
}
$loaded = array();
-
+
// Collect parent classes, ignoring transient (not-mapped) classes.
+ //TODO: Evaluate whether we can use class_parents() here.
$parentClass = $name;
$parentClasses = array();
while ($parentClass = get_parent_class($parentClass)) {
@@ -258,15 +257,15 @@ protected function _loadMetadata($name)
}
if ($parent && ! $parent->isMappedSuperclass) {
if ($parent->isIdGeneratorSequence()) {
- $class->setSequenceGeneratorDefinition($parent->getSequenceGeneratorDefinition());
+ $class->setSequenceGeneratorDefinition($parent->sequenceGeneratorDefinition);
} else if ($parent->isIdGeneratorTable()) {
- $class->getTableGeneratorDefinition($parent->getTableGeneratorDefinition());
+ $class->getTableGeneratorDefinition($parent->tableGeneratorDefinition);
}
if ($generatorType = $parent->generatorType) {
$class->setIdGeneratorType($generatorType);
}
- if ($idGenerator = $parent->getIdGenerator()) {
- $class->setIdGenerator($idGenerator);
+ if ($parent->idGenerator) {
+ $class->setIdGenerator($parent->idGenerator);
}
} else {
$this->_completeIdGeneratorMapping($class);
@@ -374,7 +373,7 @@ private function _completeIdGeneratorMapping(ClassMetadata $class)
break;
case ClassMetadata::GENERATOR_TYPE_SEQUENCE:
// If there is no sequence definition yet, create a default definition
- $definition = $class->getSequenceGeneratorDefinition();
+ $definition = $class->sequenceGeneratorDefinition;
if ( ! $definition) {
$sequenceName = $class->getTableName() . '_' . $class->getSingleIdentifierColumnName() . '_seq';
$definition['sequenceName'] = $this->_targetPlatform->fixSchemaElementName($sequenceName);
View
328 lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
@@ -114,12 +114,12 @@ class ClassMetadataInfo
const CHANGETRACKING_NOTIFY = 3;
/**
- * The name of the entity class.
+ * READ-ONLY: The name of the entity class.
*/
public $name;
/**
- * The namespace the entity class is contained in.
+ * READ-ONLY: The namespace the entity class is contained in.
*
* @var string
* @todo Not really needed. Usage could be localized.
@@ -127,7 +127,7 @@ class ClassMetadataInfo
public $namespace;
/**
- * The name of the entity class that is at the root of the entity inheritance
+ * READ-ONLY: The name of the entity class that is at the root of the entity inheritance
* hierarchy. If the entity is not part of an inheritance hierarchy this is the same
* as $_entityName.
*
@@ -144,28 +144,28 @@ class ClassMetadataInfo
public $customRepositoryClassName;
/**
- * Whether this class describes the mapping of a mapped superclass.
+ * READ-ONLY: Whether this class describes the mapping of a mapped superclass.
*
* @var boolean
*/
public $isMappedSuperclass = false;
/**
- * The names of the parent classes (ancestors).
+ * READ-ONLY: The names of the parent classes (ancestors).
*
* @var array
*/
public $parentClasses = array();
/**
- * The names of all subclasses.
+ * READ-ONLY: The names of all subclasses.
*
* @var array
*/
public $subClasses = array();
/**
- * The field names of all fields that are part of the identifier/primary key
+ * READ-ONLY: The field names of all fields that are part of the identifier/primary key
* of the mapped entity class.
*
* @var array
@@ -173,21 +173,21 @@ class ClassMetadataInfo
public $identifier = array();
/**
- * The inheritance mapping type used by the class.
+ * READ-ONLY: The inheritance mapping type used by the class.
*
* @var integer
*/
public $inheritanceType = self::INHERITANCE_TYPE_NONE;
/**
- * The Id generator type used by the class.
+ * READ-ONLY: The Id generator type used by the class.
*
* @var string
*/
public $generatorType = self::GENERATOR_TYPE_NONE;
/**
- * The field mappings of the class.
+ * READ-ONLY: The field mappings of the class.
* Keys are field names and values are mapping definitions.
*
* The mapping definition array has the following values:
@@ -236,7 +236,7 @@ class ClassMetadataInfo
public $fieldMappings = array();
/**
- * An array of field names. Used to look up field names from column names.
+ * READ-ONLY: An array of field names. Used to look up field names from column names.
* Keys are column names and values are field names.
* This is the reverse lookup map of $_columnNames.
*
@@ -245,7 +245,7 @@ class ClassMetadataInfo
public $fieldNames = array();
/**
- * A map of field names to column names. Keys are field names and values column names.
+ * READ-ONLY: A map of field names to column names. Keys are field names and values column names.
* Used to look up column names from field names.
* This is the reverse lookup map of $_fieldNames.
*
@@ -255,7 +255,7 @@ class ClassMetadataInfo
public $columnNames = array();
/**
- * The discriminator value of this class.
+ * READ-ONLY: The discriminator value of this class.
*
* <b>This does only apply to the JOINED and SINGLE_TABLE inheritance mapping strategies
* where a discriminator column is used.</b>
@@ -266,7 +266,7 @@ class ClassMetadataInfo
public $discriminatorValue;
/**
- * The discriminator map of all mapped classes in the hierarchy.
+ * READ-ONLY: The discriminator map of all mapped classes in the hierarchy.
*
* <b>This does only apply to the JOINED and SINGLE_TABLE inheritance mapping strategies
* where a discriminator column is used.</b>
@@ -277,7 +277,7 @@ class ClassMetadataInfo
public $discriminatorMap = array();
/**
- * The definition of the descriminator column used in JOINED and SINGLE_TABLE
+ * READ-ONLY: The definition of the descriminator column used in JOINED and SINGLE_TABLE
* inheritance mappings.
*
* @var array
@@ -285,7 +285,7 @@ class ClassMetadataInfo
public $discriminatorColumn;
/**
- * The primary table definition. The definition is an array with the
+ * READ-ONLY: The primary table definition. The definition is an array with the
* following entries:
*
* name => <tableName>
@@ -298,21 +298,21 @@ class ClassMetadataInfo
public $primaryTable;
/**
- * The registered lifecycle callbacks for entities of this class.
+ * READ-ONLY: The registered lifecycle callbacks for entities of this class.
*
* @var array
*/
public $lifecycleCallbacks = array();
/**
- * The association mappings. All mappings, inverse and owning side.
+ * READ-ONLY: The association mappings. All mappings, inverse and owning side.
*
* @var array
*/
public $associationMappings = array();
/**
- * List of inverse association mappings, indexed by mappedBy field name.
+ * READ-ONLY: List of inverse association mappings, indexed by mappedBy field name.
*
* @var array
* @todo Remove! See http://www.doctrine-project.org/jira/browse/DDC-193
@@ -320,29 +320,38 @@ class ClassMetadataInfo
public $inverseMappings = array();
/**
- * Flag indicating whether the identifier/primary key of the class is composite.
+ * READ-ONLY: Flag indicating whether the identifier/primary key of the class is composite.
*
* @var boolean
*/
public $isIdentifierComposite = false;
/**
- * The ID generator used for generating IDs for this class.
+ * READ-ONLY: The ID generator used for generating IDs for this class.
*
* @var AbstractIdGenerator
*/
public $idGenerator;
/**
- * The definition of the sequence generator of this class. Only used for the
+ * READ-ONLY: The definition of the sequence generator of this class. Only used for the
* SEQUENCE generation strategy.
+ *
+ * The definition has the following structure:
+ * <code>
+ * array(
+ * 'sequenceName' => 'name',
+ * 'allocationSize' => 20,
+ * 'initialValue' => 1
+ * )
+ * </code>
*
* @var array
*/
public $sequenceGeneratorDefinition;
/**
- * The definition of the table generator of this class. Only used for the
+ * READ-ONLY: The definition of the table generator of this class. Only used for the
* TABLE generation strategy.
*
* @var array
@@ -350,14 +359,14 @@ class ClassMetadataInfo
public $tableGeneratorDefinition;
/**
- * The policy used for change-tracking on entities of this class.
+ * READ-ONLY: The policy used for change-tracking on entities of this class.
*
* @var integer
*/
public $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT;
/**
- * A map of field names to class names, where the field names are association
+ * READ-ONLY: 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
* of the classes that define the association.
*
@@ -366,14 +375,15 @@ class ClassMetadataInfo
public $inheritedAssociationFields = array();
/**
- * A flag for whether or not instances of this class are to be versioned with optimistic locking.
+ * READ-ONLY: A flag for whether or not instances of this class are to be versioned
+ * with optimistic locking.
*
* @var boolean $isVersioned
*/
public $isVersioned;
/**
- * The name of the field which is used for versioning in optimistic locking (if any).
+ * READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any).
*
* @var mixed $versionField
*/
@@ -392,16 +402,6 @@ public function __construct($entityName)
}
/**
- * Gets the change tracking policy used by this class.
- *
- * @return integer
- */
- public function getChangeTrackingPolicy()
- {
- return $this->changeTrackingPolicy;
- }
-
- /**
* Sets the change tracking policy used by this class.
*
* @param integer $policy
@@ -442,50 +442,6 @@ public function isChangeTrackingNotify()
}
/**
- * Gets the name of the mapped class.
- *
- * @return string
- */
- public function getClassName()
- {
- return $this->name;
- }
-
- /**
- * Gets the name of the class in the entity hierarchy that owns the field with
- * the given name. The owning class is the one that defines the field.
- *
- * @param string $fieldName
- * @return string
- */
- /*public function getOwningClass($fieldName)
- {
- if ($this->inheritanceType == self::INHERITANCE_TYPE_NONE) {
- return $this->name;
- } else {
- $mapping = $this->getFieldMapping($fieldName);
- return $mapping['inherited'];
- }
- }*/
-
- /**
- * Gets the name of the root class of the mapped entity hierarchy. If the entity described
- * by this ClassMetadata instance is not participating in a hierarchy, this is the same as the
- * name returned by {@link getClassName()}.
- *
- * @return string The name of the root class of the entity hierarchy.
- */
- public function getRootClassName()
- {
- return $this->rootEntityName;
- }
-
- public function setResultColumnNames(array $resultColumnNames)
- {
- $this->resultColumnNames = $resultColumnNames;
- }
-
- /**
* Checks whether a field is part of the identifier/primary key field(s).
*
* @param string $fieldName The field name
@@ -501,17 +457,6 @@ public function isIdentifier($fieldName)
}
/**
- * Checks if the class has a composite identifier.
- *
- * @param string $fieldName The field name
- * @return boolean TRUE if the identifier is composite, FALSE otherwise.
- */
- public function isIdentifierComposite()
- {
- return $this->isIdentifierComposite;
- }
-
- /**
* Check if the field is unique.
*
* @param string $fieldName The field name
@@ -624,18 +569,6 @@ public function getAssociationMappings()
}
/**
- * Gets all association mappings of the class.
- *
- * Alias for getAssociationMappings().
- *
- * @return array
- */
- public function getAssociations()
- {
- return $this->associationMappings;
- }
-
- /**
* Gets the field name for a column name.
* If no field name can be found the column name is returned.
*
@@ -704,17 +637,6 @@ protected function _validateAndCompleteFieldMapping(array &$mapping)
* Gets the identifier (primary key) field names of the class.
*
* @return mixed
- * @deprecated Use getIdentifierFieldNames()
- */
- public function getIdentifier()
- {
- return $this->identifier;
- }
-
- /**
- * Gets the identifier (primary key) field names of the class.
- *
- * @return mixed
*/
public function getIdentifierFieldNames()
{
@@ -771,16 +693,6 @@ public function hasField($fieldName)
}
/**
- * Gets all field mappings.
- *
- * @return array
- */
- public function getFieldMappings()
- {
- return $this->fieldMappings;
- }
-
- /**
* Gets an array containing all the column names.
*
* @return array
@@ -817,26 +729,6 @@ public function getIdentifierColumnNames()
}
/**
- * Returns an array containing all the field names.
- *
- * @return array
- */
- public function getFieldNames()
- {
- return array_values($this->fieldNames);
- }
-
- /**
- * Gets the Id generator type used by the class.
- *
- * @return string
- */
- public function getIdGeneratorType()
- {
- return $this->generatorType;
- }
-
- /**
* Sets the type of Id generator to use for the mapped class.
*/
public function setIdGeneratorType($generatorType)
@@ -980,16 +872,6 @@ public function getTemporaryIdTableName()
}
/**
- * Gets the inheritance mapping type used by the mapped class.
- *
- * @return string
- */
- public function getInheritanceType()
- {
- return $this->inheritanceType;
- }
-
- /**
* Sets the mapped subclasses of this class.
*
* @param array $subclasses The names of all mapped subclasses.
@@ -1006,16 +888,6 @@ public function setSubclasses(array $subclasses)
}
/**
- * Gets the names of all subclasses.
- *
- * @return array The names of all subclasses.
- */
- public function getSubclasses()
- {
- return $this->subClasses;
- }
-
- /**
* Checks whether the class has any persistent subclasses.
*
* @return boolean TRUE if the class has one or more persistent subclasses, FALSE otherwise.
@@ -1026,16 +898,6 @@ public function hasSubclasses()
}
/**
- * Gets the names of all parent classes.
- *
- * @return array The names of all parent classes.
- */
- public function getParentClasses()
- {
- return $this->parentClasses;
- }
-
- /**
* Sets the parent class names.
* Assumes that the class names in the passed array are in the order:
* directParent -> directParentParent -> directParentParentParent ... -> root.
@@ -1119,17 +981,6 @@ public function setPrimaryTable(array $primaryTableDefinition)
}
/**
- * Gets the primary table definition.
- *
- * @see setPrimaryTable()
- * @return array
- */
- public function getPrimaryTable()
- {
- return $this->primaryTable;
- }
-
- /**
* Checks whether the given type identifies an inheritance type.
*
* @param string $type
@@ -1247,7 +1098,7 @@ public function mapOneToOne(array $mapping)
private function _registerMappingIfInverse(AssociationMapping $assoc)
{
if ($assoc->isInverseSide()) {
- $this->inverseMappings[$assoc->targetEntityName][$assoc->mappedByFieldName] = $assoc;
+ $this->inverseMappings[$assoc->targetEntityName][$assoc->mappedBy] = $assoc;
}
}
@@ -1312,17 +1163,6 @@ public function setCustomRepositoryClass($repositoryClassName)
}
/**
- * Gets the name of the custom repository class used for the entity class.
- *
- * @return string|null The name of the custom repository class or NULL if the entity
- * class does not have a custom repository class.
- */
- public function getCustomRepositoryClass()
- {
- return $this->customRepositoryClassName;
- }
-
- /**
* Dispatches the lifecycle event of the given entity to the registered
* lifecycle callbacks and lifecycle listeners.
*
@@ -1403,24 +1243,6 @@ public function setDiscriminatorColumn($columnDef)
}
/**
- * Gets the discriminator column definition.
- *
- * The discriminator column definition is an array with the following keys:
- * name: The name of the column
- * type: The type of the column (only integer and string supported)
- * length: The length of the column (applies only if type is string)
- *
- * A discriminator column is used for JOINED and SINGLE_TABLE inheritance mappings.
- *
- * @return array
- * @see setDiscriminatorColumn()
- */
- public function getDiscriminatorColumn()
- {
- return $this->discriminatorColumn;
- }
-
- /**
* Sets the discriminator values used by this class.
* Used for JOINED and SINGLE_TABLE inheritance mapping strategies.
*
@@ -1447,17 +1269,6 @@ public function setDiscriminatorMap(array $map)
}
/**
- * Gets the discriminator value of this class.
- * Used for JOINED and SINGLE_TABLE inheritance mapping strategies.
- *
- * @return array
- */
- public function getDiscriminatorValue()
- {
- return $this->discriminatorValue;
- }
-
- /**
* Checks whether the given column name is the discriminator column.
*
* @param string $columnName
@@ -1506,18 +1317,6 @@ public function isCollectionValuedAssociation($fieldName)
}
/**
- * Gets the name of the ID generator used for this class.
- * Only classes that use a SEQUENCE or TABLE ID generation strategy have a generator name.
- *
- * @return string|null The name of the ID generator or NULL if this class does not
- * use a named ID generator.
- */
- /*public function getIdGeneratorName()
- {
- return $this->idGeneratorName;
- }*/
-
- /**
* Sets the ID generator used to generate IDs for instances of this class.
*
* @param AbstractIdGenerator $generator
@@ -1528,36 +1327,6 @@ public function setIdGenerator($generator)
}
/**
- * Gets the ID generator used to generate IDs for instances of this class.
- *
- * @return AbstractIdGenerator
- */
- public function getIdGenerator()
- {
- return $this->idGenerator;
- }
-
- /**
- * Gets the definition of the sequence ID generator for this class.
- *
- * The definition has the following structure:
- * <code>
- * array(
- * 'sequenceName' => 'name',
- * 'allocationSize' => 20,
- * 'initialValue' => 1
- * )
- * </code>
- *
- * @return array|null An array with the generator definition or NULL if this class
- * has no sequence generator definition.
- */
- public function getSequenceGeneratorDefinition()
- {
- return $this->sequenceGeneratorDefinition;
- }
-
- /**
* Sets the definition of the sequence ID generator for this class.
*
* The definition must have the following structure:
@@ -1599,16 +1368,6 @@ public function setVersionMapping(array &$mapping)
}
/**
- * Checks whether this class is versioned for optimistic locking.
- *
- * @return boolean TRUE if this class is versioned for optimistic locking, FALSE otherwise.
- */
- public function isVersioned()
- {
- return $this->isVersioned;
- }
-
- /**
* Sets whether this class is to be versioned for optimistic locking.
*
* @param boolean $bool
@@ -1619,17 +1378,6 @@ public function setVersioned($bool)
}
/**
- * Gets the name of the field that is used for versioning if this class is versioned
- * for optimistic locking.
- *
- * @return string
- */
- public function getVersionField()
- {
- return $this->versionField;
- }
-
- /**
* Sets the name of the field that is to be used for versioning if this class is
* versioned for optimistic locking.
*
View
6 lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
@@ -78,7 +78,6 @@ class AnnotationDriver implements Driver
public function __construct(AnnotationReader $reader, $paths = null)
{
$this->_reader = $reader;
-
if ($paths) {
$this->addPaths((array) $paths);
}
@@ -292,6 +291,7 @@ public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
$mapping['targetEntity'] = $oneToOneAnnot->targetEntity;
$mapping['joinColumns'] = $joinColumns;
$mapping['mappedBy'] = $oneToOneAnnot->mappedBy;
+ $mapping['inversedBy'] = $oneToOneAnnot->inversedBy;
$mapping['cascade'] = $oneToOneAnnot->cascade;
$mapping['orphanRemoval'] = $oneToOneAnnot->orphanRemoval;
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . $oneToOneAnnot->fetch);
@@ -311,6 +311,7 @@ public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
} else if ($manyToOneAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\ManyToOne')) {
$mapping['joinColumns'] = $joinColumns;
$mapping['cascade'] = $manyToOneAnnot->cascade;
+ $mapping['inversedBy'] = $manyToOneAnnot->inversedBy;
$mapping['targetEntity'] = $manyToOneAnnot->targetEntity;
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . $manyToOneAnnot->fetch);
$metadata->mapManyToOne($mapping);
@@ -351,6 +352,7 @@ public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
$mapping['joinTable'] = $joinTable;
$mapping['targetEntity'] = $manyToManyAnnot->targetEntity;
$mapping['mappedBy'] = $manyToManyAnnot->mappedBy;
+ $mapping['inversedBy'] = $manyToManyAnnot->inversedBy;
$mapping['cascade'] = $manyToManyAnnot->cascade;
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . $manyToManyAnnot->fetch);
@@ -362,7 +364,7 @@ public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
}
}
- // Evaluate HasLifecycleCallbacks annotation
+ // Evaluate @HasLifecycleCallbacks annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\HasLifecycleCallbacks'])) {
foreach ($class->getMethods() as $method) {
if ($method->isPublic()) {
View
5 lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php
@@ -70,9 +70,9 @@
final class OneToOne extends Annotation {
public $targetEntity;
public $mappedBy;
+ public $inversedBy;
public $cascade;
public $fetch = 'LAZY';
- public $optional;
public $orphanRemoval = false;
}
final class OneToMany extends Annotation {
@@ -86,11 +86,12 @@
public $targetEntity;
public $cascade;
public $fetch = 'LAZY';
- public $optional;
+ public $inversedBy;
}
final class ManyToMany extends Annotation {
public $targetEntity;
public $mappedBy;
+ public $inversedBy;
public $cascade;
public $fetch = 'LAZY';
}
View
42 lib/Doctrine/ORM/Mapping/ManyToManyMapping.php
@@ -28,7 +28,7 @@
* <b>IMPORTANT NOTE:</b>
*
* The fields of this class are only public for 2 reasons:
- * 1) To allow fast, internal READ access.
+ * 1) To allow fast READ access.
* 2) To drastically reduce the size of a serialized instance (private/protected members
* get the whole class name, namespace inclusive, prepended to every property in
* the serialized representation).
@@ -43,17 +43,17 @@
class ManyToManyMapping extends AssociationMapping
{
/**
- * Maps the columns in the relational table to the columns in the source table.
+ * READ-ONLY: Maps the columns in the relational table to the columns in the source table.
*/
public $relationToSourceKeyColumns = array();
/**
- * Maps the columns in the relation table to the columns in the target table.
+ * READ-ONLY: Maps the columns in the relation table to the columns in the target table.
*/
public $relationToTargetKeyColumns = array();
/**
- * List of aggregated column names on the join table.
+ * READ-ONLY: List of aggregated column names on the join table.
*/
public $joinTableColumns = array();
@@ -61,24 +61,14 @@ class ManyToManyMapping extends AssociationMapping
//public $keyColumn;
/**
- * Order this collection by the given DQL snippet.
+ * READ-ONLY: Order this collection by the given DQL snippet.
*
* Only simple unqualified field names and ASC|DESC are allowed
*
* @var array
*/
- public $orderBy = null;
-
- /**
- * Initializes a new ManyToManyMapping.
- *
- * @param array $mapping The mapping definition.
- */
- public function __construct(array $mapping)
- {
- parent::__construct($mapping);
- }
-
+ public $orderBy;
+
/**
* Validates and completes the mapping.
*
@@ -145,22 +135,6 @@ protected function _validateAndCompleteMapping(array $mapping)
}
}
- public function getJoinTableColumnNames()
- {
- return $this->joinTableColumns;
- //return array_merge(array_keys($this->relationToSourceKeyColumns), array_keys($this->relationToTargetKeyColumns));
- }
-
- public function getRelationToSourceKeyColumns()
- {
- return $this->relationToSourceKeyColumns;
- }
-