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