94 'identification_sequence' => self::DEFAULT_IDENTIFICATION_SEQUENCE,
96 'adapter' => self::DEFAULT_PERSISTENT_STORAGE_ADAPTER,
176 'browser_type' => $this->_browserType,
177 'config' => $this->_config,
178 'device_class' => get_class($device),
179 'device' => $device->serialize(),
199 $deviceClass = $spec[
'device_class'];
206 $deviceSpec[
'_config'] = $this->
getConfig();
207 $deviceSpec[
'_server'] = $this->
getServer();
208 $this->_device =
new $deviceClass($deviceSpec);
227 #require_once 'Zend/Http/UserAgent/Exception.php'; 229 'Invalid argument; expected array, Zend_Config object, or object implementing ArrayAccess and Traversable; received %s',
241 if (isset(
$options[
'plugin_loader'])) {
242 $plConfig =
$options[
'plugin_loader'];
243 if (is_array($plConfig) || $plConfig instanceof Traversable) {
248 unset($plConfig,
$options[
'plugin_loader']);
254 switch (strtolower($key)) {
287 $r =
new ReflectionClass($deviceClass);
288 if (!$r->implementsInterface(
'Zend_Http_UserAgent_Device')) {
290 'Invalid device class provided ("%s"); must implement Zend_Http_UserAgent_Device',
299 array($deviceClass,
'match'),
314 $browserType = strtolower($browserType);
315 if (isset($this->_browserTypeClass[$browserType])) {
316 return $this->_browserTypeClass[$browserType];
319 if (isset($this->_config[$browserType])
320 && isset($this->_config[$browserType][
'device'])
322 $deviceConfig = $this->_config[$browserType][
'device'];
323 if (is_array($deviceConfig) && isset($deviceConfig[
'classname'])) {
324 $device = (string) $deviceConfig[
'classname'];
326 #require_once 'Zend/Http/UserAgent/Exception.php'; 328 'Invalid classname "%s" provided in device configuration for browser type "%s"',
333 }
elseif (is_array($deviceConfig) && isset($deviceConfig[
'path'])) {
335 $path = $deviceConfig[
'path'];
336 $prefix = isset($deviceConfig[
'prefix']) ? $deviceConfig[
'prefix'] :
'Zend_Http_UserAgent';
339 $device =
$loader->load($browserType);
342 $device =
$loader->load($browserType);
346 $device =
$loader->load($browserType);
349 $this->_browserTypeClass[$browserType] = $device;
424 if (
null === $browser) {
427 if (
null === $this->_storage) {
428 $config = $this->_config[
'storage'];
435 $options = array(
'browser_type' => $browser);
436 if (isset(
$config[
'options'])) {
452 if ($this->_immutable) {
453 #require_once 'Zend/Http/UserAgent/Exception.php'; 455 'The User-Agent device object has already been retrieved; the storage object is now immutable' 459 $this->_storage = $storage;
511 #require_once 'Zend/Http/UserAgent/Exception.php'; 513 'Config parameters must be in an array or a Traversable object; received "%s"',
518 if (
$config instanceof Traversable) {
527 $this->_config = array_merge($this->_config,
$config);
541 if (
null !== $this->_device) {
550 if (!$storage->isEmpty()) {
553 $object = $storage->read();
567 $this->_immutable =
true;
591 if ($this->_immutable) {
592 #require_once 'Zend/Http/UserAgent/Exception.php'; 594 'The User-Agent device object has already been retrieved; the browser type is now immutable' 598 $this->_browserType = $browserType;
615 if (
null === $this->_server) {
633 if ($this->_immutable) {
634 #require_once 'Zend/Http/UserAgent/Exception.php'; 636 'The User-Agent device object has already been retrieved; the server array is now immutable' 640 if (!is_array($server) && !$server instanceof Traversable) {
641 #require_once 'Zend/Http/UserAgent/Exception.php'; 643 'Expected an array or object implementing Traversable; received %s',
644 (is_object($server) ? get_class($server) : gettype($server))
649 if ($server instanceof ArrayObject) {
650 $server = $server->getArrayCopy();
651 }
elseif ($server instanceof Traversable) {
653 foreach ($server as $key =>
$value) {
661 $server = array_change_key_case($server, CASE_LOWER);
663 $this->_server = $server;
675 $key = strtolower($key);
678 if (isset($server[$key])) {
679 $return = $server[$key];
694 if ($this->_immutable) {
695 #require_once 'Zend/Http/UserAgent/Exception.php'; 697 'The User-Agent device object has already been retrieved; the server array is now immutable' 702 $key = strtolower($key);
703 $this->_server[$key] =
$value;
720 #require_once 'Zend/Loader.php'; 725 #require_once 'Zend/Http/UserAgent/Exception.php'; 727 'Expected a plugin loader class or object; received %s',
731 if (!
$loader instanceof Zend_Loader_PluginLoader) {
732 #require_once 'Zend/Http/UserAgent/Exception.php'; 734 'Expected an object extending Zend_Loader_PluginLoader; received %s',
739 $basePrefix =
'Zend_Http_UserAgent_';
740 $basePath =
'Zend/Http/UserAgent/';
743 $prefix = $basePrefix .
'Storage';
744 $path = $basePath .
'Storage';
765 if (!isset($this->_loaders[
$type])) {
766 #require_once 'Zend/Loader/PluginLoader.php'; 769 return $this->_loaders[
$type];
785 if (!in_array(
$type, $this->_loaderTypes)) {
786 $types = implode(
', ', $this->_loaderTypes);
788 #require_once 'Zend/Http/UserAgent/Exception.php'; 790 'Expected one of "%s" for plugin loader type; received "%s"',
809 if (empty($this->_config[
'identification_sequence'])) {
814 $sequence = explode(
',', $this->_config[
'identification_sequence']);
818 array_unshift($sequence, $browserType);
822 if (!in_array(
$type, $sequence)) {
827 foreach ($sequence as $browserType) {
828 $browserType = trim($browserType);
833 $type = $browserType;
setConfig($config=array())
setHttpAccept($httpAccept)
_validateLoaderType($type)
elseif(isset( $params[ 'redirect_parent']))
static loadClass($class, $dirs=null)
_getUserAgentDevice($browserType)
call_user_func($callable, $param)
getStorage($browser=null)
clearStorage($browser=null)
setServerValue($key, $value)
const DEFAULT_IDENTIFICATION_SEQUENCE
const DEFAULT_HTTP_ACCEPT
setPluginLoader($type, $loader)
$_option $_optionId $class
setBrowserType($browserType)
__construct($options=null)
const DEFAULT_MARKUP_LANGUAGE
setStorage(Zend_Http_UserAgent_Storage $storage)
const DEFAULT_BROWSER_TYPE
const DEFAULT_PERSISTENT_STORAGE_ADAPTER
const DEFAULT_HTTP_USER_AGENT
getHttpAccept($httpAccept=null)