*/
class NavigationManager implements \OCP\INavigationManager {
protected $entries = array();
+ protected $closureEntries = array();
protected $activeEntry;
/**
* Creates a new navigation entry
- * @param array $entry containing: id, name, order, icon and href key
+ *
+ * @param array|\Closure $entry Array containing: id, name, order, icon and href key
+ * The use of a closure is preferred, because it will avoid
+ * loading the routing of your app, unless required.
+ * @return void
*/
- public function add(array $entry) {
+ public function add($entry) {
+ if ($entry instanceof \Closure) {
+ $this->closureEntries[] = $entry;
+ return;
+ }
+
$entry['active'] = false;
if(!isset($entry['icon'])) {
$entry['icon'] = '';
* @return array an array of the added entries
*/
public function getAll() {
+ foreach ($this->closureEntries as $c) {
+ $this->add($c());
+ }
+ $this->closureEntries = array();
return $this->entries;
}
*/
public function clear() {
$this->entries = array();
+ $this->closureEntries = array();
}
/**
interface INavigationManager {
/**
* Creates a new navigation entry
- * @param array $entry containing: id, name, order, icon and href key
+ *
+ * @param array|\Closure $entry Array containing: id, name, order, icon and href key
+ * The use of a closure is preferred, because it will avoid
+ * loading the routing of your app, unless required.
* @return void
*/
- public function add(array $entry);
+ public function add($entry);
/**
* Sets the current navigation entry of the currently running app