Abstract.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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-2015 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. /** Zend_Mobile_Push_Interface **/
  23. require_once 'Zend/Mobile/Push/Interface.php';
  24. /** Zend_Mobile_Push_Exception **/
  25. require_once 'Zend/Mobile/Push/Exception.php';
  26. /**
  27. * Push Abstract
  28. *
  29. * @category Zend
  30. * @package Zend_Mobile
  31. * @subpackage Zend_Mobile_Push
  32. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. * @version $Id$
  35. */
  36. abstract class Zend_Mobile_Push_Abstract implements Zend_Mobile_Push_Interface
  37. {
  38. /**
  39. * Is Connected
  40. *
  41. * @var boolean
  42. */
  43. protected $_isConnected = false;
  44. /**
  45. * Connect to the Push Server
  46. *
  47. * @return Zend_Mobile_Push_Abstract
  48. */
  49. public function connect()
  50. {
  51. $this->_isConnected = true;
  52. return $this;
  53. }
  54. /**
  55. * Send a Push Message
  56. *
  57. * @param Zend_Mobile_Push_Message_Abstract $message
  58. * @return boolean
  59. * @throws DomainException
  60. */
  61. public function send(Zend_Mobile_Push_Message_Abstract $message)
  62. {
  63. if (!$this->_isConnected) {
  64. $this->connect();
  65. }
  66. return true;
  67. }
  68. /**
  69. * Close the Connection to the Push Server
  70. *
  71. * @return void
  72. */
  73. public function close()
  74. {
  75. $this->_isConnected = false;
  76. }
  77. /**
  78. * Is Connected
  79. *
  80. * @return boolean
  81. */
  82. public function isConnected()
  83. {
  84. return $this->_isConnected;
  85. }
  86. /**
  87. * Set Options
  88. *
  89. * @param array $options
  90. * @return Zend_Mobile_Push_Abstract
  91. * @throws Zend_Mobile_Push_Exception
  92. */
  93. public function setOptions(array $options)
  94. {
  95. foreach ($options as $k => $v) {
  96. $method = 'set' . ucwords($k);
  97. if (!method_exists($this, $method)) {
  98. throw new Zend_Mobile_Push_Exception('The method "' . $method . "' does not exist.");
  99. }
  100. $this->$method($v);
  101. }
  102. return $this;
  103. }
  104. }