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

[DDC-3287] Change parent classes of some Events #1144

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Event/OnClearEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @author Roman Borschel <[email protected]>
* @author Benjamin Eberlei <[email protected]>
*/
class OnClearEventArgs extends \Doctrine\Common\EventArgs
class OnClearEventArgs extends \Doctrine\Common\Persistence\Event\OnClearEventArgs
{
/**
* @var \Doctrine\ORM\EntityManager
Expand Down
102 changes: 9 additions & 93 deletions lib/Doctrine/ORM/Event/PreUpdateEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,109 +29,25 @@
* @author Benjamin Eberlei <[email protected]>
* @since 2.0
*/
class PreUpdateEventArgs extends LifecycleEventArgs
class PreUpdateEventArgs extends \Doctrine\Common\Persistence\Event\PreUpdateEventArgs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a BC break, because it does not extend the ORM LifecycleEventArgs anymore

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this change, otherwise the PR cannot be accepted

{
/**
* @var array
*/
private $entityChangeSet;

/**
* Constructor.
*
* @param object $entity
* @param EntityManager $em
* @param array $changeSet
*/
public function __construct($entity, EntityManager $em, array &$changeSet)
{
parent::__construct($entity, $em);

$this->entityChangeSet = &$changeSet;
}

/**
* Retrieves entity changeset.
*
* @return array
*/
public function getEntityChangeSet()
{
return $this->entityChangeSet;
}

/**
* Checks if field has a changeset.
*
* @param string $field
* Retrieves associated Entity.
*
* @return boolean
* @return object
*/
public function hasChangedField($field)
public function getEntity()
{
return isset($this->entityChangeSet[$field]);
return $this->getObject();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong indentation

}

/**
* Gets the old value of the changeset of the changed field.
*
* @param string $field
*
* @return mixed
*/
public function getOldValue($field)
{
$this->assertValidField($field);

return $this->entityChangeSet[$field][0];
}

/**
* Gets the new value of the changeset of the changed field.
*
* @param string $field
*
* @return mixed
*/
public function getNewValue($field)
{
$this->assertValidField($field);

return $this->entityChangeSet[$field][1];
}

/**
* Sets the new value of this field.
*
* @param string $field
* @param mixed $value
*
* @return void
*/
public function setNewValue($field, $value)
{
$this->assertValidField($field);

$this->entityChangeSet[$field][1] = $value;
}

/**
* Asserts the field exists in changeset.
*
* @param string $field
*
* @return void
* Retrieves associated EntityManager.
*
* @throws \InvalidArgumentException
* @return \Doctrine\ORM\EntityManager
*/
private function assertValidField($field)
public function getEntityManager()
{
if ( ! isset($this->entityChangeSet[$field])) {
throw new \InvalidArgumentException(sprintf(
'Field "%s" is not a valid field of the entity "%s" in PreUpdateEventArgs.',
$field,
get_class($this->getEntity())
));
}
return $this->getObjectManager();
}
}