PersistenceEvent.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2020 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of the MIT License.
7  *
8  * See the LICENSE file distributed with this work for
9  * additional information.
10  */
11 namespace wcmf\lib\persistence;
12 
15 
16 /**
17  * PersistentEvent signals create/update/delete operations
18  * on a persistent entity.
19  *
20  * @author ingo herwig <ingo@wemove.com>
21  */
22 class PersistenceEvent extends Event {
23 
24  const NAME = __CLASS__;
25 
26  private $object = null;
27  private $action = null;
28  private $oldOid = null;
29 
30  /**
31  * Constructor.
32  * @param $object PersistentObject instance.
33  * @param $action One of the PersistenceAction values.
34  * @param $oldOid The object id of the object before the action was performed (optional)
35  */
36  public function __construct(PersistentObject $object, $action, $oldOid=null) {
37  $this->object = $object;
38  $this->action = $action;
39  $this->oldOid = $oldOid == null ? $object->getOID() : $oldOid;
40  }
41 
42  /**
43  * Get the object involved.
44  * @return PersistentObject instance
45  */
46  public function getObject() {
47  return $this->object;
48  }
49 
50  /**
51  * Get the action.
52  * @return PersistenceAction value
53  */
54  public function getAction() {
55  return $this->action;
56  }
57 
58  /**
59  * Get the old object id.
60  * @return ObjectId
61  */
62  public function getOldOid() {
63  return $this->oldOid;
64  }
65 }
66 ?>
getObject()
Get the object involved.
getOID()
Get the object id of the PersistentObject.
Persistence layer related interfaces and classes.
Definition: namespaces.php:42
Event is the base class for all events.
Definition: Event.php:18
PersistentEvent signals create/update/delete operations on a persistent entity.
__construct(PersistentObject $object, $action, $oldOid=null)
Constructor.
PersistentObject defines the interface of all persistent objects.