aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/Menu/AbstractMenu.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2023-08-29 14:45:13 +0200
committerAndreas Gohr <andi@splitbrain.org>2023-08-29 14:45:13 +0200
commit33b91513e25639a6c7eb35668484d29098f7c9b4 (patch)
tree94ce92db1a438558a4a4cb1071d013f37799b29d /inc/Menu/AbstractMenu.php
parenta469bafbb7a66014d980252c016b21d803046f1a (diff)
downloaddokuwiki-33b91513e25639a6c7eb35668484d29098f7c9b4.tar.gz
dokuwiki-33b91513e25639a6c7eb35668484d29098f7c9b4.zip
Apply rector fixes to inc/Menu
Diffstat (limited to 'inc/Menu/AbstractMenu.php')
-rw-r--r--inc/Menu/AbstractMenu.php36
1 files changed, 19 insertions, 17 deletions
diff --git a/inc/Menu/AbstractMenu.php b/inc/Menu/AbstractMenu.php
index 37e5d2cc3..d97b584ee 100644
--- a/inc/Menu/AbstractMenu.php
+++ b/inc/Menu/AbstractMenu.php
@@ -12,10 +12,11 @@ use dokuwiki\Menu\Item\AbstractItem;
* It contains convenience functions to display the menu in HTML, but template authors can also
* just accesst the items via getItems() and create the HTML as however they see fit.
*/
-abstract class AbstractMenu implements MenuInterface {
+abstract class AbstractMenu implements MenuInterface
+{
/** @var string[] list of Item classes to load */
- protected $types = array();
+ protected $types = [];
/** @var int the context this menu is used in */
protected $context = AbstractItem::CTX_DESKTOP;
@@ -28,7 +29,8 @@ abstract class AbstractMenu implements MenuInterface {
*
* @param int $context the context this menu is used in
*/
- public function __construct($context = AbstractItem::CTX_DESKTOP) {
+ public function __construct($context = AbstractItem::CTX_DESKTOP)
+ {
$this->context = $context;
}
@@ -38,30 +40,29 @@ abstract class AbstractMenu implements MenuInterface {
* @return AbstractItem[]
* @triggers MENU_ITEMS_ASSEMBLY
*/
- public function getItems() {
- $data = array(
- 'view' => $this->view,
- 'items' => array(),
- );
- Event::createAndTrigger('MENU_ITEMS_ASSEMBLY', $data, array($this, 'loadItems'));
+ public function getItems()
+ {
+ $data = ['view' => $this->view, 'items' => []];
+ Event::createAndTrigger('MENU_ITEMS_ASSEMBLY', $data, [$this, 'loadItems']);
return $data['items'];
}
/**
* Default action for the MENU_ITEMS_ASSEMBLY event
*
- * @see getItems()
* @param array $data The plugin data
+ * @see getItems()
*/
- public function loadItems(&$data) {
- foreach($this->types as $class) {
+ public function loadItems(&$data)
+ {
+ foreach ($this->types as $class) {
try {
$class = "\\dokuwiki\\Menu\\Item\\$class";
/** @var AbstractItem $item */
$item = new $class();
- if(!$item->visibleInContext($this->context)) continue;
+ if (!$item->visibleInContext($this->context)) continue;
$data['items'][] = $item;
- } catch(\RuntimeException $ignored) {
+ } catch (\RuntimeException $ignored) {
// item not available
}
}
@@ -77,10 +78,11 @@ abstract class AbstractMenu implements MenuInterface {
* @param bool $svg add the SVG link
* @return string
*/
- public function getListItems($classprefix = '', $svg = true) {
+ public function getListItems($classprefix = '', $svg = true)
+ {
$html = '';
- foreach($this->getItems() as $item) {
- if($classprefix !== false) {
+ foreach ($this->getItems() as $item) {
+ if ($classprefix !== false) {
$class = ' class="' . $classprefix . $item->getType() . '"';
} else {
$class = '';