PHP 클래스 JSONStorage

Provides a very simple way to persistent JSON storage. Acts as a registry key saver. Example of use: $j = new JSONStorage(); $j->addRegistry('custom'); echo $j->registryExists('custom'); $j->setData('mydata','super','custom'); $j->save(); $j->load(); echo $j->getData('super','custom');
상속: extends CComponent
파일 보기 프로젝트 열기: yinhe/yincart

보호된 프로퍼티들

프로퍼티 타입 설명
$data the data of the registry
$default the name of the default registry
$dirty whether the registry has changed or not
$filename the filename to save the values to
$path the full path to the directory with read/write access to save the registry to. If none set, the component will used the application's runtime folder

공개 메소드들

메소드 설명
__construct ( null $registry = null ) class constructor
__destruct ( ) class destructor - flush data
addRegistry ( string $registry ) : boolean Add new collection name
getData ( string $key, null $registry = null ) : mixed Retrieves a data value from the registry
getFile ( ) : string Property get file
getLength ( null $registry = null ) : integer Retrieves the number of keys in registry
getPath ( ) : string Property get path
getRegistry ( string $registry ) : mixed | null Retrieves a registry collection based on its name
load ( ) Loads registry data into memory
onAfterSave ( CEvent $event ) Fires after the registry has been saved
onBeforeSave ( CEvent $event ) Fires before registry has been saved
registryExists ( string $registry ) : boolean Checkes whether a collection exists (registry)
removeData ( string $key, null $registry = null ) : boolean Removes data from a key in the registry
removeRegistry ( string $registry ) : boolean Remove an existing collection and all associated data
save ( ) Saves registry data to the file
setData ( string $key, array $data, null $registry = null ) : boolean Saves data to the registry
setFile ( string $file ) Property set file
setPath ( string $path ) : boolean Property set path
verify ( ) : boolean Verifies data integrity

비공개 메소드들

메소드 설명
decode ( string $data ) : mixed JSON decodes the data
encode ( string $data ) : string JSON encodes the data
flush ( ) : boolean Saves the global registry to the file

메소드 상세

__construct() 공개 메소드

class constructor
public __construct ( null $registry = null )
$registry null

__destruct() 공개 메소드

class destructor - flush data
public __destruct ( )

addRegistry() 공개 메소드

Add new collection name
public addRegistry ( string $registry ) : boolean
$registry string the name of the registry (collection) to create
리턴 boolean

getData() 공개 메소드

Retrieves a data value from the registry
public getData ( string $key, null $registry = null ) : mixed
$key string the name of the key that holds the data
$registry null the registry name
리턴 mixed the data in the key value, null otherwise

getFile() 공개 메소드

Property get file
public getFile ( ) : string
리턴 string filename

getLength() 공개 메소드

Retrieves the number of keys in registry
public getLength ( null $registry = null ) : integer
$registry null the registry name
리턴 integer the data length

getPath() 공개 메소드

Property get path
public getPath ( ) : string
리턴 string

getRegistry() 공개 메소드

Retrieves a registry collection based on its name
public getRegistry ( string $registry ) : mixed | null
$registry string the name of the registry to retrieve
리턴 mixed | null the registry, null if none found

load() 공개 메소드

Loads registry data into memory
public load ( )

onAfterSave() 공개 메소드

Fires after the registry has been saved
public onAfterSave ( CEvent $event )
$event CEvent

onBeforeSave() 공개 메소드

Fires before registry has been saved
public onBeforeSave ( CEvent $event )
$event CEvent

registryExists() 공개 메소드

Checkes whether a collection exists (registry)
public registryExists ( string $registry ) : boolean
$registry string the name of the registry to check existence
리턴 boolean

removeData() 공개 메소드

Removes data from a key in the registry
public removeData ( string $key, null $registry = null ) : boolean
$key string the key name that holds the data to remove
$registry null the registry name
리턴 boolean true if successful, false otherwise

removeRegistry() 공개 메소드

Remove an existing collection and all associated data
public removeRegistry ( string $registry ) : boolean
$registry string the name of the registry to remove
리턴 boolean

save() 공개 메소드

Saves registry data to the file
public save ( )

setData() 공개 메소드

Saves data to the registry
public setData ( string $key, array $data, null $registry = null ) : boolean
$key string the name of the key that will hold the data
$data array the data to save
$registry null the name of the registry
리턴 boolean

setFile() 공개 메소드

Property set file
public setFile ( string $file )
$file string the filename to save the registry to

setPath() 공개 메소드

Property set path
public setPath ( string $path ) : boolean
$path string the full path of the directory with read/write access to save the registry file to
리턴 boolean

verify() 공개 메소드

Verifies data integrity
public verify ( ) : boolean
리턴 boolean

프로퍼티 상세

$data 보호되어 있는 프로퍼티

the data of the registry
protected $data

$default 보호되어 있는 프로퍼티

the name of the default registry
protected $default

$dirty 보호되어 있는 프로퍼티

whether the registry has changed or not
protected $dirty

$filename 보호되어 있는 프로퍼티

the filename to save the values to
protected $filename

$path 보호되어 있는 프로퍼티

the full path to the directory with read/write access to save the registry to. If none set, the component will used the application's runtime folder
protected $path