| 1 | <?php |
||
| 5 | abstract class AbstractWidget |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * The number of seconds before each reload. |
||
| 9 | * False means no reload at all. |
||
| 10 | * |
||
| 11 | * @var int|float|bool |
||
| 12 | */ |
||
| 13 | public $reloadTimeout = false; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * The number of minutes before cache expires. |
||
| 17 | * False means no caching at all. |
||
| 18 | * |
||
| 19 | * @var int|float|bool |
||
| 20 | */ |
||
| 21 | public $cacheTime = false; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * The configuration array. |
||
| 25 | * |
||
| 26 | * @var array |
||
| 27 | */ |
||
| 28 | protected $config = []; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Constructor. |
||
| 32 | * |
||
| 33 | * @param array $config |
||
| 34 | */ |
||
| 35 | public function __construct(array $config = []) |
||
| 36 | { |
||
| 37 | foreach ($config as $key => $value) { |
||
| 38 | $this->config[$key] = $value; |
||
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Placeholder for async widget. |
||
| 44 | * You can customize it by overwriting this method. |
||
| 45 | * |
||
| 46 | * @return string |
||
| 47 | */ |
||
| 48 | public function placeholder() |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Async and reloadable widgets are wrapped in container. |
||
| 55 | * You can customize it by overriding this method. |
||
| 56 | * |
||
| 57 | * @return array |
||
| 58 | */ |
||
| 59 | public function container() |
||
| 60 | { |
||
| 61 | return [ |
||
| 62 | 'element' => 'div', |
||
| 63 | 'attributes' => 'style="display:inline" class="arrilot-widget-container"', |
||
| 64 | ]; |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Cache key that is used if caching is enabled. |
||
| 69 | * |
||
| 70 | * @param $params |
||
| 71 | * |
||
| 72 | * @return string |
||
| 73 | */ |
||
| 74 | public function cacheKey(array $params = []) |
||
| 78 | |||
| 79 | /** |
||
| 80 | * Add defaults to configuration array. |
||
| 81 | * |
||
| 82 | * @param array $defaults |
||
| 83 | */ |
||
| 84 | protected function addConfigDefaults(array $defaults) |
||
| 88 | } |
||
| 89 |