Packages

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • None
  • PHP

Classes

  • ArrayHash
  • ArrayList
  • Callback
  • DateTime53
  • Framework
  • FreezableObject
  • Image
  • Object
  • ObjectMixin

Interfaces

  • IFreezable

Exceptions

  • ArgumentOutOfRangeException
  • DeprecatedException
  • DirectoryNotFoundException
  • FatalErrorException
  • FileNotFoundException
  • InvalidStateException
  • IOException
  • MemberAccessException
  • NotImplementedException
  • NotSupportedException
  • StaticClassException
  • UnknownImageFileException
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (http://nette.org)
 5:  *
 6:  * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
 7:  *
 8:  * For the full copyright and license information, please view
 9:  * the file license.txt that was distributed with this source code.
10:  * @package Nette
11:  */
12: 
13: 
14: 
15: /**
16:  * Defines an object that has a modifiable and a read-only (frozen) state.
17:  *
18:  * @author     David Grudl
19:  *
20:  * @property-read bool $frozen
21:  * @package Nette
22:  */
23: abstract class FreezableObject extends Object implements IFreezable
24: {
25:     /** @var bool */
26:     private $frozen = FALSE;
27: 
28: 
29: 
30:     /**
31:      * Makes the object unmodifiable.
32:      * @return void
33:      */
34:     public function freeze()
35:     {
36:         $this->frozen = TRUE;
37:     }
38: 
39: 
40: 
41:     /**
42:      * Is the object unmodifiable?
43:      * @return bool
44:      */
45:     final public function isFrozen()
46:     {
47:         return $this->frozen;
48:     }
49: 
50: 
51: 
52:     /**
53:      * Creates a modifiable clone of the object.
54:      * @return void
55:      */
56:     public function __clone()
57:     {
58:         $this->frozen = FALSE;
59:     }
60: 
61: 
62: 
63:     /**
64:      * @return void
65:      */
66:     protected function updating()
67:     {
68:         if ($this->frozen) {
69:             $class = get_class($this);
70:             throw new InvalidStateException("Cannot modify a frozen object $class.");
71:         }
72:     }
73: 
74: }
75: 
Nette Framework 2.0.0 (for PHP 5.2, un-prefixed) API API documentation generated by ApiGen 2.7.0