13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Application |
16 * @package Zend_Application |
17 * @subpackage Resource |
17 * @subpackage Resource |
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
20 */ |
20 */ |
21 |
21 |
22 /** |
22 /** |
23 * @category Zend |
23 * @category Zend |
24 * @package Zend_Application |
24 * @package Zend_Application |
25 * @subpackage Resource |
25 * @subpackage Resource |
26 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
26 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
27 * @license http://framework.zend.com/license/new-bsd New BSD License |
27 * @license http://framework.zend.com/license/new-bsd New BSD License |
28 */ |
28 */ |
29 class Zend_Application_Resource_UserAgent extends Zend_Application_Resource_ResourceAbstract |
29 class Zend_Application_Resource_UserAgent extends Zend_Application_Resource_ResourceAbstract |
30 { |
30 { |
31 /** |
31 /** |
32 * @var Zend_Http_UserAgent |
32 * @var Zend_Http_UserAgent |
33 */ |
33 */ |
34 protected $_userAgent; |
34 protected $_userAgent; |
35 |
35 |
36 /** |
36 /** |
37 * Intialize resource |
37 * Intialize resource |
38 * |
38 * |
39 * @return Zend_Http_UserAgent |
39 * @return Zend_Http_UserAgent |
40 */ |
40 */ |
41 public function init() |
41 public function init() |
42 { |
42 { |
43 $userAgent = $this->getUserAgent(); |
43 $userAgent = $this->getUserAgent(); |
44 |
44 |
45 // Optionally seed the UserAgent view helper |
45 // Optionally seed the UserAgent view helper |
46 $bootstrap = $this->getBootstrap(); |
46 $bootstrap = $this->getBootstrap(); |
47 if ($bootstrap->hasResource('view') || $bootstrap->hasPluginResource('view')) { |
47 if ($bootstrap->hasResource('view') || $bootstrap->hasPluginResource('view')) { |
48 $bootstrap->bootstrap('view'); |
48 $bootstrap->bootstrap('view'); |
51 $view->userAgent($userAgent); |
51 $view->userAgent($userAgent); |
52 } |
52 } |
53 } |
53 } |
54 |
54 |
55 return $userAgent; |
55 return $userAgent; |
56 } |
56 } |
57 |
57 |
58 /** |
58 /** |
59 * Get UserAgent instance |
59 * Get UserAgent instance |
60 * |
60 * |
61 * @return Zend_Http_UserAgent |
61 * @return Zend_Http_UserAgent |
62 */ |
62 */ |
63 public function getUserAgent() |
63 public function getUserAgent() |
64 { |
64 { |
65 if (null === $this->_userAgent) { |
65 if (null === $this->_userAgent) { |
66 $options = $this->getOptions(); |
66 $options = $this->getOptions(); |
67 $this->_userAgent = new Zend_Http_UserAgent($options); |
67 $this->_userAgent = new Zend_Http_UserAgent($options); |
68 } |
68 } |
69 |
69 |
70 return $this->_userAgent; |
70 return $this->_userAgent; |
71 } |
71 } |
72 } |
72 } |