1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (https://nette.org)
5: * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6: */
7:
8: namespace Nette;
9:
10:
11: /**
12: * @deprecated
13: */
14: abstract class FreezableObject extends Object implements IFreezable
15: {
16: /** @var bool */
17: private $frozen = FALSE;
18:
19:
20: /**
21: * Makes the object unmodifiable.
22: * @return void
23: */
24: public function freeze()
25: {
26: $this->frozen = TRUE;
27: }
28:
29:
30: /**
31: * Is the object unmodifiable?
32: * @return bool
33: */
34: public function isFrozen()
35: {
36: return $this->frozen;
37: }
38:
39:
40: /**
41: * Creates a modifiable clone of the object.
42: * @return void
43: */
44: public function __clone()
45: {
46: $this->frozen = FALSE;
47: }
48:
49:
50: /**
51: * @return void
52: */
53: protected function updating()
54: {
55: if ($this->frozen) {
56: $class = get_class($this);
57: throw new InvalidStateException("Cannot modify a frozen object $class.");
58: }
59: }
60:
61: }
62: