freenet-router |
Subversion Repositories: |
Compare with Previous - Blame - Download
<?php
namespace Phem\ClassLoading;
/**
*
* Loads 3rdParty Libraries outside framework namespaces.
* Each of them should be located in separate subdirectory of 3rdParty directory
* The subdirectory should contain bootstraper file ([SubdirectoryName]Boot.php)
*
* @author Jakub PetrĹžĂlka <petrzilka@czweb.net>
*/
class ThirdPartyLoader extends Loader
{
public function commit()
{
$dirContent = scandir(THIRD_PARTY_DIR);
foreach ($dirContent as $dirEntry)
{
if (($dirEntry == ".") || ($dirEntry == "..")) continue;
if (is_dir(THIRD_PARTY_DIR . DS . $dirEntry))
{
$bootFileName = THIRD_PARTY_DIR . DS . $dirEntry . DS . $dirEntry . BOOTSTRAPER_SUFFIX . '.php';
if (file_exists($bootFileName))
{
require_once $bootFileName;
//the boot file must contain class named [SubdirectoryName]Boot
$bootstraperClass = $dirEntry . BOOTSTRAPER_SUFFIX;
if (!class_exists($bootstraperClass))
die("Invalid boot file in dependecy " . $dirEntry);
//the class must be descendant of BootStrapper
$bootstrapper = new $bootstraperClass();
if (!is_a($bootstrapper, "Phem\ClassLoading\Bootstrapping\Bootstrapper"))
die("Bootstraper of component " . $dirEntry . " must be inherited from Bootstraper");
$bootstrapper->init();
}
else
{
die("Bootstraper file for component " . $dirEntry. " not found");
}
}
}
}
}