I have file structure like this
I wonder how to share library or plugins from outside module to inside module. eg. call Security.php from privateModuleA
the goal is dispatch Security ACL plugins to EventManager in Multiple Module
I try to add this code to app/modules/privateModuleA/Module.php
but It's not working
<?php
namespace Modules\privateModuleA;
use Phalcon\Loader,
Phalcon\Mvc\Dispatcher,
Phalcon\Mvc\View,
Phalcon\Mvc\ModuleDefinitionInterface;
use \Base\Plugins\Security as Security;
class Module implements ModuleDefinitionInterface
{
/**
* Register a specific autoloader for the module
*/
public function registerAutoloaders()
{
$loader = new Loader();
$loader->registerNamespaces(
array(
'Modules\privateModuleA\Controllers' => __DIR__ . '/controllers/',
'Modules\privateModuleA\Models' => __DIR__ . '/models/',
'Base\Plugins\Security' => __DIR__ . '/../../plugins/Security.php',
)
);
$loader->registerClasses(
array(
"Base\Plugins\Security" => "../../plugins/Security.php",
)
);
/**
* We're a registering a set of directories taken from the configuration file
*/
$loader->registerDirs(
array(
__DIR__ . '/../../plugins/',
)
);
$loader->register();
}
/**
* Register specific services for the module
*/
public function registerServices($di)
{
// include __DIR__ . "/../../plugins/Security.php";
/**
* We register the events manager
*/
$di->set('dispatcher', function() use ($di) {
$eventsManager = $di->getShared('eventsManager');
$security = new Security($di);
$eventsManager->attach('dispatch', $security);
$dispatcher = new Dispatcher();
$dispatcher->setEventsManager($eventsManager);
return $dispatcher;
}, true);
//Registering the view component
$di->set('view', function() {
$view = new View();
$view->setViewsDir(__DIR__ . '/views/');
return $view;
});
}
}
please help.