Commit 34c830e3 authored by romanb's avatar romanb

moved Collection

parent c24ecd7b
......@@ -698,8 +698,8 @@ class Doctrine_EntityManager
* @param Doctrine::Common::EventManager $eventManager The EventManager instance to use.
* @return Doctrine::ORM::EntityManager The created EntityManager.
*/
public static function create($conn, $name, Doctrine_Configuration $config = null,
Doctrine_EventManager $eventManager = null)
public static function create($conn, $name, Doctrine_Common_Configuration $config = null,
Doctrine_Common_EventManager $eventManager = null)
{
if (is_array($conn)) {
$connFactory = new Doctrine_DBAL_DriverManager();
......@@ -709,10 +709,10 @@ class Doctrine_EntityManager
}
if (is_null($config)) {
$config = new Doctrine_Configuration();
$config = new Doctrine_Common_Configuration();
}
if (is_null($eventManager)) {
$eventManager = new Doctrine_EventManager();
$eventManager = new Doctrine_Common_EventManager();
}
$em = new Doctrine_EntityManager($conn, $name, $config, $eventManager);
......
<?php
/*
* $Id$
* $Id: Collection.php 4930 2008-09-12 10:40:23Z romanb $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
......@@ -41,12 +41,12 @@
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @since 1.0
* @version $Revision$
* @version $Revision: 4930 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @todo Add more typical Collection methods.
*/
class Doctrine_Collection implements Countable, IteratorAggregate, Serializable, ArrayAccess
class Doctrine_ORM_Collection implements Countable, IteratorAggregate, Serializable, ArrayAccess
{
/**
* The base type of the collection.
......
......@@ -543,7 +543,7 @@ abstract class Doctrine_ORM_Entity implements ArrayAccess, Serializable
if ($rel->isOneToOne() && ! $value instanceof Doctrine_ORM_Entity) {
throw Doctrine_Entity_Exception::invalidValueForOneToOneReference();
} else if (($rel->isOneToMany() || $rel->isManyToMany()) && ! $value instanceof Doctrine_Collection) {
} else if (($rel->isOneToMany() || $rel->isManyToMany()) && ! $value instanceof Doctrine_ORM_Collection) {
throw Doctrine_Entity_Exception::invalidValueForOneToManyReference();
}
......
......@@ -49,7 +49,7 @@ class Doctrine_ORM_Internal_Hydration_ObjectDriver
public function getElementCollection($component)
{
$coll = new Doctrine_Collection($component);
$coll = new Doctrine_ORM_Collection($component);
$this->_collections[] = $coll;
return $coll;
......@@ -80,7 +80,7 @@ class Doctrine_ORM_Internal_Hydration_ObjectDriver
}
}
public function registerCollection(Doctrine_Collection $coll)
public function registerCollection(Doctrine_ORM_Collection $coll)
{
$this->_collections[] = $coll;
}
......
<?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.phpdoctrine.org>.
*/
/**
* The base class for sequence handling drivers.
*
* @package Doctrine
* @subpackage Sequence
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
*/
class Doctrine_Sequence extends Doctrine_Connection_Module
{
/**
* Returns the next free id of a sequence
*
* @param string $seqName name of the sequence
* @param bool when true missing sequences are automatic created
*
* @return integer next id in the given sequence
*/
public function nextId($seqName, $ondemand = true)
{
throw new Doctrine_Sequence_Exception('method not implemented');
}
/**
* Returns the autoincrement ID if supported or $id or fetches the current
* ID in a sequence called: $table.(empty($field) ? '' : '_'.$field)
*
* @param string name of the table into which a new row was inserted
* @param string name of the field into which a new row was inserted
*/
public function lastInsertId($table = null, $field = null)
{
throw new Doctrine_Sequence_Exception('method not implemented');
}
/**
* Returns the current id of a sequence
*
* @param string $seqName name of the sequence
*
* @return integer current id in the given sequence
*/
public function currId($seqName)
{
$this->warnings[] = 'database does not support getting current
sequence value, the sequence value was incremented';
return $this->nextId($seqName);
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -41,10 +41,10 @@ class Orm_Component_CollectionTest extends Doctrine_OrmTestCase
{
parent::setUp();
$this->coll = new Doctrine_Collection('ForumUser');
$this->coll = new Doctrine_ORM_Collection('ForumUser');
//we create a CmsUser with username as key column and add a user to it
$cmsColl = new Doctrine_Collection('CmsUser', 'username');
$cmsColl = new Doctrine_ORM_Collection('CmsUser', 'username');
$user = new CmsUser();
$user->username ='test';
$cmsColl[] = $user;
......@@ -67,7 +67,7 @@ class Orm_Component_CollectionTest extends Doctrine_OrmTestCase
*/
public function shouldUseSpecifiedKeyColumn()
{
$coll = new Doctrine_Collection('ForumUser', 'id');
$coll = new Doctrine_ORM_Collection('ForumUser', 'id');
$this->assertEquals('id', $coll->getKeyField());
}
......@@ -80,7 +80,7 @@ class Orm_Component_CollectionTest extends Doctrine_OrmTestCase
*/
public function shouldThrowExceptionIfNonValidFieldSetAsKey()
{
$coll = new Doctrine_Collection('ForumUser', 'xxNonValidFieldxx');
$coll = new Doctrine_ORM_Collection('ForumUser', 'xxNonValidFieldxx');
}
/**
......@@ -99,7 +99,7 @@ class Orm_Component_CollectionTest extends Doctrine_OrmTestCase
{
$serialized = serialize($this->coll);
$coll = unserialize($serialized);
$this->assertEquals('Doctrine_Collection', get_class($coll));
$this->assertEquals('Doctrine_ORM_Collection', get_class($coll));
}
/**
......
......@@ -85,7 +85,7 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
}
if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
$this->assertTrue($result instanceof Doctrine_Collection);
$this->assertTrue($result instanceof Doctrine_ORM_Collection);
$this->assertTrue($result[0] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[1] instanceof Doctrine_ORM_Entity);
} else if ($hydrationMode == Doctrine::HYDRATE_ARRAY) {
......@@ -187,11 +187,11 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
$this->assertTrue($result[0][0] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[0][0]['phonenumbers'] instanceof Doctrine_Collection);
$this->assertTrue($result[0][0]['phonenumbers'] instanceof Doctrine_ORM_Collection);
$this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[1][0] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_Collection);
$this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_ORM_Collection);
} else if ($hydrationMode == Doctrine::HYDRATE_SCALAR) {
$this->assertTrue(is_array($result));
$this->assertEquals(3, count($result));
......@@ -379,7 +379,7 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
$this->assertTrue($result[0]['1'] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[1]['2'] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[0]['1']['phonenumbers'] instanceof Doctrine_Collection);
$this->assertTrue($result[0]['1']['phonenumbers'] instanceof Doctrine_ORM_Collection);
$this->assertEquals(2, count($result[0]['1']['phonenumbers']));
} else if ($hydrationMode == Doctrine::HYDRATE_SCALAR) {
// NOTE: Indexing has no effect with HYDRATE_SCALAR
......@@ -522,14 +522,14 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
$this->assertTrue($result[0][0] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[0][0]['phonenumbers'] instanceof Doctrine_Collection);
$this->assertTrue($result[0][0]['phonenumbers'] instanceof Doctrine_ORM_Collection);
$this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[0][0]['articles'] instanceof Doctrine_Collection);
$this->assertTrue($result[0][0]['articles'] instanceof Doctrine_ORM_Collection);
$this->assertTrue($result[0][0]['articles'][0] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[0][0]['articles'][1] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[1][0] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_Collection);
$this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_ORM_Collection);
$this->assertTrue($result[1][0]['phonenumbers'][0] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[1][0]['articles'][0] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[1][0]['articles'][1] instanceof Doctrine_ORM_Entity);
......@@ -708,26 +708,26 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$this->assertTrue($result[0][0] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[1][0] instanceof Doctrine_ORM_Entity);
// phonenumbers
$this->assertTrue($result[0][0]['phonenumbers'] instanceof Doctrine_Collection);
$this->assertTrue($result[0][0]['phonenumbers'] instanceof Doctrine_ORM_Collection);
$this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_Collection);
$this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_ORM_Collection);
$this->assertTrue($result[1][0]['phonenumbers'][0] instanceof Doctrine_ORM_Entity);
// articles
$this->assertTrue($result[0][0]['articles'] instanceof Doctrine_Collection);
$this->assertTrue($result[0][0]['articles'] instanceof Doctrine_ORM_Collection);
$this->assertTrue($result[0][0]['articles'][0] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[0][0]['articles'][1] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[1][0]['articles'][0] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[1][0]['articles'][1] instanceof Doctrine_ORM_Entity);
// article comments
$this->assertTrue($result[0][0]['articles'][0]['comments'] instanceof Doctrine_Collection);
$this->assertTrue($result[0][0]['articles'][0]['comments'] instanceof Doctrine_ORM_Collection);
$this->assertTrue($result[0][0]['articles'][0]['comments'][0] instanceof Doctrine_ORM_Entity);
// empty comment collections
$this->assertTrue($result[0][0]['articles'][1]['comments'] instanceof Doctrine_Collection);
$this->assertTrue($result[0][0]['articles'][1]['comments'] instanceof Doctrine_ORM_Collection);
$this->assertEquals(0, count($result[0][0]['articles'][1]['comments']));
$this->assertTrue($result[1][0]['articles'][0]['comments'] instanceof Doctrine_Collection);
$this->assertTrue($result[1][0]['articles'][0]['comments'] instanceof Doctrine_ORM_Collection);
$this->assertEquals(0, count($result[1][0]['articles'][0]['comments']));
$this->assertTrue($result[1][0]['articles'][1]['comments'] instanceof Doctrine_Collection);
$this->assertTrue($result[1][0]['articles'][1]['comments'] instanceof Doctrine_ORM_Collection);
$this->assertEquals(0, count($result[1][0]['articles'][1]['comments']));
} else if ($hydrationMode == Doctrine::HYDRATE_SCALAR) {
//...
......@@ -848,7 +848,7 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
$this->assertTrue(is_array($result[0]));
$this->assertTrue(is_array($result[1]));
} else if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
$this->assertTrue($result instanceof Doctrine_Collection);
$this->assertTrue($result instanceof Doctrine_ORM_Collection);
$this->assertTrue($result[0] instanceof Doctrine_ORM_Entity);
$this->assertTrue($result[1] instanceof Doctrine_ORM_Entity);
} else if ($hydrationMode == Doctrine::HYDRATE_SCALAR) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment