mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-12-01 10:46:54 +00:00
153c6f2668
Bug: T319358 Change-Id: I9830a4b4b55fdb205c479c09ef807de4f6d68713
45 lines
789 B
PHP
45 lines
789 B
PHP
<?php
|
|
namespace MediaWiki\Skins\Vector\Components;
|
|
|
|
use Countable;
|
|
|
|
/**
|
|
* VectorComponentMenu component
|
|
*/
|
|
class VectorComponentMenu implements VectorComponent, Countable {
|
|
/** @var array */
|
|
private $data;
|
|
|
|
/**
|
|
* @param array $data
|
|
*/
|
|
public function __construct( array $data ) {
|
|
$this->data = $data;
|
|
}
|
|
|
|
/**
|
|
* Counts how many items the menu has.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function count(): int {
|
|
$htmlItems = $this->data['html-items'] ?? '';
|
|
return substr_count( $htmlItems, '<li' );
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getTemplateData(): array {
|
|
return $this->data + [
|
|
'class' => '',
|
|
'label' => '',
|
|
'html-tooltip' => '',
|
|
'label-class' => '',
|
|
'html-before-portal' => '',
|
|
'html-items' => '',
|
|
'html-after-portal' => '',
|
|
];
|
|
}
|
|
}
|