La Libreria que me genera este objeto, que hace los require_once de cada clase segun el directorio y que a su vez guarda las intancias en el objeto ClassManager Siguiente:
<?php
class ClassManager {
public function LoadClassExternal(&$ObjClass) {
$External = scandir(EXTCLASS, 1); # Directorio de archivos
foreach ($External as $key => $name) {
if (strpos($name, 'class.') !== false) {
#require_once EXTCLASS.''.
$ObjClass[$name] = EXTCLASS . $name;
} elseif(strpos($name, 'phpMailer') !== false) {
$ObjClass[$name] = EXTCLASS . $name .'/PHPMailerAutoload.php';
} elseif(strpos($name, 'html2pdf') !== false) {
$ObjClass[$name] = EXTCLASS . $name .'/html2pdf.class.php';
} elseif(strpos($name, 'fpdf') !== false) {
$ObjClass[$name] = EXTCLASS . $name .'/fpdf.php';
}
}
return $ObjClass;
}
public function LoadClassGeneric(&$ObjClass) {
$Generic = scandir(GENCLASS, 1); # Directorio de archivos
foreach ($Generic as $key => $name) {
if (strpos($name, 'class.') !== false) {
$ObjClass[$name] = GENCLASS . $name;
}
}
return $ObjClass;
}
public function LoadClassCRON(&$ObjClass) {
$Cron = scandir(CRONCLASS, 1); # Directorio de archivos
foreach ($Cron as $key => $name) {
if (strpos($name, 'class.') !== false) {
$ObjClass[$name] = CRONCLASS . $name;
}
}
return $ObjClass;
}
public function LoadClassMVC(&$ObjClass) {
$MVC = scandir(MVCCLASS, 1); # Directorio de archivos
foreach ($MVC as $key => $name) {
if (strpos($name, 'class.') !== false) {
$ObjClass[$name] = MVCCLASS . $name;
}
}
return $ObjClass;
}
public function LoadClassCORE(&$ObjClass) {
$CoreD = scandir(CORECLASS, 1); # Directorio de archivos
foreach ($CoreD as $key => $nameD) {
if (strpos($nameD, 'doc') !== false) {
$CoreF = scandir(CORECLASS.$nameD.'/', 1); # Directorio de archivos
foreach ($CoreF as $key => $nameF) {
if (strpos($nameF, 'doc') !== false) {
$ObjClass[$nameF] = CORECLASS.$nameD.'/' . $nameF;
}
}
}
if (strpos($nameD, 'form') !== false) {
$CoreF = scandir(CORECLASS.$nameD.'/', 1); # Directorio de archivos
foreach ($CoreF as $key => $nameF) {
if (strpos($nameF, 'form') !== false) {
$ObjClass[$nameF] = CORECLASS.$nameD.'/' . $nameF;
}
}
}
if (strpos($nameD, 'list') !== false) {
$CoreF = scandir(CORECLASS.$nameD.'/', 1); # Directorio de archivos
foreach ($CoreF as $key => $nameF) {
if (strpos($nameF, 'list') !== false) {
$ObjClass[$nameF] = CORECLASS.$nameD.'/' . $nameF;
}
}
}
if (strpos($nameD, 'modal') !== false) {
$CoreF = scandir(CORECLASS.$nameD.'/', 1); # Directorio de archivos
foreach ($CoreF as $key => $nameF) {
if (strpos($nameF, 'modal') !== false) {
$ObjClass[$nameF] = CORECLASS.$nameD.'/' . $nameF;
}
}
}
if (strpos($nameD, 'not') !== false) {
$CoreF = scandir(CORECLASS.$nameD.'/', 1); # Directorio de archivos
foreach ($CoreF as $key => $nameF) {
if (strpos($nameF, 'not') !== false) {
$ObjClass[$nameF] = CORECLASS.$nameD.'/' . $nameF;
}
}
}
if (strpos($nameD, 'process') !== false) {
$CoreF = scandir(CORECLASS.$nameD.'/', 1); # Directorio de archivos
foreach ($CoreF as $key => $nameF) {
if (strpos($nameF, 'process') !== false) {
$ObjClass[$nameF] = CORECLASS.$nameD.'/' . $nameF;
}
}
}
}
return $ObjClass;
}
public function LoadClass(&$ObjClass) {
#require files
$this->LoadClassExternal($ObjClass);
$this->LoadClassGeneric($ObjClass);
$this->LoadClassCRON($ObjClass);
$this->LoadClassMVC($ObjClass);
$this->LoadClassCORE($ObjClass);
return $ObjClass;
}
public function ClassPackExternal(&$ObjClassInst) {
return $ObjClassInst;
}
#Esta Seccion es la que instancia las Clases
public function ClassPackGeneric(&$ObjClassInst) {
$Generic = scandir(GENCLASS, 1); # Directorio de archivos
foreach ($Generic as $key => $name) {
if (strpos($name, 'class.') !== false) {
$name=preg_replace('#\.php#', '', $name);
$names=explode(".", $name);
foreach ($names as $key => $namesr) {
$names[$key]=ucfirst(strtolower($namesr));
}
$name=implode('_', $names);
$NamesClass = $name.'Manager';
$InstanceClass = strtoupper(preg_replace('#\Class_#', '', $NamesClass));
#$ObjClassInst['Generic'][$InstanceClass] = $NamesClass;
$ObjClassInst['Generic'][$InstanceClass] = $this->$InstanceClass= new $NamesClass();
}
}
return $ObjClassInst;
}
public function ClassPackCRON(&$ObjClassInst) {
return $ObjClassInst;
}
public function ClassPackMVC(&$ObjClassInst) {
return $ObjClassInst;
}
public function ClassPackCORE(&$ObjClassInst) {
return $ObjClassInst;
}
public function ClassPack(&$ObjClassInst){
#require files
$this->ClassPackExternal($ObjClassInst);
$this->ClassPackGeneric($ObjClassInst);
$this->ClassPackCRON($ObjClassInst);
$this->ClassPackMVC($ObjClassInst);
$this->ClassPackCORE($ObjClassInst);
return $ObjClassInst;
}
}
?>