/framework/ZoopLibrary.php
PHP | 50 lines | 38 code | 6 blank | 6 comment | 5 complexity | e810684a8c592daa01b002aaff5d1e59 MD5 | raw file
1<?php 2abstract class ZoopLibrary 3{ 4 private $mods, $path; 5 6 /** 7 * Stuff about the constructor 8 * 9 * @return ZoopLibrary 10 */ 11 final function __construct($path) 12 { 13 $this->path = $path; 14 $this->mods = array(); 15 $this->init(); 16 } 17 18 protected function registerMod($name) 19 { 20 if(!isset($this->mods[$name])) 21 $this->mods[$name] = false; 22 } 23 24 public function hasMod($name) 25 { 26 return isset($this->mods[$name]); 27 } 28 29 public function loadMod($name) 30 { 31 // if this library doesn't have this module then Zoop will have to figure out which one does 32 if(!$this->hasMod($name)) 33 return Zoop::loadMod($name); 34 35 if(isset($this->mods[$name]) && $this->mods[$name]) 36 return; 37 $modName = ucfirst($name) . 'Module'; 38 include("$this->path/$name/$modName.php"); 39 $this->mods[$name] = new $modName("$this->path/$name", $this); 40 } 41 42 public function loadMods() 43 { 44 foreach($this->mods as $name => $mod) 45 { 46 if(!$mod) 47 $this->loadMod($name); 48 } 49 } 50}