Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
1 <?php 2 /** 3 * Copyright 2014-2017 Horde LLC (http://www.horde.org/) 4 * 5 * See the enclosed file LICENSE for license information (LGPL). If you 6 * did not receive this file, see http://www.horde.org/licenses/lgpl21. 7 * 8 * @category Horde 9 * @copyright 2014-2017 Horde LLC 10 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 11 * @package Imap_Client 12 */ 13 14 /** 15 * Handle IMAP alerts sent from the server. 16 * 17 * @author Michael Slusarz <slusarz@horde.org> 18 * @category Horde 19 * @copyright 2014-2017 Horde LLC 20 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 21 * @package Imap_Client 22 * @since 2.24.0 23 */ 24 class Horde_Imap_Client_Base_Alerts 25 implements SplSubject 26 { 27 /** 28 * Alert data. 29 * 30 * @var object 31 */ 32 protected $_alert; 33 34 /** 35 * Observers. 36 * 37 * @var array 38 */ 39 protected $_observers = array(); 40 41 /** 42 * Add an alert. 43 * 44 * @param string $alert The alert string. 45 * @param string $type The alert type. 46 */ 47 public function add($alert, $type = null) 48 { 49 $this->_alert = new stdClass; 50 $this->_alert->alert = $alert; 51 if (!is_null($type)) { 52 $this->_alert->type = $type; 53 } 54 55 $this->notify(); 56 } 57 58 /** 59 * Returns the last alert received. 60 * 61 * @return object Alert information. Object with these properties: 62 * <pre> 63 * - alert: (string) Alert string. 64 * - type: (string) [OPTIONAL] Alert type. 65 * </pre> 66 */ 67 public function getLast() 68 { 69 return $this->_alert; 70 } 71 72 /* SplSubject methods. */ 73 74 /** 75 */ 76 public function attach(SplObserver $observer) 77 { 78 $this->detach($observer); 79 $this->_observers[] = $observer; 80 } 81 82 /** 83 */ 84 public function detach(SplObserver $observer) 85 { 86 if (($key = array_search($observer, $this->_observers, true)) !== false) { 87 unset($this->_observers[$key]); 88 } 89 } 90 91 /** 92 * Notification is triggered internally whenever the object's internal 93 * data storage is altered. 94 */ 95 public function notify() 96 { 97 foreach ($this->_observers as $val) { 98 $val->update($this); 99 } 100 } 101 102 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body