OptimisticLockException.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  */
12 
13 /**
14  * OptimisticLockException signals an exception when trying to create an
15  * optimistic lock.
16  *
17  * @author ingo herwig <ingo@wemove.com>
18  */
19 class OptimisticLockException extends \Exception {
20 
21  private $currentState = null;
22 
23  /**
24  * Constructor
25  * @param $currentState PersistentObject instance representing the current object state
26  * or null, if the object is deleted
27  */
28  public function __construct($currentState) {
29  $this->currentState = $currentState;
30 
31  $msg = '';
32  if ($currentState == null) {
33  $msg = 'The object was deleted by another user.';
34  }
35  else {
36  $msg = 'The object was modified by another user.';
37  }
38  parent::__construct($msg);
39  }
40 
41  /**
42  * Get the current object
43  * @return PersistentObject instance
44  */
45  public function getCurrentState() {
46  return $this->currentState;
47  }
48 }
49 ?>
OptimisticLockException signals an exception when trying to create an optimistic lock.