68 self::REGISTRY => array(
83 if (null === $this->path) {
84 $this->
setPath(Yii::app()->getRuntimePath());
86 $this->
setFile($this->filename);
95 $this->
default = $registry;
114 $this->raiseEvent(
'onBeforeSave', $event);
124 $this->raiseEvent(
'onAfterSave', $event);
138 $this->path = substr(
$path, -1) == DIRECTORY_SEPARATOR ?
$path :
$path . DIRECTORY_SEPARATOR;
141 throw new Exception(
'"Path" must be a writable directory.');
160 $this->filename = $this->path . $file;
178 $registry = function_exists(
'json_encode')
179 ? json_encode($this->data[self::REGISTRY])
181 $this->data[self::REGISTRY]
183 return $this->data[
self::META][
"hash"] == md5($registry);
193 if (file_exists($this->
getFile())) {
195 if (strlen(
$json) == 0) {
201 if ($this->data === null) {
202 throw new Exception(
'Error while trying to decode ' . $this->
getFile() .
'.');
206 throw new Exception($this->
getFile() .
' failed checksum validation.');
216 if ($this->hasEventHandler(
'onBeforeSave')) {
220 if ($this->hasEventHandler(
'onAfterSave')) {
236 if ($registry == null) {
239 if (is_string($key . $registry) && $this->
registryExists($registry)) {
255 public function getData($key, $registry = null)
257 if ($registry == null) {
260 if (is_string($key . $registry) && $this->
registryExists($registry)) {
261 if (array_key_exists($key, $this->data[self::REGISTRY][$registry])) {
278 if ($registry == null) {
282 if (is_string($key . $registry) && $this->
registryExists($registry)) {
283 if (array_key_exists($key, $this->data[self::REGISTRY][$registry])) {
284 unset($this->data[self::REGISTRY][$registry][$key]);
301 if ($registry == null) {
305 return count($this->data[self::REGISTRY][$registry]);
331 return array_key_exists($registry, $this->data[self::REGISTRY]);
361 unset($this->data[self::REGISTRY][$registry]);
376 if ($this->dirty ==
false) {
381 $registry = $this->
encode($this->data[self::REGISTRY]);
389 throw new Exception(strtr(
390 'Unable to write back to {FILE}. Data will be lost!',
391 array(
'{FILE}' => $this->
getFile())