PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Loaders

The purpose of a Loader is to find Providers and Manifest files that contain classes which implement either Zend_Tool_Framework_Provider_Interface or Zend_Tool_Framework_Manifest_Interface. Once these files are found by a loader, providers are loaded into the Provider Repository and manifest metadata is loaded into the Manifest Repository.

To implement a loader, one must extend the following abstract class:

<?php
abstract class Zend_Tool_Framework_Loader_Abstract
{

    abstract protected function 
_getFiles();

    public function 
load()
    {
        
/** ... */
    
}
}

The _getFiles() method should return an array of files (absolute paths). The built-in loader supplied with Zend Framework is called the IncludePath loader. By default, the Tooling framework will use an include_path based loader to find files that might include Providers or Manifest Metadata objects. Zend_Tool_Framework_Loader_IncludePathLoader, without any other options, will search for files inside the include path that end in Mainfest.php, Tool.php or Provider.php. Once found, they will be tested (by the load() method of the Zend_Tool_Framework_Loader_Abstract) to determine if they implement any of the supported interfaces. If they do, an instance of the found class is instantiated, and it is appended to the proper repository.

<?php
class Zend_Tool_Framework_Loader_IncludePathLoader
    
extends Zend_Tool_Framework_Loader_Abstract
{

    protected 
$_filterDenyDirectoryPattern '.*(/|\\\\).svn';
    protected 
$_filterAcceptFilePattern '.*(?:Manifest|Provider)\.php$';

    protected function 
_getFiles()
    {
        
/** ... */
    
}
}

As you can see, the IncludePath loader will search all include_paths for the files that match the $_filterAcceptFilePattern and not match the $_filterDenyDirectoryPattern.

Zend Framework