Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
9dcab5ee
Commit
9dcab5ee
authored
Feb 07, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small reorganizations, improvements and progress.
parent
2eb4a16d
Changes
33
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
547 additions
and
491 deletions
+547
-491
Collection.php
lib/Doctrine/Common/Collections/Collection.php
+103
-56
EventArgs.php
lib/Doctrine/Common/EventArgs.php
+19
-28
EventManager.php
lib/Doctrine/Common/EventManager.php
+13
-14
Connection.php
lib/Doctrine/DBAL/Connection.php
+24
-34
AbstractQuery.php
lib/Doctrine/ORM/AbstractQuery.php
+8
-10
EntityManager.php
lib/Doctrine/ORM/EntityManager.php
+6
-7
EntityManagerException.php
lib/Doctrine/ORM/EntityManagerException.php
+3
-3
Events.php
lib/Doctrine/ORM/Events.php
+41
-36
EntityException.php
lib/Doctrine/ORM/Exceptions/EntityException.php
+0
-65
HydrationException.php
lib/Doctrine/ORM/Internal/Hydration/HydrationException.php
+1
-1
ObjectHydrator.php
lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
+25
-5
SingleScalarHydrator.php
lib/Doctrine/ORM/Internal/Hydration/SingleScalarHydrator.php
+0
-1
AssociationMapping.php
lib/Doctrine/ORM/Mapping/AssociationMapping.php
+0
-2
ClassMetadata.php
lib/Doctrine/ORM/Mapping/ClassMetadata.php
+45
-79
AnnotationDriver.php
lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
+3
-1
ManyToManyMapping.php
lib/Doctrine/ORM/Mapping/ManyToManyMapping.php
+0
-2
MappingException.php
lib/Doctrine/ORM/Mapping/MappingException.php
+1
-1
OneToManyMapping.php
lib/Doctrine/ORM/Mapping/OneToManyMapping.php
+2
-5
OneToOneMapping.php
lib/Doctrine/ORM/Mapping/OneToOneMapping.php
+0
-2
PersistentCollection.php
lib/Doctrine/ORM/PersistentCollection.php
+12
-12
AbstractCollectionPersister.php
lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php
+33
-3
AbstractEntityPersister.php
lib/Doctrine/ORM/Persisters/AbstractEntityPersister.php
+9
-7
ManyToManyPersister.php
lib/Doctrine/ORM/Persisters/ManyToManyPersister.php
+2
-4
Parser.php
lib/Doctrine/ORM/Query/Parser.php
+0
-1
QueryException.php
lib/Doctrine/ORM/Query/QueryException.php
+1
-1
UnitOfWork.php
lib/Doctrine/ORM/UnitOfWork.php
+85
-101
VirtualProxy.php
lib/Doctrine/ORM/VirtualProxy.php
+25
-3
AllTests.php
tests/Doctrine/Tests/Common/AllTests.php
+2
-3
EventManagerTest.php
tests/Doctrine/Tests/Common/EventManagerTest.php
+72
-0
CmsUser.php
tests/Doctrine/Tests/Models/CMS/CmsUser.php
+1
-1
EntityManagerTest.php
tests/Doctrine/Tests/ORM/EntityManagerTest.php
+1
-1
BasicCRUDTest.php
tests/Doctrine/Tests/ORM/Functional/BasicCRUDTest.php
+9
-1
SingleScalarHydratorTest.php
...Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php
+1
-1
No files found.
lib/Doctrine/Common/Collections/Collection.php
View file @
9dcab5ee
This diff is collapsed.
Click to expand it.
lib/Doctrine/Common/Event
s/Event
.php
→
lib/Doctrine/Common/Event
Args
.php
View file @
9dcab5ee
...
...
@@ -16,60 +16,51 @@
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.
phpdoctrine
.org>.
* <http://www.
doctrine-project
.org>.
*/
namespace
Doctrine\Common
\Events
;
namespace
Doctrine\Common
;
/**
* Doctrine_Event
* EventArgs is the base class for classes containing event data.
*
* This class contains no event data and cannot be instantiated.
* It is used by events that do not pass state information to an event handler
* when an event is raised. The single empty EventArgs instance can be obtained
* through {@link getEmptyInstance()}.
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.
phpdoctrine
.org
* @link www.
doctrine-project
.org
* @since 2.0
* @version $Revision$
*/
class
Event
class
Event
Args
{
/* Event callback constants */
const
preDelete
=
'preDelete'
;
const
postDelete
=
'postDelete'
;
//...more
protected
$_type
;
protected
$_target
;
protected
$_defaultPrevented
;
private
static
$_emptyEventArgsInstance
;
private
$_defaultPrevented
;
p
ublic
function
__construct
(
$type
,
$target
=
null
)
p
rotected
function
__construct
(
)
{
$this
->
_type
=
$type
;
$this
->
_target
=
$target
;
$this
->
_defaultPrevented
=
false
;
}
public
function
getType
()
{
return
$this
->
_type
;
}
public
function
preventDefault
()
{
$this
->
_defaultPrevented
=
true
;
}
public
function
getDefaultPrevented
()
{
return
$this
->
_defaultPrevented
;
}
public
function
getTarget
()
public
static
function
getEmptyInstance
()
{
return
$this
->
_target
;
if
(
!
self
::
$_emptyEventArgsInstance
)
{
self
::
$_emptyEventArgsInstance
=
new
EventArgs
;
}
return
self
::
$_emptyEventArgsInstance
;
}
}
lib/Doctrine/Common/EventManager.php
View file @
9dcab5ee
...
...
@@ -16,7 +16,7 @@
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.
phpdoctrine
.org>.
* <http://www.
doctrine-project
.org>.
*/
namespace
Doctrine\Common
;
...
...
@@ -45,20 +45,20 @@ class EventManager
/**
* Dispatches an event to all registered listeners.
*
* @param string|Event $event The name of the event or the event object.
* @param string $eventName The name of the event to dispatch. The name of the event is
* the name of the method that is invoked on listeners.
* @param EventArgs $eventArgs The event arguments to pass to the event handlers/listeners.
* If not supplied, the single empty EventArgs instance is used.
* @return boolean
*/
public
function
dispatchEvent
(
$event
)
public
function
dispatchEvent
(
$event
Name
,
EventArgs
$eventArgs
=
null
)
{
$argIsCallback
=
is_string
(
$event
);
$callback
=
$argIsCallback
?
$event
:
$event
->
getType
();
if
(
isset
(
$this
->
_listeners
[
$callback
]))
{
$event
=
$argIsCallback
?
new
Event
(
$event
)
:
$event
;
foreach
(
$this
->
_listeners
[
$callback
]
as
$listener
)
{
$listener
->
$callback
(
$event
);
if
(
isset
(
$this
->
_listeners
[
$eventName
]))
{
$eventArgs
=
is_null
(
$eventArgs
)
?
EventArgs
::
getEmptyInstance
()
:
$eventArgs
;
foreach
(
$this
->
_listeners
[
$eventName
]
as
$listener
)
{
$listener
->
$eventName
(
$eventArgs
);
}
return
!
$event
->
getDefaultPrevented
();
return
!
$event
Args
->
getDefaultPrevented
();
}
return
true
;
}
...
...
@@ -95,7 +95,7 @@ class EventManager
{
// TODO: maybe check for duplicate registrations?
foreach
((
array
)
$events
as
$event
)
{
$this
->
_listeners
[
$event
]
=
$listener
;
$this
->
_listeners
[
$event
]
[]
=
$listener
;
}
}
...
...
@@ -109,5 +109,4 @@ class EventManager
{
$this
->
addEventListener
(
$subscriber
->
getSubscribedEvents
(),
$subscriber
);
}
}
}
\ No newline at end of file
lib/Doctrine/DBAL/Connection.php
View file @
9dcab5ee
...
...
@@ -154,9 +154,11 @@ class Connection
* Initializes a new instance of the Connection class.
*
* @param array $params The connection parameters.
* @param Driver $driver
* @param Configuration $config
* @param EventManager $eventManager
*/
public
function
__construct
(
array
$params
,
Driver
$driver
,
Configuration
$config
=
null
,
public
function
__construct
(
array
$params
,
Driver
$driver
,
Configuration
$config
=
null
,
EventManager
$eventManager
=
null
)
{
$this
->
_driver
=
$driver
;
...
...
@@ -182,7 +184,7 @@ class Connection
/**
* Gets the Configuration used by the Connection.
*
* @return Configuration
* @return
Doctrine\DBAL\
Configuration
*/
public
function
getConfiguration
()
{
...
...
@@ -389,23 +391,23 @@ class Connection
}
/**
*
fetchAll
*
Convenience method for PDO::query("...") followed by $stmt->fetchAll(PDO::FETCH_ASSOC).
*
* @param string $s
tatement sql query to be executed
* @param array $params
prepared statement params
* @param string $s
ql The SQL query.
* @param array $params
The query parameters.
* @return array
*/
public
function
fetchAll
(
$s
tatement
,
array
$params
=
array
())
public
function
fetchAll
(
$s
ql
,
array
$params
=
array
())
{
return
$this
->
execute
(
$s
tatement
,
$params
)
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
return
$this
->
execute
(
$s
ql
,
$params
)
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
}
/**
*
fetchOne
*
Convenience method for PDO::query("...") followed by $stmt->fetchColumn().
*
* @param string $statement
sql query to be executed
* @param array $params
prepared statement params
* @param int $colnum
0-indexed column number to retrieve
* @param string $statement
The SQL query.
* @param array $params
The query parameters.
* @param int $colnum 0-indexed column number to retrieve
* @return mixed
*/
public
function
fetchOne
(
$statement
,
array
$params
=
array
(),
$colnum
=
0
)
...
...
@@ -414,10 +416,10 @@ class Connection
}
/**
*
fetchRow
*
Convenience method for PDO::query("...") followed by $stmt->fetch(PDO::FETCH_ASSOC).
*
* @param string $statement
sql query to be executed
* @param array $params
prepared statement params
* @param string $statement
The SQL query.
* @param array $params
The query parameters.
* @return array
*/
public
function
fetchRow
(
$statement
,
array
$params
=
array
())
...
...
@@ -426,7 +428,7 @@ class Connection
}
/**
*
fetchArray
*
Convenience method for PDO::query("...") followed by $stmt->fetch(PDO::FETCH_NUM).
*
* @param string $statement sql query to be executed
* @param array $params prepared statement params
...
...
@@ -438,7 +440,7 @@ class Connection
}
/**
*
fetchColumn
*
Convenience method for PDO::query("...") followed by $stmt->fetchAll(PDO::FETCH_COLUMN, ...).
*
* @param string $statement sql query to be executed
* @param array $params prepared statement params
...
...
@@ -451,19 +453,7 @@ class Connection
}
/**
* fetchAssoc
*
* @param string $statement sql query to be executed
* @param array $params prepared statement params
* @return array
*/
public
function
fetchAssoc
(
$statement
,
array
$params
=
array
())
{
return
$this
->
execute
(
$statement
,
$params
)
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
}
/**
* fetchBoth
* Convenience method for PDO::query("...") followed by $stmt->fetchAll(PDO::FETCH_BOTH).
*
* @param string $statement sql query to be executed
* @param array $params prepared statement params
...
...
@@ -478,7 +468,7 @@ class Connection
* Prepares an SQL statement.
*
* @param string $statement
* @return
Doctrine::DBAL::
Statement
* @return
PDO
Statement
*/
public
function
prepare
(
$statement
)
{
...
...
@@ -487,13 +477,13 @@ class Connection
}
/**
* Queries the database with limit and offset
* a
dded to the query and returns a Doctrine_Connection_Statement object
* Queries the database with limit and offset
added to the query and returns
* a
Statement object.
*
* @param string $query
* @param integer $limit
* @param integer $offset
* @return
Doctrine_Connection_
Statement
* @return Statement
*/
public
function
select
(
$query
,
$limit
=
0
,
$offset
=
0
)
{
...
...
lib/Doctrine/ORM/AbstractQuery.php
View file @
9dcab5ee
...
...
@@ -17,23 +17,21 @@
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.
phpdoctrine
.org>.
* <http://www.
doctrine-project
.org>.
*/
namespace
Doctrine\ORM
;
/**
*
Doctrine_ORM_Query_Abstract
*
Base class for Query and NativeQuery.
*
* @package Doctrine
* @subpackage Query
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.
phpdoctrine
.com
* @link www.
doctrine-project
.com
* @since 1.0
* @version $Revision: 1393 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @
todo See {@link Doctrine_ORM_Query}
* @
author Roman Borschel <roman@code-factory.org>
*/
abstract
class
AbstractQuery
{
...
...
@@ -101,7 +99,7 @@ abstract class AbstractQuery
/**
* @var integer $type Query type.
*
* @see
Doctrine_ORM_
Query::* constants
* @see Query::* constants
*/
protected
$_type
=
self
::
SELECT
;
...
...
@@ -112,19 +110,19 @@ abstract class AbstractQuery
/**
* @var array $params Parameters of this query.
* @see
Doctrine_ORM_
Query::free that initializes this property
* @see Query::free that initializes this property
*/
protected
$_params
=
array
();
/**
* @var array $_enumParams Array containing the keys of the parameters that should be enumerated.
* @see
Doctrine_ORM_
Query::free that initializes this property
* @see Query::free that initializes this property
*/
protected
$_enumParams
=
array
();
/**
* @var array $_dqlParts An array containing all DQL query parts.
* @see
Doctrine_ORM_
Query::free that initializes this property
* @see Query::free that initializes this property
*/
protected
$_dqlParts
=
array
();
...
...
lib/Doctrine/ORM/EntityManager.php
View file @
9dcab5ee
...
...
@@ -24,7 +24,6 @@ namespace Doctrine\ORM;
use
Doctrine\Common\EventManager
;
use
Doctrine\Common\DoctrineException
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\ORM\Exceptions\EntityManagerException
;
use
Doctrine\ORM\Mapping\ClassMetadata
;
use
Doctrine\ORM\Mapping\ClassMetadataFactory
;
...
...
@@ -90,7 +89,7 @@ class EntityManager
private
$_conn
;
/**
* The metadata factory, used to retrieve the metadata of entity classes.
* The metadata factory, used to retrieve the
ORM
metadata of entity classes.
*
* @var Doctrine\ORM\Mapping\ClassMetadataFactory
*/
...
...
@@ -330,7 +329,7 @@ class EntityManager
*/
public
function
flush
()
{
$this
->
_errorIf
NotActiveOr
Closed
();
$this
->
_errorIfClosed
();
$this
->
_unitOfWork
->
commit
();
}
...
...
@@ -412,7 +411,7 @@ class EntityManager
*/
public
function
save
(
$object
)
{
$this
->
_errorIf
NotActiveOr
Closed
();
$this
->
_errorIfClosed
();
$this
->
_unitOfWork
->
save
(
$object
);
if
(
$this
->
_flushMode
==
self
::
FLUSHMODE_IMMEDIATE
)
{
$this
->
flush
();
...
...
@@ -426,7 +425,7 @@ class EntityManager
*/
public
function
delete
(
$entity
)
{
$this
->
_errorIf
NotActiveOr
Closed
();
$this
->
_errorIfClosed
();
$this
->
_unitOfWork
->
delete
(
$entity
);
if
(
$this
->
_flushMode
==
self
::
FLUSHMODE_IMMEDIATE
)
{
$this
->
flush
();
...
...
@@ -459,7 +458,7 @@ class EntityManager
}
/**
* Gets the repository for an
Entity
.
* Gets the repository for an
entity class
.
*
* @param string $entityName The name of the Entity.
* @return Doctrine\ORM\EntityRepository The repository.
...
...
@@ -520,7 +519,7 @@ class EntityManager
*
* @throws EntityManagerException If the EntityManager is closed or not active.
*/
private
function
_errorIf
NotActiveOr
Closed
()
private
function
_errorIfClosed
()
{
if
(
$this
->
_closed
)
{
throw
EntityManagerException
::
notActiveOrClosed
(
$this
->
_name
);
...
...
lib/Doctrine/ORM/E
xceptions/E
ntityManagerException.php
→
lib/Doctrine/ORM/EntityManagerException.php
View file @
9dcab5ee
...
...
@@ -16,10 +16,10 @@
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.
phpdoctrine
.org>.
* <http://www.
doctrine-project
.org>.
*/
namespace
Doctrine\ORM
\Exceptions
;
namespace
Doctrine\ORM
;
/**
* Doctrine_EntityManager_Exception
...
...
@@ -27,7 +27,7 @@ namespace Doctrine\ORM\Exceptions;
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.
phpdoctrine
.org
* @link www.
doctrine-project
.org
* @since 2.0
* @version $Revision$
*/
...
...
lib/Doctrine/ORM/E
xceptions/ORMException
.php
→
lib/Doctrine/ORM/E
vents
.php
View file @
9dcab5ee
<?php
/*
* $Id: Exception.php 4776 2008-08-16 19:40:59Z romanb $
*
* 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>.
*/
<?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\ORM
;
/**
* Container for all ORM events.
*
* This class cannot be instantiated.
*
* @author robo
* @since 2.0
*/
final
class
Events
{
private
function
__construct
()
{}
const
preDelete
=
'preDelete'
;
const
postDelete
=
'postDelete'
;
const
preSave
=
'preSave'
;
const
postSave
=
'postSave'
;
}
#namespace Doctrine::ORM::Exceptions;
/**
* Doctrine_Exception
*
* @package Doctrine
* @subpackage Exception
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 4776 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
*/
class
Doctrine_ORM_Exceptions_ORMException
extends
Doctrine_Common_Exceptions_DoctrineException
{}
lib/Doctrine/ORM/Exceptions/EntityException.php
deleted
100644 → 0
View file @
2eb4a16d
<?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>.
*/
#namespace Doctrine::ORM::Exceptions;
/**
* Doctrine_Entity_Exception
*
* @package Doctrine
* @subpackage Entity
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class
Doctrine_ORM_Exceptions_EntityException
extends
Doctrine_ORM_Exceptions_ORMException
{
public
static
function
unknownField
(
$field
)
{
return
new
self
(
"Undefined field: '
$field
'."
);
}
public
static
function
invalidValueForOneToManyReference
()
{
return
new
self
(
"Invalid value. The value of a reference in a OneToMany "
.
"association must be a Collection."
);
}
public
static
function
invalidValueForOneToOneReference
()
{
return
new
self
(
"Invalid value. The value of a reference in a OneToOne "
.
"association must be an Entity."
);
}
public
static
function
invalidValueForManyToManyReference
()
{
return
new
self
(
"Invalid value. The value of a reference in a ManyToMany "
.
"association must be a Collection."
);
}
public
static
function
invalidField
(
$field
)
{
return
new
self
(
"Invalid field: '
$field
'."
);
}
}
\ No newline at end of file
lib/Doctrine/ORM/
Exceptions
/HydrationException.php
→
lib/Doctrine/ORM/
Internal/Hydration
/HydrationException.php
View file @
9dcab5ee
<?php
namespace
Doctrine\ORM\
Exceptions
;
namespace
Doctrine\ORM\
Internal\Hydration
;
class
HydrationException
extends
\Doctrine\Common\DoctrineException
{
...
...
lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
View file @
9dcab5ee
<?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\ORM\Internal\Hydration
;
use
\PDO
;
/**
*
Description of ObjectHydrator
*
The ObjectHydrator constructs an object graph out of an SQL result set.
*
* @author robo
* @since 2.0
*/
class
ObjectHydrator
extends
AbstractHydrator
{
...
...
@@ -64,8 +84,8 @@ class ObjectHydrator extends AbstractHydrator
// Take snapshots from all initialized collections
foreach
(
$this
->
_collections
as
$coll
)
{
$coll
->
_
takeSnapshot
();
$coll
->
_
setHydrationFlag
(
false
);
$coll
->
takeSnapshot
();
$coll
->
setHydrationFlag
(
false
);
}
// Clean up
...
...
@@ -128,8 +148,8 @@ class ObjectHydrator extends AbstractHydrator
$relation
=
$classMetadata
->
getAssociationMapping
(
$name
);
$relatedClass
=
$this
->
_em
->
getClassMetadata
(
$relation
->
getTargetEntityName
());
$coll
=
$this
->
getCollection
(
$relatedClass
->
getClassName
());
$coll
->
_
setOwner
(
$entity
,
$relation
);
$coll
->
_
setHydrationFlag
(
true
);
$coll
->
setOwner
(
$entity
,
$relation
);
$coll
->
setHydrationFlag
(
true
);
$classMetadata
->
getReflectionProperty
(
$name
)
->
setValue
(
$entity
,
$coll
);
$this
->
_initializedRelations
[
$oid
][
$name
]
=
true
;
$this
->
_uow
->
setOriginalEntityProperty
(
$oid
,
$name
,
$coll
);
...
...
lib/Doctrine/ORM/Internal/Hydration/SingleScalarHydrator.php
View file @
9dcab5ee
...
...
@@ -7,7 +7,6 @@
namespace
Doctrine\ORM\Internal\Hydration
;
use
\PDO
;
use
Doctrine\ORM\Exceptions\HydrationException
;
/**
* Description of SingleScalarHydrator
...
...
lib/Doctrine/ORM/Mapping/AssociationMapping.php
View file @
9dcab5ee
...
...
@@ -21,8 +21,6 @@
namespace
Doctrine\ORM\Mapping
;
use
Doctrine\ORM\Exceptions\MappingException
;
/**
* Base class for association mappings.
*
...
...
lib/Doctrine/ORM/Mapping/ClassMetadata.php
View file @
9dcab5ee
This diff is collapsed.
Click to expand it.
lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
View file @
9dcab5ee
...
...
@@ -22,7 +22,7 @@
namespace
Doctrine\ORM\Mapping\Driver
;
use
Doctrine\ORM\Mapping\ClassMetadata
;
use
Doctrine\ORM\
Exceptions
\MappingException
;
use
Doctrine\ORM\
Mapping
\MappingException
;
/* Addendum annotation reflection extensions */
if
(
!
class_exists
(
'\Addendum'
,
false
))
{
...
...
@@ -134,6 +134,7 @@ class AnnotationDriver
$metadata
->
mapOneToMany
(
$mapping
);
}
else
if
(
$manyToOneAnnot
=
$property
->
getAnnotation
(
'DoctrineManyToOne'
))
{
$mapping
[
'joinColumns'
]
=
$joinColumns
;
$mapping
[
'cascade'
]
=
$manyToOneAnnot
->
cascade
;
$mapping
[
'targetEntity'
]
=
$manyToOneAnnot
->
targetEntity
;
$metadata
->
mapManyToOne
(
$mapping
);
}
else
if
(
$manyToManyAnnot
=
$property
->
getAnnotation
(
'DoctrineManyToMany'
))
{
...
...
@@ -150,6 +151,7 @@ class AnnotationDriver
$mapping
[
'joinTable'
]
=
$joinTable
;
$mapping
[
'targetEntity'
]
=
$manyToManyAnnot
->
targetEntity
;
$mapping
[
'mappedBy'
]
=
$manyToManyAnnot
->
mappedBy
;
$mapping
[
'cascade'
]
=
$manyToManyAnnot
->
cascade
;
$metadata
->
mapManyToMany
(
$mapping
);
}
...
...
lib/Doctrine/ORM/Mapping/ManyToManyMapping.php
View file @
9dcab5ee
...
...
@@ -21,8 +21,6 @@
namespace
Doctrine\ORM\Mapping
;
use
Doctrine\ORM\Exceptions\MappingException
;
/**
* A many-to-many mapping describes the mapping between two collections of
* entities.
...
...
lib/Doctrine/ORM/
Exceptions
/MappingException.php
→
lib/Doctrine/ORM/
Mapping
/MappingException.php
View file @
9dcab5ee
...
...
@@ -19,7 +19,7 @@
* <http://www.phpdoctrine.org>.
*/
namespace
Doctrine\ORM\
Exceptions
;
namespace
Doctrine\ORM\
Mapping
;
/**
* A MappingException indicates that something is wrong with the mapping setup.
...
...
lib/Doctrine/ORM/Mapping/OneToManyMapping.php
View file @
9dcab5ee
...
...
@@ -21,8 +21,6 @@
namespace
Doctrine\ORM\Mapping
;
use
Doctrine\ORM\Exceptions\MappingException
;
/**
* Represents a one-to-many mapping.
*
...
...
@@ -53,7 +51,7 @@ class OneToManyMapping extends AssociationMapping
//protected $_sourceKeysToTargetForeignKeys;
/** Whether to delete orphaned elements (removed from the collection) */
pr
otected
$_deleteOrphans
=
false
;
pr
ivate
$_deleteOrphans
=
false
;
/**
* Initializes a new OneToManyMapping.
...
...
@@ -96,9 +94,8 @@ class OneToManyMapping extends AssociationMapping
}
/**
*
Whether the association is one-to-many.
*
{@inheritdoc}
*
* @return boolean TRUE if the association is one-to-many, FALSE otherwise.
* @override
*/
public
function
isOneToMany
()
...
...
lib/Doctrine/ORM/Mapping/OneToOneMapping.php
View file @
9dcab5ee
...
...
@@ -21,8 +21,6 @@
namespace
Doctrine\ORM\Mapping
;
use
Doctrine\ORM\Exceptions\MappingException
;
/**
* A one-to-one mapping describes a uni-directional mapping from one entity
* to another entity.
...
...
lib/Doctrine/ORM/PersistentCollection.php
View file @
9dcab5ee
...
...
@@ -48,7 +48,7 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
*
* @var string
*/
private
$_
entityBaseT
ype
;
private
$_
t
ype
;
/**
* A snapshot of the collection at the moment it was fetched from the database.
...
...
@@ -99,7 +99,7 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
* Hydration flag.
*
* @var boolean
* @see
_
setHydrationFlag()
* @see setHydrationFlag()
*/
private
$_hydrationFlag
;
...
...
@@ -119,12 +119,12 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
/**
* Creates a new persistent collection.
*/
public
function
__construct
(
EntityManager
$em
,
$
entityBaseT
ype
,
array
$data
=
array
(),
$keyField
=
null
)
public
function
__construct
(
EntityManager
$em
,
$
t
ype
,
array
$data
=
array
(),
$keyField
=
null
)
{
parent
::
__construct
(
$data
);
$this
->
_
entityBaseType
=
$entityBaseT
ype
;
$this
->
_
type
=
$t
ype
;
$this
->
_em
=
$em
;
$this
->
_ownerClass
=
$em
->
getClassMetadata
(
$
entityBaseT
ype
);
$this
->
_ownerClass
=
$em
->
getClassMetadata
(
$
t
ype
);
if
(
$keyField
!==
null
)
{
if
(
!
$this
->
_ownerClass
->
hasField
(
$keyField
))
{
throw
new
DoctrineException
(
"Invalid field '
$keyField
' can't be used as key."
);
...
...
@@ -162,7 +162,7 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
* @param object $entity
* @param AssociationMapping $assoc
*/
public
function
_
setOwner
(
$entity
,
AssociationMapping
$assoc
)
public
function
setOwner
(
$entity
,
AssociationMapping
$assoc
)
{
$this
->
_owner
=
$entity
;
$this
->
_association
=
$assoc
;
...
...
@@ -289,7 +289,7 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
*
* @param boolean $bool
*/
public
function
_
setHydrationFlag
(
$bool
)
public
function
setHydrationFlag
(
$bool
)
{
$this
->
_hydrationFlag
=
$bool
;
}
...
...
@@ -301,9 +301,9 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
* when a fetched collection has three elements, then two of those
* are being removed the diff would contain one element.
*/
public
function
_
takeSnapshot
()
public
function
takeSnapshot
()
{
$this
->
_snapshot
=
$this
->
_
data
;
$this
->
_snapshot
=
$this
->
_
elements
;
}
/**
...
...
@@ -312,7 +312,7 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
*
* @return array The last snapshot of the elements.
*/
public
function
_
getSnapshot
()
public
function
getSnapshot
()
{
return
$this
->
_snapshot
;
}
...
...
@@ -325,7 +325,7 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
*/
public
function
getDeleteDiff
()
{
return
array_udiff
(
$this
->
_snapshot
,
$this
->
_
data
,
array
(
$this
,
'_compareRecords'
));
return
array_udiff
(
$this
->
_snapshot
,
$this
->
_
elements
,
array
(
$this
,
'_compareRecords'
));
}
/**
...
...
@@ -335,7 +335,7 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
*/
public
function
getInsertDiff
()
{
return
array_udiff
(
$this
->
_
data
,
$this
->
_snapshot
,
array
(
$this
,
'_compareRecords'
));
return
array_udiff
(
$this
->
_
elements
,
$this
->
_snapshot
,
array
(
$this
,
'_compareRecords'
));
}
/**
...
...
lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php
View file @
9dcab5ee
...
...
@@ -66,20 +66,36 @@ abstract class AbstractCollectionPersister
if
(
$coll
->
getMapping
()
->
isInverseSide
())
{
return
;
// ignore inverse side
}
$sql
=
$this
->
_getDeleteSql
(
$coll
);
$this
->
_conn
->
exec
(
$sql
,
$this
->
_getDeleteSqlParameters
(
$coll
));
}
/**
* Gets the SQL statement for deleting the given collection.
*
* @param PersistentCollection $coll
*/
abstract
protected
function
_getDeleteSql
(
PersistentCollection
$coll
);
/**
* Gets the SQL parameters for the corresponding SQL statement to delete
* the given collection.
*
* @param PersistentCollection $coll
*/
abstract
protected
function
_getDeleteSqlParameters
(
PersistentCollection
$coll
);
/**
* Updates the given collection, synchronizing it's state with the database
* by inserting, updating and deleting individual elements.
*
* @param PersistentCollection $coll
*/
public
function
update
(
PersistentCollection
$coll
)
{
if
(
$coll
->
getMapping
()
->
isInverseSide
())
{
return
;
// ignore inverse side
}
$this
->
deleteRows
(
$coll
);
//$this->updateRows($coll);
$this
->
insertRows
(
$coll
);
...
...
@@ -113,6 +129,13 @@ abstract class AbstractCollectionPersister
*/
abstract
protected
function
_getDeleteRowSql
(
PersistentCollection
$coll
);
/**
* Gets the SQL parameters for the corresponding SQL statement to delete the given
* element from the given collection.
*
* @param PersistentCollection $coll
* @param mixed $element
*/
abstract
protected
function
_getDeleteRowSqlParameters
(
PersistentCollection
$coll
,
$element
);
/**
...
...
@@ -128,7 +151,14 @@ abstract class AbstractCollectionPersister
* @param PersistentCollection $coll
*/
abstract
protected
function
_getInsertRowSql
(
PersistentCollection
$coll
);
/**
* Gets the SQL parameters for the corresponding SQL statement to insert the given
* element of the given collection into the database.
*
* @param PersistentCollection $coll
* @param mixed $element
*/
abstract
protected
function
_getInsertRowSqlParameters
(
PersistentCollection
$coll
,
$element
);
}
lib/Doctrine/ORM/Persisters/AbstractEntityPersister.php
View file @
9dcab5ee
...
...
@@ -21,6 +21,9 @@
namespace
Doctrine\ORM\Persisters
;
use
Doctrine\ORM\EntityManager
;
use
Doctrine\ORM\Mapping\ClassMetadata
;
/**
* Base class for all EntityPersisters.
*
...
...
@@ -65,7 +68,7 @@ abstract class AbstractEntityPersister
* that uses the given EntityManager and persists instances of the class described
* by the given class metadata descriptor.
*/
public
function
__construct
(
\Doctrine\ORM\EntityManager
$em
,
\Doctrine\ORM\Mapping\
ClassMetadata
$classMetadata
)
public
function
__construct
(
EntityManager
$em
,
ClassMetadata
$classMetadata
)
{
$this
->
_em
=
$em
;
$this
->
_entityName
=
$classMetadata
->
getClassName
();
...
...
@@ -112,8 +115,10 @@ abstract class AbstractEntityPersister
*/
public
function
delete
(
$entity
)
{
$id
=
array_combine
(
$this
->
_classMetadata
->
getIdentifierFieldNames
(),
$this
->
_em
->
getUnitOfWork
()
->
getEntityIdentifier
(
$entity
));
$id
=
array_combine
(
$this
->
_classMetadata
->
getIdentifierFieldNames
(),
$this
->
_em
->
getUnitOfWork
()
->
getEntityIdentifier
(
$entity
)
);
$this
->
_conn
->
delete
(
$this
->
_classMetadata
->
getTableName
(),
$id
);
}
...
...
@@ -132,7 +137,7 @@ abstract class AbstractEntityPersister
*
* @param string $fieldName
* @return string
* @todo
Consider using 'inherited' => 'ClassName' to make the lookup simpler.
* @todo
Move to ClassMetadata?
*/
public
function
getOwningClass
(
$fieldName
)
{
...
...
@@ -180,11 +185,9 @@ abstract class AbstractEntityPersister
if
(
$this
->
_classMetadata
->
hasAssociation
(
$field
))
{
$assocMapping
=
$this
->
_classMetadata
->
getAssociationMapping
(
$field
);
if
(
!
$assocMapping
->
isOneToOne
()
||
$assocMapping
->
isInverseSide
())
{
//echo "NOT TO-ONE OR INVERSE!";
continue
;
}
foreach
(
$assocMapping
->
getSourceToTargetKeyColumns
()
as
$sourceColumn
=>
$targetColumn
)
{
//TODO: throw exc if field not set
$otherClass
=
$this
->
_em
->
getClassMetadata
(
$assocMapping
->
getTargetEntityName
());
if
(
is_null
(
$newVal
))
{
$result
[
$sourceColumn
]
=
null
;
...
...
@@ -192,7 +195,6 @@ abstract class AbstractEntityPersister
$result
[
$sourceColumn
]
=
$otherClass
->
getReflectionProperty
(
$otherClass
->
getFieldName
(
$targetColumn
))
->
getValue
(
$newVal
);
}
}
}
else
if
(
is_null
(
$newVal
))
{
$result
[
$columnName
]
=
null
;
...
...
lib/Doctrine/ORM/Persisters/ManyToManyPersister.php
View file @
9dcab5ee
...
...
@@ -65,9 +65,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
* @override
*/
protected
function
_getUpdateRowSql
(
PersistentCollection
$coll
)
{
}
{}
/**
* {@inheritdoc}
...
...
@@ -96,7 +94,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
$this
->
_uow
->
getEntityIdentifier
(
$coll
->
getOwner
()),
$this
->
_uow
->
getEntityIdentifier
(
$element
)
);
var_dump
(
$params
);
//
var_dump($params);
return
$params
;
}
...
...
lib/Doctrine/ORM/Query/Parser.php
View file @
9dcab5ee
...
...
@@ -23,7 +23,6 @@
namespace
Doctrine\ORM\Query
;
use
Doctrine\ORM\Query\AST
;
use
Doctrine\ORM\Exceptions\QueryException
;
use
Doctrine\ORM\Query\Exec
;
/**
...
...
lib/Doctrine/ORM/
Exceptions
/QueryException.php
→
lib/Doctrine/ORM/
Query
/QueryException.php
View file @
9dcab5ee
...
...
@@ -4,7 +4,7 @@
* and open the template in the editor.
*/
namespace
Doctrine\ORM\
Exceptions
;
namespace
Doctrine\ORM\
Query
;
/**
* Description of QueryException
...
...
lib/Doctrine/ORM/UnitOfWork.php
View file @
9dcab5ee
This diff is collapsed.
Click to expand it.
lib/Doctrine/ORM/VirtualProxy.php
View file @
9dcab5ee
<?php
#namespace Doctrine\ORM;
/*
* $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\ORM
;
use
Doctrine\ORM\Mapping\AssociationMapping
;
/**
* Represents a virtual proxy that is used for lazy to-one associations.
...
...
@@ -7,7 +29,7 @@
* @author robo
* @since 2.0
*/
class
Doctrine_ORM_
VirtualProxy
class
VirtualProxy
{
private
$_assoc
;
private
$_refProp
;
...
...
@@ -22,7 +44,7 @@ class Doctrine_ORM_VirtualProxy
* @param <type> $assoc
* @param <type> $refProp
*/
public
function
__construct
(
$owner
,
Doctrine_ORM_Mapping_AssociationMapping
$assoc
,
ReflectionProperty
$refProp
)
public
function
__construct
(
$owner
,
AssociationMapping
$assoc
,
\
ReflectionProperty
$refProp
)
{
$this
->
_owner
=
$owner
;
$this
->
_assoc
=
$assoc
;
...
...
tests/Doctrine/Tests/Common/AllTests.php
View file @
9dcab5ee
...
...
@@ -10,9 +10,6 @@ if (!defined('PHPUnit_MAIN_METHOD')) {
require_once
__DIR__
.
'/../TestInit.php'
;
// Suites
#require_once 'Common/Collections/AllTests.php';
class
AllTests
{
public
static
function
main
()
...
...
@@ -24,6 +21,8 @@ class AllTests
{
$suite
=
new
\Doctrine\Tests\DoctrineTestSuite
(
'Doctrine Common Tests'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\Common\EventManagerTest'
);
$suite
->
addTest
(
Collections\AllTests
::
suite
());
return
$suite
;
...
...
tests/Doctrine/Tests/Common/EventManagerTest.php
0 → 100644
View file @
9dcab5ee
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
namespace
Doctrine\Tests\Common
;
use
Doctrine\Common\EventManager
;
use
Doctrine\Common\EventArgs
;
/**
* Description of EventManagerTest
*
* @author robo
*/
class
EventManagerTest
extends
\Doctrine\Tests\DoctrineTestCase
{
/* Some pseudo events */
const
preFoo
=
'preFoo'
;
const
postFoo
=
'postFoo'
;
private
$_preFooInvoked
=
false
;
private
$_postFooInvoked
=
false
;
private
$_eventManager
;
protected
function
setUp
()
{
$this
->
_eventManager
=
new
EventManager
;
$this
->
_preFooInvoked
=
false
;
$this
->
_postFooInvoked
=
false
;
}
public
function
testInitialState
()
{
$this
->
assertEquals
(
array
(),
$this
->
_eventManager
->
getListeners
());
$this
->
assertFalse
(
$this
->
_eventManager
->
hasListeners
(
self
::
preFoo
));
$this
->
assertFalse
(
$this
->
_eventManager
->
hasListeners
(
self
::
postFoo
));
}
public
function
testAddEventListener
()
{
$this
->
_eventManager
->
addEventListener
(
array
(
'preFoo'
,
'postFoo'
),
$this
);
$this
->
assertTrue
(
$this
->
_eventManager
->
hasListeners
(
self
::
preFoo
));
$this
->
assertTrue
(
$this
->
_eventManager
->
hasListeners
(
self
::
postFoo
));
$this
->
assertEquals
(
1
,
count
(
$this
->
_eventManager
->
getListeners
(
self
::
preFoo
)));
$this
->
assertEquals
(
1
,
count
(
$this
->
_eventManager
->
getListeners
(
self
::
postFoo
)));
$this
->
assertEquals
(
2
,
count
(
$this
->
_eventManager
->
getListeners
()));
}
public
function
testDispatchEvent
()
{
$this
->
_eventManager
->
addEventListener
(
array
(
'preFoo'
,
'postFoo'
),
$this
);
$this
->
_eventManager
->
dispatchEvent
(
self
::
preFoo
);
$this
->
assertTrue
(
$this
->
_preFooInvoked
);
$this
->
assertFalse
(
$this
->
_postFooInvoked
);
}
/* Listener methods */
public
function
preFoo
(
EventArgs
$e
)
{
$this
->
_preFooInvoked
=
true
;
}
public
function
postFoo
(
EventArgs
$e
)
{
$this
->
_postFooInvoked
=
true
;
}
}
tests/Doctrine/Tests/Models/CMS/CmsUser.php
View file @
9dcab5ee
...
...
@@ -39,7 +39,7 @@ class CmsUser
*/
public
$address
;
/**
* @DoctrineManyToMany(targetEntity="CmsGroup")
* @DoctrineManyToMany(targetEntity="CmsGroup"
, cascade={"save"}
)
* @DoctrineJoinTable(name="cms_users_groups",
joinColumns={{"name"="user_id", "referencedColumnName"="id"}},
inverseJoinColumns={{"name"="group_id", "referencedColumnName"="id"}})
...
...
tests/Doctrine/Tests/ORM/EntityManagerTest.php
View file @
9dcab5ee
...
...
@@ -22,7 +22,7 @@ class EntityManagerTest extends \Doctrine\Tests\OrmTestCase
try
{
$this
->
_em
->
setFlushMode
(
'foobar'
);
$this
->
fail
(
"Setting invalid flushmode did not trigger exception."
);
}
catch
(
\Doctrine\ORM\E
xceptions\E
ntityManagerException
$expected
)
{}
}
catch
(
\Doctrine\ORM\EntityManagerException
$expected
)
{}
$this
->
_em
->
setFlushMode
(
$prev
);
}
}
\ No newline at end of file
tests/Doctrine/Tests/ORM/Functional/BasicCRUDTest.php
View file @
9dcab5ee
...
...
@@ -157,6 +157,8 @@ class BasicCRUDTest extends \Doctrine\Tests\OrmFunctionalTestCase {
public
function
testManyToManyCollectionClearing
()
{
echo
PHP_EOL
.
"MANY-MANY"
.
PHP_EOL
;
$user
=
new
CmsUser
;
$user
->
name
=
'Guilherme'
;
$user
->
username
=
'gblanco'
;
...
...
@@ -171,11 +173,17 @@ class BasicCRUDTest extends \Doctrine\Tests\OrmFunctionalTestCase {
$this
->
_em
->
save
(
$user
);
// Saves the user, cause of post-insert ID
$this
->
_em
->
flush
();
// Saves the groups, cause they're attached to a persistent entity ($user)
$this
->
_em
->
flush
();
// Check that there are indeed 10 links in the association table
$count
=
$this
->
_em
->
getConnection
()
->
execute
(
"SELECT COUNT(*) FROM cms_users_groups"
,
array
())
->
fetchColumn
();
$this
->
assertEquals
(
10
,
$count
);
//$user->groups->clear();
unset
(
$user
->
groups
);
echo
PHP_EOL
.
"FINAL FLUSH"
.
PHP_EOL
;
$this
->
_em
->
flush
();
// Check that the links in the association table have been deleted
...
...
tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php
View file @
9dcab5ee
...
...
@@ -89,7 +89,7 @@ class SingleScalarHydratorTest extends HydrationTest
$result
=
$hydrator
->
hydrateall
(
$stmt
,
$this
->
_createParserResult
(
$queryComponents
,
$tableAliasMap
));
$this
->
fail
();
}
catch
(
\Doctrine\ORM\
Exceptions
\HydrationException
$ex
)
{}
}
catch
(
\Doctrine\ORM\
Internal\Hydration
\HydrationException
$ex
)
{}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment