/** * Register the module onto our application * * @param Application $app [description] * @return */ public function register(Application $app) { $app->getInjector()->alias('Skeletapp\\Renderer\\Renderer', 'Skeletapp\\Renderer\\TwigRenderer'); // $app->getInjector()->define('Twig_Environment', [ // ':loader' => $loader, // ':options' => [] // ]); $app->getInjector()->delegate('Twig_Environment', function () use($app) { $loader = new Twig_Loader_Filesystem(APP_ROOT_PATH . '/templates'); $twig = new Twig_Environment($loader); return $twig; }); }
/** * Load a module * * @param type Application $app * @param type $moduleName * @return type */ public function load(Application $app, $moduleName) { $modulePath = sprintf('%s\\%s\\%s', self::BASE_NAMESPACE, $moduleName, $moduleName); if (!class_exists($modulePath) && !class_exists($moduleName)) { throw new \Exception(sprintf("Can't find module %s", $moduleName)); } $module = class_exists($moduleName) ? $app->getInjector()->make($moduleName) : new $modulePath(); if (!$module instanceof Module) { throw new \Exception(sprintf("%s must implement Skeletapp\\Modules\\Module interface", $moduleName)); } $module->register($app); $app->moduleLoaded($moduleName); }