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: use Nette;
11:
12:
13: /**
14: * @deprecated
15: */
16: abstract class FreezableObject extends Object implements IFreezable
17: {
18: /** @var bool */
19: private $frozen = FALSE;
20:
21:
22: /**
23: * Makes the object unmodifiable.
24: * @return void
25: */
26: public function freeze()
27: {
28: $this->frozen = TRUE;
29: }
30:
31:
32: /**
33: * Is the object unmodifiable?
34: * @return bool
35: */
36: public function isFrozen()
37: {
38: return $this->frozen;
39: }
40:
41:
42: /**
43: * Creates a modifiable clone of the object.
44: * @return void
45: */
46: public function __clone()
47: {
48: $this->frozen = FALSE;
49: }
50:
51:
52: /**
53: * @return void
54: */
55: protected function updating()
56: {
57: if ($this->frozen) {
58: $class = get_class($this);
59: throw new InvalidStateException("Cannot modify a frozen object $class.");
60: }
61: }
62:
63: }
64: