Esempio n. 1
0
 /**
  * 	method:	load
  *
  * 	todo: write documentation
  */
 public function load()
 {
     if ($this->isLoaded) {
         return $this->api;
     }
     if ($this->isConfigured) {
         //	Process all child plugins before the parents
         foreach (Amslib_Array::valid($this->data["requires"]) as $plugin) {
             $plugin->load();
         }
         //	run all the configuration into the api object
         $this->process();
         //	initialise the api object, it's now ready to use externally
         $this->api->initialise();
         //	Insert into the plugin manager
         Amslib_Plugin_Manager::insert($this->name, $this);
         //	finalise the plugin, finish any last requests by the plugin
         $this->finalisePlugin();
         $this->isLoaded = true;
         return $this->api;
     }
     return false;
 }
 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();
 }