moved event stuff
This commit is contained in:
parent
0ef216a9b5
commit
b6642e2dce
@ -19,7 +19,7 @@
|
|||||||
* <http://www.phpdoctrine.org>.
|
* <http://www.phpdoctrine.org>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#namespace Doctrine::Common::Event;
|
#namespace Doctrine::Common;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The EventManager is the central point of Doctrine's event listener system.
|
* The EventManager is the central point of Doctrine's event listener system.
|
||||||
@ -30,7 +30,7 @@
|
|||||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
class Doctrine_EventManager
|
class Doctrine_Common_EventManager
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Map of registered listeners.
|
* Map of registered listeners.
|
||||||
@ -107,7 +107,7 @@ class Doctrine_EventManager
|
|||||||
*
|
*
|
||||||
* @param Doctrine::Common::Event::EventSubscriber $subscriber The subscriber.
|
* @param Doctrine::Common::Event::EventSubscriber $subscriber The subscriber.
|
||||||
*/
|
*/
|
||||||
public function addEventSubscriber(Doctrine_EventSubscriber $subscriber)
|
public function addEventSubscriber(Doctrine_Common_EventSubscriber $subscriber)
|
||||||
{
|
{
|
||||||
$this->addEventListener($subscriber->getSubscribedEvents(), $subscriber);
|
$this->addEventListener($subscriber->getSubscribedEvents(), $subscriber);
|
||||||
}
|
}
|
39
lib/Doctrine/Common/EventSubscriber.php
Normal file
39
lib/Doctrine/Common/EventSubscriber.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* $Id: EventListener.php 4653 2008-07-10 17:17:58Z 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>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#namespace Doctrine::Common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An EventSubscriber knows itself what events it is interested in.
|
||||||
|
* If an EventSubscriber is added to an EventManager, the manager invokes
|
||||||
|
* getSubscribedEvents() and registers the subscriber as a listener for all
|
||||||
|
* returned events.
|
||||||
|
*
|
||||||
|
* @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: 4653 $
|
||||||
|
*/
|
||||||
|
interface Doctrine_Common_EventSubscriber
|
||||||
|
{
|
||||||
|
public function getSubscribedEvents();
|
||||||
|
}
|
@ -19,7 +19,7 @@
|
|||||||
* <http://www.phpdoctrine.org>.
|
* <http://www.phpdoctrine.org>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#namespace Doctrine::ORM::Events;
|
#namespace Doctrine::Common::Events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Doctrine_Event
|
* Doctrine_Event
|
||||||
@ -32,7 +32,7 @@
|
|||||||
* @since 2.0
|
* @since 2.0
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
class Doctrine_Event
|
class Doctrine_Common_Events_Event
|
||||||
{
|
{
|
||||||
/* Event callback constants */
|
/* Event callback constants */
|
||||||
const preDelete = 'preDelete';
|
const preDelete = 'preDelete';
|
@ -175,7 +175,7 @@ class Doctrine_Connection
|
|||||||
$this->_config = new Doctrine_Configuration();
|
$this->_config = new Doctrine_Configuration();
|
||||||
}
|
}
|
||||||
if ( ! $eventManager) {
|
if ( ! $eventManager) {
|
||||||
$this->_eventManager = new Doctrine_EventManager();
|
$this->_eventManager = new Doctrine_Common_EventManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
// create platform
|
// create platform
|
||||||
|
@ -59,14 +59,14 @@ class Doctrine_ConnectionFactory
|
|||||||
* @return Connection
|
* @return Connection
|
||||||
*/
|
*/
|
||||||
public function createConnection(array $params, Doctrine_Configuration $config = null,
|
public function createConnection(array $params, Doctrine_Configuration $config = null,
|
||||||
Doctrine_EventManager $eventManager = null)
|
Doctrine_Common_EventManager $eventManager = null)
|
||||||
{
|
{
|
||||||
// create default config and event manager, if not set
|
// create default config and event manager, if not set
|
||||||
if ( ! $config) {
|
if ( ! $config) {
|
||||||
$config = new Doctrine_Configuration();
|
$config = new Doctrine_Configuration();
|
||||||
}
|
}
|
||||||
if ( ! $eventManager) {
|
if ( ! $eventManager) {
|
||||||
$eventManager = new Doctrine_EventManager();
|
$eventManager = new Doctrine_Common_EventManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for existing pdo object
|
// check for existing pdo object
|
||||||
|
@ -149,7 +149,7 @@ class Doctrine_EntityManager
|
|||||||
* @param string $name
|
* @param string $name
|
||||||
*/
|
*/
|
||||||
protected function __construct(Doctrine_Connection $conn, $name, Doctrine_Configuration $config,
|
protected function __construct(Doctrine_Connection $conn, $name, Doctrine_Configuration $config,
|
||||||
Doctrine_EventManager $eventManager)
|
Doctrine_Common_EventManager $eventManager)
|
||||||
{
|
{
|
||||||
$this->_conn = $conn;
|
$this->_conn = $conn;
|
||||||
$this->_name = $name;
|
$this->_name = $name;
|
||||||
|
@ -11,7 +11,7 @@ class Doctrine_OrmTestSuite extends Doctrine_TestSuite
|
|||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
$config = new Doctrine_Configuration();
|
$config = new Doctrine_Configuration();
|
||||||
$eventManager = new Doctrine_EventManager();
|
$eventManager = new Doctrine_Common_EventManager();
|
||||||
$connectionOptions = array(
|
$connectionOptions = array(
|
||||||
'driverClass' => 'Doctrine_ConnectionMock',
|
'driverClass' => 'Doctrine_ConnectionMock',
|
||||||
'user' => 'john',
|
'user' => 'john',
|
||||||
|
@ -34,13 +34,13 @@ class Doctrine_EntityManagerMock extends Doctrine_EntityManager
|
|||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
public static function create($conn, $name, Doctrine_Configuration $config = null,
|
public static function create($conn, $name, Doctrine_Configuration $config = null,
|
||||||
Doctrine_EventManager $eventManager = null)
|
Doctrine_Common_EventManager $eventManager = null)
|
||||||
{
|
{
|
||||||
if (is_null($config)) {
|
if (is_null($config)) {
|
||||||
$config = new Doctrine_Configuration();
|
$config = new Doctrine_Configuration();
|
||||||
}
|
}
|
||||||
if (is_null($eventManager)) {
|
if (is_null($eventManager)) {
|
||||||
$eventManager = new Doctrine_EventManager();
|
$eventManager = new Doctrine_Common_EventManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Doctrine_EntityManagerMock($conn, $name, $config, $eventManager);
|
return new Doctrine_EntityManagerMock($conn, $name, $config, $eventManager);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user