Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event refactoring to use doctrine commons 2.4 events where possible #288

Merged
merged 4 commits into from May 27, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,20 @@
Changelog
=========

2013-05-27
----------

* #288: Event refactoring to use doctrine commons 2.4 events where possible
Use the doctrine common event argument classes where possible instead of
custom classes. The classes `Doctrine\ODM\PHPCR\Event\LifecycleEventArgs`
and `Doctrine\ODM\PHPCR\Event\ManagerEventArgs` and
`Doctrine\ODM\PHPCR\Event\LoadClassMetadataEventArgs` are deprecated and
will be deleted soon. Switch your code to depend on the classes in namespace
`Doctrine\Common\Persistence\Event\` instead.
The only PHPCR-ODM specific event argument that will remain is MoveEventArgs
because it has additional parameters and the move operation is PHPCR-ODM
specific.

2013-05-13
----------

Expand Down
34 changes: 16 additions & 18 deletions lib/Doctrine/ODM/PHPCR/Event/LifecycleEventArgs.php
Expand Up @@ -19,34 +19,32 @@

namespace Doctrine\ODM\PHPCR\Event;

class LifecycleEventArgs extends \Doctrine\Common\EventArgs
{
private $document;

/**
* @var \Doctrine\ODM\PHPCR\DocumentManager
*/
private $dm;

public function __construct($document, $dm)
{
$this->document = $document;
$this->dm = $dm;
}
use Doctrine\Common\Persistence\Event\LifecycleEventArgs as BaseLifecycleEventArgs;

/**
* @deprecated Will be dropped in favor of Doctrine\Common\Persistence\Event\LifecycleEventArgs
*/
class LifecycleEventArgs extends BaseLifecycleEventArgs
{
/**
* @return object
* @deprecated Will be dropped in favor of getObject in 1.0
*
* @return object
*/
public function getDocument()
{
return $this->document;
trigger_error('The getDocument method is deprecated, use getObject instead', E_USER_DEPRECATED);
return $this->getObject();
}

/**
* @return \Doctrine\ODM\PHPCR\DocumentManager
* @deprecated Will be dropped in favor of getObjectManager in 1.0
*
* @return \Doctrine\ODM\PHPCR\DocumentManager
*/
public function getDocumentManager()
{
return $this->dm;
trigger_error('The getDocumentManager method is deprecated, use getObjectManager instead', E_USER_DEPRECATED);
return $this->getObjectManager();
}
}
48 changes: 9 additions & 39 deletions lib/Doctrine/ODM/PHPCR/Event/LoadClassMetadataEventArgs.php
Expand Up @@ -19,51 +19,21 @@

namespace Doctrine\ODM\PHPCR\Event;

use Doctrine\Common\EventArgs;
use Doctrine\ODM\PHPCR\Mapping\ClassMetadata;
use Doctrine\ODM\PHPCR\DocumentManager;
use Doctrine\Common\Persistence\Event\LoadClassMetadataEventArgs as BaseLoadClassMetadataEventArgs;

class LoadClassMetadataEventArgs extends EventArgs
/**
* @deprecated Will be dropped in favor of Doctrine\Common\Persistence\Event\LoadClassMetadataEventArgs
*/
class LoadClassMetadataEventArgs extends BaseLoadClassMetadataEventArgs
{
/**
* @var \Doctrine\PHPCR\ODM\Mapping\ClassMetadata
*/
private $classMetadata;

/**
* @var \Doctrine\PHPCR\ODM\DocumentManager
*/
private $dm;

/**
* Constructor.
*
* @param \Doctrine\PHPCR\ODM\Mapping\ClassMetadataInfo $classMetadata
* @param \Doctrine\PHPCR\ODM\DocumentManager $dm
*/
public function __construct(ClassMetadata $classMetadata, DocumentManager $dm)
{
$this->classMetadata = $classMetadata;
$this->dm = $dm;
}

/**
* Retrieve associated ClassMetadata.
*
* @return \Doctrine\PHPCR\ODM\Mapping\ClassMetadataInfo
*/
public function getClassMetadata()
{
return $this->classMetadata;
}

/**
* Retrieve associated DocumentManager.
* @deprecated Will be dropped in favor of getObjectManager in 1.0
*
* @return \Doctrine\PHPCR\ODM\DocumentManager
* @return \Doctrine\ODM\PHPCR\DocumentManager
*/
public function getDocumentManager()
{
return $this->dm;
trigger_error('The getDocumentManager method is deprecated, use getObjectManager instead', E_USER_DEPRECATED);
return $this->getObjectManager();
}
}
Expand Up @@ -15,32 +15,24 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/

namespace Doctrine\ODM\PHPCR\Event;

use Doctrine\Common\EventArgs;
use Doctrine\Common\Persistence\Event\ManagerEventArgs as BaseManagerEventArgs;

class OnFlushEventArgs extends EventArgs
/**
* @deprecated Will be dropped in favor of Doctrine\Common\Persistence\Event\ManagerEventArgs
*/
class ManagerEventArgs extends BaseManagerEventArgs
{
/**
* @var \Doctrine\ODM\PHPCR\DocumentManager
*/
private $dm;

/**
* @param \Doctrine\ODM\PHPCR\DocumentManager $dm
*/
public function __construct($dm)
{
$this->dm = $dm;
}

/**
* @return \Doctrine\ODM\PHPCR\DocumentManager
* @deprecated Will be dropped in favor of getObjectManager in 1.0
* @return \Doctrine\ODM\PHPCR\DocumentManager
*/
public function getDocumentManager()
{
return $this->dm;
trigger_error('The getDocumentManager method is deprecated, use getObjectManager instead', E_USER_DEPRECATED);
return $this->getObjectManager();
}
}
56 changes: 13 additions & 43 deletions lib/Doctrine/ODM/PHPCR/Event/MoveEventArgs.php
Expand Up @@ -20,21 +20,10 @@

namespace Doctrine\ODM\PHPCR\Event;

/**
* MoveEventArgs
*/
class MoveEventArgs extends \Doctrine\Common\EventArgs
{
/**
* @var object
*/
private $document;

/**
* @var \Doctrine\ODM\PHPCR\DocumentManager
*/
private $dm;
use Doctrine\ODM\PHPCR\DocumentManager;

class MoveEventArgs extends LifecycleEventArgs
{
/**
* @var string
*/
Expand All @@ -48,41 +37,21 @@ class MoveEventArgs extends \Doctrine\Common\EventArgs
/**
* Constructor
*
* @param object $document The object
* @param \Doctrine\ODM\PHPCR\DocumentManager $dm The document manager
* @param string $sourcePath The source path
* @param string $targetPath The target path
* @param object $document
* @param DocumentManager $dm
* @param string $sourcePath Path the document is moved from
* @param string $targetPath Path the document is moved to, including target name
*/
public function __construct($document, $dm, $sourcePath, $targetPath)
public function __construct($document, DocumentManager $dm, $sourcePath, $targetPath)
{
$this->document = $document;
$this->dm = $dm;
parent::__construct($document, $dm);
$this->sourcePath = $sourcePath;
$this->targetPath = $targetPath;
}

/**
* Get the document
*
* @return object
*/
public function getDocument()
{
return $this->document;
}

/**
* Get the document manager
*
* @return \Doctrine\ODM\PHPCR\DocumentManager
*/
public function getDocumentManager()
{
return $this->dm;
}

/**
* Get the source path
* Get the path this document is being moved away from, including the
* document name.
*
* @return string
*/
Expand All @@ -92,7 +61,8 @@ public function getSourcePath()
}

/**
* Get the target path
* Get the path this document is being moved to, including the new document
* name.
*
* @return string
*/
Expand Down
46 changes: 0 additions & 46 deletions lib/Doctrine/ODM/PHPCR/Event/OnClearEventArgs.php

This file was deleted.

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

This file was deleted.