forked from 2amigos/yii2-google-maps-library
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPluginAbstract.php
68 lines (61 loc) · 1.45 KB
/
PluginAbstract.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/*
*
* @copyright Copyright (c) 2013-2019 2amigos
* @link http://2amigos.us
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
*
*/
namespace dosamigos\google\maps;
use yii\web\JsExpression;
/**
* PluginAbstract
*
* Abstract object where all plugins should extend from.
*
* @author Antonio Ramirez <[email protected]>
*
* @link http://www.2amigos.us/
* @package dosamigos\google\maps
*/
abstract class PluginAbstract extends ObjectAbstract
{
/**
* Sets the map name
* @param string $value
*/
public function setMap($value)
{
$this->options['map'] = new JsExpression($value);
}
/**
* @return string the processed js events
*/
public function getEvents()
{
$js = [];
if (!empty($this->events)) {
foreach ($this->events as $event) {
/** @var Event $event */
if (!($event instanceof Event)) {
continue; // only Google Events allowed
}
$js[] = $event->getJs($this->getName());
}
}
return !empty($js) ? implode("\n", $js) : "";
}
/**
* Returns the plugin name
* @return string
*/
abstract public function getPluginName();
/**
* Registers plugin asset bundle
*
* @param \yii\web\View $view
*
* @return mixed
*/
abstract public function registerAssetBundle($view);
}