Gallery3:Developer Handbook:Kohana Cascading Filesystem - Gallery Codex
Personal tools

Gallery3:Developer Handbook:Kohana Cascading Filesystem

From Gallery Codex

Kohana Cascading Filesystem

Gallery 3 makes heavy use of the Kohana Cascading Filesystem, which is designed to allow you to not worry about finding and including code before you use it. When your code refers to a helper, Kohana searches all the helpers directories in order until it finds the helper that you’re referring to, auto-loads this class for you and then calls the method you’re referring to. In order for this to work, Kohana has to know exactly where to look.

Supposing you have the following modules in your Gallery 3 install and they are activated in the following order: alpha, beta, gamma.

 modules
 ├── alpha
 │   └── helpers
 │       ├── chart
 │       └── chart.php
 ├── beta
 │   ├── helpers
 │   └── libraries
 │       └── Ball.php
 └── gamma
     ├── config
     └── libraries
         └── Ball.php
     └── helpers
         └── chart.php

If you write the following code:

 $ball = new Ball();
 chart::draw();

The Kohana Cascading Filesystem will load modules/alpha/chart.php because that’s the first instance of the chart helper class it finds, and it will load modules/beta/Ball.php because that’s the first instance of the Ball class that it can find. In your code you do not need to include these files yourself.

Note: Typically, it’s a bad practice to rely directly on a helper or library from any module other than the gallery module.