Creating Your Own Flash Scope
The ColdBox Flash capabilities are very flexible and you can easily create your own Flash Implementations by doing two things:
Create a CFC that inherits from
coldbox.system.web.flash.AbstractFlashScope
Implement the following functions:
clearFlash(), saveFlash(), flashExists(), and getFlash()
Implementable Methods
Method | ReturnType | Description |
clearFlash() | void | Will destroy or clear the entire flash storage structure. |
saveFlash() | void | Will be called before relocations or on demand in order to flash the storage. This method usually talks to the getScope() method to retrieve the temporary flash variables and then serialize and persist. |
flashExists() | boolean | Checks if the flash storage is available and has data in it. |
getFlash() | struct | This method needs to return a structure of flash data to reinflate and use during a request. |
Caution It is the developer's responsibility to provide consistent storage locking and synchronizations.
All of the methods must be implemented and they have their unique purposes as you read in the description. Let's see a real life example, below you can see the flash implementation for the session scope:
As you can see from the implementation, it is very straightforward to create a useful session flash RAM object.
Last updated