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