class PreUpdateEventArgs in Plug 7
Class that holds event arguments for a preUpdate event.
@author Guilherme Blanco <guilehrmeblanco@hotmail.com> @author Roman Borschel <roman@code-factory.org> @author Benjamin Eberlei <kontakt@beberlei.de> @since 2.2
Hierarchy
- class \Doctrine\Common\EventArgs
- class \Doctrine\Common\Persistence\Event\LifecycleEventArgs
- class \Doctrine\Common\Persistence\Event\PreUpdateEventArgs
- class \Doctrine\Common\Persistence\Event\LifecycleEventArgs
Expanded class hierarchy of PreUpdateEventArgs
File
- lib/
doctrine/ common/ lib/ Doctrine/ Common/ Persistence/ Event/ PreUpdateEventArgs.php, line 32
Namespace
Doctrine\Common\Persistence\EventView source
class PreUpdateEventArgs extends LifecycleEventArgs {
/**
* @var array
*/
private $entityChangeSet;
/**
* Constructor.
*
* @param object $entity
* @param ObjectManager $objectManager
* @param array $changeSet
*/
public function __construct($entity, ObjectManager $objectManager, array &$changeSet) {
parent::__construct($entity, $objectManager);
$this->entityChangeSet =& $changeSet;
}
/**
* Retrieves the entity changeset.
*
* @return array
*/
public function getEntityChangeSet() {
return $this->entityChangeSet;
}
/**
* Checks if field has a changeset.
*
* @param string $field
*
* @return boolean
*/
public function hasChangedField($field) {
return isset($this->entityChangeSet[$field]);
}
/**
* 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
*
* @throws \InvalidArgumentException
*/
private function assertValidField($field) {
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())));
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EventArgs:: |
private static | property | Single instance of EventArgs. | |
EventArgs:: |
public static | function | Gets the single, empty and immutable EventArgs instance. | |
LifecycleEventArgs:: |
private | property | ||
LifecycleEventArgs:: |
private | property | ||
LifecycleEventArgs:: |
public | function | Retrieves the associated entity. | |
LifecycleEventArgs:: |
public | function | Retrieves the associated object. | |
LifecycleEventArgs:: |
public | function | Retrieves the associated ObjectManager. | |
PreUpdateEventArgs:: |
private | property | ||
PreUpdateEventArgs:: |
private | function | Asserts the field exists in changeset. | |
PreUpdateEventArgs:: |
public | function | Retrieves the entity changeset. | |
PreUpdateEventArgs:: |
public | function | Gets the new value of the changeset of the changed field. | |
PreUpdateEventArgs:: |
public | function | Gets the old value of the changeset of the changed field. | |
PreUpdateEventArgs:: |
public | function | Checks if field has a changeset. | |
PreUpdateEventArgs:: |
public | function | Sets the new value of this field. | |
PreUpdateEventArgs:: |
public | function |
Constructor. Overrides LifecycleEventArgs:: |