Reorganization of namespaces
First of all thank You for Your time. I use autoload in my 2 plugins. They have to different namespaces but i want to build one main plugin with autoload for this two plugins. In future i am going to add more plugins. How should i organize that? in plugins i have to namespaces
namespace plugin_namespace\controller\some_cntr
and
namespace sec_plugin_namespace\controller\some_cntr
everything is object oriented and here is my autoloader witch exists in both plugins (i will have only one if it is possible :))
/**
* Register autoloader
*/
public function autoloader(){
spl_autoload_register( array( $this, 'xx_my_plugin' ) );
}
/**
* Autoloader
*
* @param $class
*/
public function xx_my_plugin( $class ) {
$first = strpos($class, '\\') + 1;
$path = substr( $class, $first);
$path = strtolower( $path );
$path = str_replace( '_', '-', $path );
$path = str_replace( '\\', DIRECTORY_SEPARATOR, $path ) . '.php';
$path = __DIR__ . DIRECTORY_SEPARATOR . $path;
if ( file_exists( $path ) ) {
include $path;
}
}