13 private $baseUrl =
'';
14 private $paths = array();
15 private $shim = array();
16 private $dependencies = array();
29 $this->hooks = $hooks;
39 $this->baseUrl =
$url;
51 if (preg_match(
"/\.js$/",
$path)) {
55 if (!isset($this->paths[
$name])) {
56 $this->paths[
$name] = array();
59 array_unshift($this->paths[$name],
$path);
71 unset($this->paths[
$name]);
73 if (preg_match(
"/\.js$/",
$path)) {
78 unset($this->paths[$name][
$key]);
80 if (empty($this->paths[$name])) {
81 unset($this->paths[$name]);
100 if (empty(
$deps) && empty($exports)) {
101 throw new \InvalidParameterException(
"Shimmed modules must have deps or exports");
104 $this->shim[
$name] = array();
110 if (!empty($exports)) {
111 $this->shim[
$name][
'exports'] = $exports;
122 return isset($this->shim[
$name]);
132 unset($this->shim[
$name]);
142 $this->dependencies[
$name] =
true;
152 unset($this->dependencies[
$name]);
161 return array_keys($this->dependencies);
171 return isset($this->dependencies[
$name]);
197 if (!empty(
$deps) || !empty($exports)) {
227 if (isset($this->shim[
$name])) {
231 if (isset($this->paths[$name])) {
245 'baseUrl' => $this->baseUrl,
246 'paths' => $this->paths,
247 'shim' => $this->shim,
removeShim($name)
Unregister the shim config for a module.
addDependency($name)
Add a dependency.
if($guid==elgg_get_logged_in_user_guid()) $name
addModule($name, array $config=array())
Adds a standard AMD or shimmed module to the config.
__construct(\Elgg\PluginHooksService $hooks)
Constructor.
addPath($name, $path)
Add a path mapping for a module.
setBaseUrl($url)
Set the base URL for the site.
removePath($name, $path=null)
Remove a path for a module.
getDependencies()
Get registered dependencies.
addShim($name, array $config)
Configures a shimmed module.
getConfig()
Get the configuration of AMD.
hasShim($name)
Is this shim defined.
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
hasModule($name)
Is module configured?
hasDependency($name)
Is this dependency registered.
removeModule($name)
Removes all config for a module.
removeDependency($name)
Removes a dependency.