Phalcon\Registry is an object oriented array. It extends Phalcon\Collection but cannot be extended itself since all of its methods are declared final. It offers speed, as well as implementations of various PHP interfaces. These are:
Using get() offers three extra parameters. When $defaultValue is defined in the call and the element is not found, $defaultValue will be returned. 默认情况下$insensitive被设置为true，使得集合中的搜索不区分大小写。 Setting this value to false will make the search for the element in a case sensitive manner. The cast parameter accepts a string that defines what the returned value will be casted. The available values are:
To check whether an element exists or not in the collection, you can use the following:
The \Serializable and \JsonSerializable interfaces expose methods that allow you to serialize and unserialize the object. serialize() and unserialize() use PHP’s serialize and unserialize functions. jsonSerialize() returns an array which can be used with json_encode to serialize the object.
Phalcon\Registry also exposes two transformation methods: toArray() and toJson(int $options). toArray() returns the object transformed as an array. This method returns the same array as jsonSerialize().
toJson(int $options) returns a JSON representation of the object. It uses json_encode internally and accepts a parameter, which represents the flags that json_encode accepts. By default the options are set up with the value 74, (RFC4327) which translates to:
You can pass any valid flags to the method according to your needs.