* // Returns array('admin', 'test.example') * Module::parse('admin::test.example'); * * // Returns array('application', 'test.example') * Module::parse('test.example'); * * * @param string $key * @return array */ public static function parse($key) { $module = (strpos($key, '::') !== false) ? substr($key, 0, strpos($key, ':')) : DEFAULT_MODULE; if ($module !== DEFAULT_MODULE) $key = substr($key, strpos($key, ':') + 2); return array($module, $key); } /** * Get the path for a given module. * * If the module exists in the module array as a key, that means a path other than * the default path has been specified for the module. Otherwise, the module directory * is assumed to have the same name as the module. * * @param string $module * @return string */ public static function path($module) { if (array_key_exists($module, static::$paths)) return static::$paths[$module]; if (in_array($module, static::$modules)) { return static::$paths[$module] = MODULE_PATH.$module.'/'; } elseif (array_key_exists($module, static::$modules)) { return static::$paths[$module] = MODULE_PATH.static::$modules[$module].'/'; } } /** * Get the an array of paths to all of the modules. * * @return array */ public static function paths() { return array_map(function($module) { return Laravel\Module::path($module); }, static::$modules); } }