Gallery3:Developer Handbook:Libraries - Gallery Codex
Personal tools

Gallery3:Developer Handbook:Libraries

From Gallery Codex

Libraries

A library is a concept in the Kohana framework. It’s similar to a helper in that it contains helpful methods grouped around a single concept. The difference between libraries and helpers is that libraries are not static. You must create an instance of a library in order to use it. This allows you to initialize a library with relevant data and then call a series of functions on it. Fore more information including detailed examples, refer to Kohana’s documentation on Libraries.

Note that library class names must start with an uppercase letter for the Kohana Cascading Filesystem to find them properly.

A typical pattern in Kohana is that libraries can use drivers to support multiple implementations for a common interface. For example, the authentication system is implemented in the IdentityProvider class in modules/gallery/libraries but the authentication system is designed to be modular so that you can pick your own preferred way to authenticate. There is a driver interface in modules/gallery/libraries/drivers/IdentityProvider.php and then the user module has its own implementation of this interface in modules/user/libraries/drivers/IdentityProvider/Gallery.php