MediaWiki master
SpinnerWidget.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Widget;
4
6use Stringable;
7
17class SpinnerWidget implements Stringable {
18
20 private $attributes;
22 private $content;
23
27 public function __construct( array $config = [] ) {
28 $size = $config['size'] ?? 'small';
29 $type = $config['type'] ?? 'inline';
30
31 $this->attributes = [];
32
33 if ( isset( $config['id'] ) ) {
34 $this->attributes['id'] = $config['id'];
35 }
36
37 // Initialization
38 $this->attributes['class'] = [
39 'mw-spinner',
40 $size === 'small' ? 'mw-spinner-small' : 'mw-spinner-large',
41 $type === 'inline' ? 'mw-spinner-inline' : 'mw-spinner-block',
42 ];
43
44 $this->content =
45 '<div class="mw-spinner-container">' .
46 str_repeat( '<div></div>', 12 ) .
47 '</div>';
48 }
49
54 public function toString() {
55 return Html::rawElement( 'div', $this->attributes, $this->content );
56 }
57
65 public function __toString() {
66 return $this->toString();
67 }
68}
This class is a collection of static functions that serve two purposes:
Definition Html.php:57
PHP version of jquery.spinner.
toString()
Render element into HTML.
__toString()
Magic method implementation.