| | 92 | * Pre-serialization callback. |
| | 93 | * |
| | 94 | * Will set the name of the context instead of the instance, and the name of |
| | 95 | * the output type instead of the instance. Both will be restored by __wakeup |
| | 96 | * |
| | 97 | * @author David Zuelke <dz@bitxtender.com> |
| | 98 | * @since 0.11.0 |
| | 99 | */ |
| | 100 | public function __sleep() |
| | 101 | { |
| | 102 | $this->contextName = $this->context->getName(); |
| | 103 | $this->outputTypeName = $this->outputType->getName(); |
| | 104 | $arr = get_object_vars($this); |
| | 105 | unset($arr['context'], $arr['outputType']); |
| | 106 | return array_keys($arr); |
| | 107 | } |
| | 108 | |
| | 109 | /** |
| | 110 | * Post-unserialization callback. |
| | 111 | * |
| | 112 | * Will restore the context and output type instances based on their names set |
| | 113 | * by __sleep. |
| | 114 | * |
| | 115 | * @author David Zuelke <dz@bitxtender.com> |
| | 116 | * @since 0.11.0 |
| | 117 | */ |
| | 118 | public function __wakeup() |
| | 119 | { |
| | 120 | $this->context = AgaviContext::getInstance($this->contextName); |
| | 121 | $this->outputType = $this->context->getController()->getOutputType($this->outputTypeName); |
| | 122 | unset($this->contextName, $this->outputTypeName); |
| | 123 | } |
| | 124 | |
| | 125 | /** |