Skip to content

Commit

Permalink
Removed extra event classes, made more similar to Commons 2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
dantleech committed Mar 1, 2013
1 parent 30db625 commit 5708443
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 223 deletions.
16 changes: 16 additions & 0 deletions lib/Doctrine/ODM/PHPCR/Event/LifecycleEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,20 @@ public function getDocumentManager()
{
return $this->dm;
}

/**
* @return object
*/
public function getObject()
{
return $this->object;
}

/**
* @return \Doctrine\ODM\PHPCR\DocumentManager
*/
public function getObjectManager()
{
return $this->dm;
}
}
10 changes: 10 additions & 0 deletions lib/Doctrine/ODM/PHPCR/Event/LoadClassMetadataEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,14 @@ public function getDocumentManager()
{
return $this->dm;
}

/**
* Retrieve associated ObjectManager.
*
* @return \Doctrine\PHPCR\ODM\ObjectManager
*/
public function getObjectManager()
{
return $this->dm;
}
}
46 changes: 0 additions & 46 deletions lib/Doctrine/ODM/PHPCR/Event/OnClearEventArgs.php

This file was deleted.

46 changes: 0 additions & 46 deletions lib/Doctrine/ODM/PHPCR/Event/OnFlushEventArgs.php

This file was deleted.

51 changes: 0 additions & 51 deletions lib/Doctrine/ODM/PHPCR/Event/PostFlushEventArgs.php

This file was deleted.

46 changes: 0 additions & 46 deletions lib/Doctrine/ODM/PHPCR/Event/PreFlushEventArgs.php

This file was deleted.

12 changes: 6 additions & 6 deletions lib/Doctrine/ODM/PHPCR/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@
use Doctrine\ODM\PHPCR\Exception\MissingTranslationException;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ODM\PHPCR\Event\LifecycleEventArgs;
use Doctrine\ODM\PHPCR\Event\OnFlushEventArgs;
use Doctrine\ODM\PHPCR\Event\LifecycleEventArgs;
use Doctrine\ODM\PHPCR\Event\PreFlushEventArgs;
use Doctrine\ODM\PHPCR\Event\PostFlushEventArgs;
use Doctrine\ODM\PHPCR\Event\OnClearEventArgs;
use Doctrine\ODM\PHPCR\Event\MoveEventArgs;
use Doctrine\ODM\PHPCR\Proxy\Proxy;

Expand All @@ -45,6 +44,7 @@
use PHPCR\UnsupportedRepositoryOperationException;
use PHPCR\RepositoryException;
use PHPCR\Util\UUIDHelper;
use Doctrine\ODM\PHPCR\Event\ManagerEventArgs;

/**
* Unit of work class
Expand Down Expand Up @@ -1615,7 +1615,7 @@ public function commit($document = null)
{
// Raise preFlush
if ($this->evm->hasListeners(Event::preFlush)) {
$this->evm->dispatchEvent(Event::preFlush, new PreFlushEventArgs($this->dm));
$this->evm->dispatchEvent(Event::preFlush, new ManagerEventArgs($this->dm));
}

if ($document === null) {
Expand All @@ -1629,7 +1629,7 @@ public function commit($document = null)
}

if ($this->evm->hasListeners(Event::onFlush)) {
$this->evm->dispatchEvent(Event::onFlush, new OnFlushEventArgs($this->dm));
$this->evm->dispatchEvent(Event::onFlush, new ManagerEventArgs($this->dm));
}

try {
Expand Down Expand Up @@ -1680,7 +1680,7 @@ public function commit($document = null)

// Raise postFlush
if ($this->evm->hasListeners(Event::postFlush)) {
$this->evm->dispatchEvent(Event::postFlush, new PostFlushEventArgs($this->dm));
$this->evm->dispatchEvent(Event::postFlush, new ManagerEventArgs($this->dm));
}

$this->documentTranslations =
Expand Down Expand Up @@ -2507,7 +2507,7 @@ public function clear()
$this->documentVersion = array();

if ($this->evm->hasListeners(Event::onClear)) {
$this->evm->dispatchEvent(Event::onClear, new OnClearEventArgs($this->dm));
$this->evm->dispatchEvent(Event::onClear, new ManagerEventArgs($this->dm));
}

$this->session->refresh(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
<?php

use Doctrine\ODM\PHPCR\Event\PostFlushEventArgs;
use Doctrine\ODM\PHPCR\Event\ManagerEventArgs;


class PostFlushEventArgsTest extends \PHPUnit_Framework_TestCase
class ManagerEventArgsTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
$this->dm = $this->getMockBuilder('Doctrine\ODM\PHPCR\DocumentManager')
->disableOriginalConstructor()
->getMock();
$this->postFlushEventArgs = new PostFlushEventArgs($this->dm);
$this->postFlushEventArgs = new ManagerEventArgs($this->dm);
}

public function testGetDocumentManager()
{
$res = $this->postFlushEventArgs->getDocumentManager();
$this->assertSame($this->dm, $res);
}

public function testGetObjectManager()
{
$res = $this->postFlushEventArgs->getObjectManager();
$this->assertSame($this->dm, $res);
}
}
21 changes: 0 additions & 21 deletions tests/Doctrine/Tests/ODM/PHPCR/Event/PreFlushEventArgsTest.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase;
use Doctrine\Tests\Models\CMS\CmsPage;
use Doctrine\Tests\Models\CMS\CmsItem;
use Doctrine\ODM\PHPCR\Event\PostFlushEventArgs;
use Doctrine\ODM\PHPCR\Event\PreFlushEventArgs;
use Doctrine\ODM\PHPCR\Event\ManagerEventArgs;

class EventManagerTest extends PHPCRFunctionalTestCase
{
Expand Down Expand Up @@ -213,12 +212,12 @@ public function onFlush(EventArgs $e)
$this->onFlush = true;
}

public function postFlush(PostFlushEventArgs $e)
public function postFlush(ManagerEventArgs $e)
{
$this->postFlush = true;
}

public function preFlush(PreFlushEventArgs $e)
public function preFlush(ManagerEventArgs $e)
{
$this->preFlush = true;
}
Expand Down

0 comments on commit 5708443

Please sign in to comment.