Completed
Push — master ( 0deaa8...2f46d9 )
by Konstantin
01:14
created
UloginWidget.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,6 @@
 block discarded – undo
7 7
 
8 8
 namespace kosv\ulogin\widget;
9 9
 
10
-use Yii;
11 10
 use yii\base\Widget;
12 11
 use kosv\ulogin\widget\UloginAsset;
13 12
 
Please login to merge, or discard this patch.
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -20,105 +20,105 @@
 block discarded – undo
20 20
  */
21 21
 class UloginWidget extends Widget
22 22
 {
23
-    /**
24
-     * @var array Layouts buttons
25
-     * @see http://ulogin.ru/help.php#buttons
26
-     */
27
-    public $buttons = [];
28
-
29
-    /**
30
-     * @var string HTML The class attribute
31
-     * @see http://htmlbook.ru/html/attr/class
32
-     */
33
-    public $classAttr = '';
34
-
35
-    /**
36
-     * @var array Js event handlers
37
-     * @see https://ulogin.ru/help.php#listeners
38
-     */
39
-    public $eventListeners = [];
40
-
41
-    /**
42
-     * @var array Ulogin options
43
-     * @see https://ulogin.ru/help.php
44
-     */
45
-    public $options = [];
46
-
47
-    /**
48
-     * @var string Ulogin init buttons
49
-     */
50
-    private $_initButtons;
51
-    /**
52
-     * @var string Ulogin init options
53
-     */
54
-    private $_initOptions;
55
-
56
-    /**
57
-     * @inheritdoc
58
-     */
59
-    public function init()
60
-    {
61
-        $initOptions = '';
62
-        foreach ($this->options as $option => $value) {
63
-            if (is_array($value)) {
64
-                $initOptions .= $option . '=' . implode(',', $value) . ';';
65
-            } else {
66
-                $initOptions .= $option . '=' . $value . ';';
67
-            }
68
-        }
69
-
70
-        $initButtons = [];
71
-        foreach ($this->buttons as $button) {
72
-            $data = "data-uloginbutton=\"{$button['provider']}\"";
73
-            $initButtons[] = $button['layout']($data);
74
-        }
75
-
76
-        $this->_initOptions = $initOptions;
77
-        $this->_initButtons = $initButtons;
78
-
79
-
80
-        parent::init();
81
-    }
82
-
83
-    /**
84
-     * @inheritdoc
85
-     */
86
-    public function run()
87
-    {
88
-
89
-        UloginAsset::register($this->getView());
90
-
91
-        //Register event listeners
92
-        foreach ($this->eventListeners as $event => $listener) {
93
-            $this->setStateListener($event, $listener);
94
-        }
95
-
96
-        return $this->render('widget', [
97
-            'class' => $this->classAttr,
98
-            'buttons' => $this->_initButtons,
99
-            'id' => $this->id,
100
-            'initOptions' => $this->_initOptions,
101
-        ]);
102
-    }
103
-
104
-    /**
105
-     * Sets the event handler in the event ulogin
106
-     *
107
-     * @param string $event Js event name
108
-     * @param string $listener Js event handler
109
-     * @return $this
110
-     * @see https://ulogin.ru/help.php#listeners
111
-     */
112
-    public function setStateListener($event, $listener)
113
-    {
114
-        $js = sprintf(
115
-            'uLogin.setStateListener(%s, %s, %s);',
116
-            $this->id,
117
-            $event,
118
-            $listener
119
-        );
120
-
121
-        $this->getView()->registerJs($js);
122
-        return $this;
123
-    }
23
+	/**
24
+	 * @var array Layouts buttons
25
+	 * @see http://ulogin.ru/help.php#buttons
26
+	 */
27
+	public $buttons = [];
28
+
29
+	/**
30
+	 * @var string HTML The class attribute
31
+	 * @see http://htmlbook.ru/html/attr/class
32
+	 */
33
+	public $classAttr = '';
34
+
35
+	/**
36
+	 * @var array Js event handlers
37
+	 * @see https://ulogin.ru/help.php#listeners
38
+	 */
39
+	public $eventListeners = [];
40
+
41
+	/**
42
+	 * @var array Ulogin options
43
+	 * @see https://ulogin.ru/help.php
44
+	 */
45
+	public $options = [];
46
+
47
+	/**
48
+	 * @var string Ulogin init buttons
49
+	 */
50
+	private $_initButtons;
51
+	/**
52
+	 * @var string Ulogin init options
53
+	 */
54
+	private $_initOptions;
55
+
56
+	/**
57
+	 * @inheritdoc
58
+	 */
59
+	public function init()
60
+	{
61
+		$initOptions = '';
62
+		foreach ($this->options as $option => $value) {
63
+			if (is_array($value)) {
64
+				$initOptions .= $option . '=' . implode(',', $value) . ';';
65
+			} else {
66
+				$initOptions .= $option . '=' . $value . ';';
67
+			}
68
+		}
69
+
70
+		$initButtons = [];
71
+		foreach ($this->buttons as $button) {
72
+			$data = "data-uloginbutton=\"{$button['provider']}\"";
73
+			$initButtons[] = $button['layout']($data);
74
+		}
75
+
76
+		$this->_initOptions = $initOptions;
77
+		$this->_initButtons = $initButtons;
78
+
79
+
80
+		parent::init();
81
+	}
82
+
83
+	/**
84
+	 * @inheritdoc
85
+	 */
86
+	public function run()
87
+	{
88
+
89
+		UloginAsset::register($this->getView());
90
+
91
+		//Register event listeners
92
+		foreach ($this->eventListeners as $event => $listener) {
93
+			$this->setStateListener($event, $listener);
94
+		}
95
+
96
+		return $this->render('widget', [
97
+			'class' => $this->classAttr,
98
+			'buttons' => $this->_initButtons,
99
+			'id' => $this->id,
100
+			'initOptions' => $this->_initOptions,
101
+		]);
102
+	}
103
+
104
+	/**
105
+	 * Sets the event handler in the event ulogin
106
+	 *
107
+	 * @param string $event Js event name
108
+	 * @param string $listener Js event handler
109
+	 * @return $this
110
+	 * @see https://ulogin.ru/help.php#listeners
111
+	 */
112
+	public function setStateListener($event, $listener)
113
+	{
114
+		$js = sprintf(
115
+			'uLogin.setStateListener(%s, %s, %s);',
116
+			$this->id,
117
+			$event,
118
+			$listener
119
+		);
120
+
121
+		$this->getView()->registerJs($js);
122
+		return $this;
123
+	}
124 124
 }
125 125
\ No newline at end of file
Please login to merge, or discard this patch.
UloginAsset.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
  */
18 18
 class UloginAsset extends AssetBundle
19 19
 {
20
-    public $js = [
21
-        '//ulogin.ru/js/ulogin.js'
22
-    ];
20
+	public $js = [
21
+		'//ulogin.ru/js/ulogin.js'
22
+	];
23 23
 }
24 24
\ No newline at end of file
Please login to merge, or discard this patch.
views/widget.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2
-    /** @var string $class */
3
-    /** @var string[] $buttons */
4
-    /** @var string $id */
5
-    /** @var string $initOptions */
2
+	/** @var string $class */
3
+	/** @var string[] $buttons */
4
+	/** @var string $id */
5
+	/** @var string $initOptions */
6 6
 ?>
7 7
 <div id="<?= $id ?>" class="<?= $class ?>" data-ulogin="<?= $initOptions ?>">
8 8
     <?php foreach ($buttons as $button): ?>
Please login to merge, or discard this patch.