Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
init.js.php
Go to the documentation of this file.
1 <?php
8 $modules = [];
9 foreach (elgg_get_plugins() as $plugin) {
10  $id = $plugin->getID();
11  if (elgg_view_exists("boot/$id.js")) {
12  $modules[] = "boot/$id";
13  }
14 }
15 
16 ?>
17 //<script>
18 define(function (require) {
19  var Plugin = require('elgg/Plugin');
20  var elgg = require('elgg');
21 
22  var modules = [];
23  var i;
24 
25  // We need literal require('boot/example'); statements. We can't use async require in here because we promise to
26  // not return this module until all boot plugins are loaded.
27 <?php foreach ($modules as $name) { ?>
28  modules.push({
29  plugin: require(<?= json_encode($name, JSON_UNESCAPED_SLASHES) ?>),
30  name: <?= json_encode($name, JSON_UNESCAPED_SLASHES) ?>
31  });
32 <?php } ?>
33 
34  for (i = 0; i < modules.length; i++) {
35  if (modules[i].plugin instanceof Plugin) {
36  modules[i].plugin._init();
37  } else {
38  console.error("Boot module boot/" + modules[i].name + " did not return an instance of Plugin (from elgg/Plugin)");
39  }
40  }
41 
42  elgg.trigger_hook('init', 'system');
43 });
elgg_view_exists($view, $viewtype= '', $recurse=true)
Returns whether the specified view exists.
Definition: views.php:299
$modules
Boot all the plugins and trigger the [init, system] hook.
Definition: init.js.php:8
$plugin
if($guid==elgg_get_logged_in_user_guid()) $name
Definition: delete.php:21
$site name
elgg_get_plugins($status= 'active', $site_guid=null)
Returns an ordered list of plugins.
Definition: plugins.php:132
const elgg
Definition: elgg.js.php:92
if(!$collection_name) $id
Definition: add.php:17
i
Definition: admin.css.php:47