|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
7 * This source file is subject to the new BSD license that is bundled |
|
8 * with this package in the file LICENSE.txt. |
|
9 * It is also available through the world-wide-web at this URL: |
|
10 * http://framework.zend.com/license/new-bsd |
|
11 * If you did not receive a copy of the license and are unable to |
|
12 * obtain it through the world-wide-web, please send an email |
|
13 * to license@zend.com so we can send you a copy immediately. |
|
14 * |
|
15 * @category Zend |
|
16 * @package Zend_Mobile |
|
17 * @subpackage Zend_Mobile_Push |
|
18 * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) |
|
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
20 * @version $Id$ |
|
21 */ |
|
22 |
|
23 /** Zend_Mobile_Push_Interface **/ |
|
24 require_once 'Zend/Mobile/Push/Interface.php'; |
|
25 |
|
26 /** Zend_Mobile_Push_Exception **/ |
|
27 require_once 'Zend/Mobile/Push/Exception.php'; |
|
28 |
|
29 /** |
|
30 * Push Abstract |
|
31 * |
|
32 * @category Zend |
|
33 * @package Zend_Mobile |
|
34 * @subpackage Zend_Mobile_Push |
|
35 * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) |
|
36 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
37 * @version $Id$ |
|
38 */ |
|
39 abstract class Zend_Mobile_Push_Abstract implements Zend_Mobile_Push_Interface |
|
40 { |
|
41 /** |
|
42 * Is Connected |
|
43 * |
|
44 * @var boolean |
|
45 */ |
|
46 protected $_isConnected = false; |
|
47 |
|
48 /** |
|
49 * Connect to the Push Server |
|
50 * |
|
51 * @return Zend_Mobile_Push_Abstract |
|
52 */ |
|
53 public function connect() |
|
54 { |
|
55 $this->_isConnected = true; |
|
56 return $this; |
|
57 } |
|
58 |
|
59 /** |
|
60 * Send a Push Message |
|
61 * |
|
62 * @param Zend_Mobile_Push_Message_Abstract $message |
|
63 * @return boolean |
|
64 * @throws DomainException |
|
65 */ |
|
66 public function send(Zend_Mobile_Push_Message_Abstract $message) |
|
67 { |
|
68 if (!$this->_isConnected) { |
|
69 $this->connect(); |
|
70 } |
|
71 return true; |
|
72 } |
|
73 |
|
74 /** |
|
75 * Close the Connection to the Push Server |
|
76 * |
|
77 * @return void |
|
78 */ |
|
79 public function close() |
|
80 { |
|
81 $this->_isConnected = false; |
|
82 } |
|
83 |
|
84 /** |
|
85 * Is Connected |
|
86 * |
|
87 * @return boolean |
|
88 */ |
|
89 public function isConnected() |
|
90 { |
|
91 return $this->_isConnected; |
|
92 } |
|
93 |
|
94 /** |
|
95 * Set Options |
|
96 * |
|
97 * @param array $options |
|
98 * @return Zend_Mobile_Push_Abstract |
|
99 * @throws Zend_Mobile_Push_Exception |
|
100 */ |
|
101 public function setOptions(array $options) |
|
102 { |
|
103 foreach ($options as $k => $v) { |
|
104 $method = 'set' . ucwords($k); |
|
105 if (!method_exists($this, $method)) { |
|
106 throw new Zend_Mobile_Push_Exception('The method "' . $method . "' does not exist."); |
|
107 } |
|
108 $this->$method($v); |
|
109 } |
|
110 return $this; |
|
111 } |
|
112 } |