class Module
{
protected $container = [];
public function share($moduleName, $object)
{
$this->container[$moduleName] = $object;
}
public function get($moduleName)
{
return $this->container[$moduleName];
}
}
class ACL
{
public function isAllowed($user, $action) {}
}
class Router
{
protected $acl;
public function __construct(ACL $acl)
{
$this->acl = $acl;
}
public function isAllowed()
{
$this->acl->isAllowed("user", "Controller");
}
}
$module = new Module();
$module->share('acl', new ACL());
$module->share('router', new Router($module->get('acl')));