Esempio n. 1
0
 public function configPath($name, $array, $object)
 {
     if (!array_key_exists("child", $array)) {
         return;
     }
     foreach (Amslib_Array::valid($array["child"]) as $c) {
         $v = Amslib_Plugin::expandPath($c["value"]);
         if ($c["tag"] == "include") {
             Amslib::addIncludePath(Amslib_File::absolute($v));
         } else {
             Amslib_Website::setPath($c["tag"], $v);
             switch ($c["tag"]) {
                 case "plugin":
                     Amslib_Plugin_Manager::addLocation($v);
                     break;
                 case "docroot":
                     Amslib_File::documentRoot($v);
                     break;
             }
         }
     }
 }
 public function initialise()
 {
     //	Quickly insert this plugin object before we load anything else
     //	We do this so other plugins that might call the application can access this plugins
     //	configuration before the entire tree is loaded, because in a tree algorithm, all the
     //	other plugins are loaded into the system before this one, which causes a problem because
     //	of course if you need to talk to or through the application object, if you have not fully
     //	explored the tree, it won't exist, this obviously causes a lot of problems, so we need to
     //	"insert" a incomplete plugin here, so at least the plugin configurtion is available even
     //	if the actual API is not, when configuring the plugin tree, we 100% of the time always deal
     //	with the plugin object, not the API which is created after the plugin is fully loaded
     Amslib_Plugin_Manager::insert($this->getName(), $this);
     //	Set the base locations to load plugins from
     //	NOTE: this obviously means it's not configurable, since I'm hardcoding the path for this here
     Amslib_Plugin_Manager::addLocation($this->getLocation());
     Amslib_Plugin_Manager::addLocation($this->getLocation() . "/plugins");
     //	We can't use Amslib_Plugin_Manager for this, because it's an application plugin
     $this->config($this->getName());
     //	Process all the imports and exports so all the plugins contain the correct data
     Amslib_Plugin_Manager::processImport();
     Amslib_Plugin_Manager::processExport();
     //	Now we have to load all the plugins into the system
     $this->load();
     //	NOTE:	perhaps we can add a default callback for running the method Amslib_Plugin_Manager::processTransfers
     //	NOTE:	after all the plugins are loaded, do we need ot keep the plugin objects in memory, perhaps we should
     //			dump them all once all the API objects are created
     //	NOTE:	perhaps we register a completion callback to manually take care of this, it sounds like a useful way
     //			to save some memory, all those xml objects must take up space and especially the bulky confguration arrays
     //	NOTE:	we currently are deleting it inside the plugin code, perhaps this is not elegant
     $this->runCompletionCallbacks();
 }