# UserAgent View Helper

## Overview

This view helper provides the ability to inject and later retrieve a `Zend_Http_UserAgent` instance for use in branching display logic based on device capabilities.

## Quick Start

In most cases, you can simply retrieve the User-Agent and related device by calling the helper. If the `UserAgent` was configured in the bootstrap, that instance will be injected already in the helper; otherwise, it will instantiate one for you.

    <?php if ($this->userAgent()->getDevice()->hasFlash()): ?>
        <object ...></object>
    <?php endif ?>

If you initialize the `UserAgent` object manually, you can still inject it into the helper, in one of two ways.

    // Pull the helper from the view, and inject:
    $helper = $view->getHelper('userAgent');
    $helper->setUserAgent($userAgent);

    // Pass the UserAgent to the helper:
    $view->userAgent($userAgent);

## Available Methods

`userAgent` Zend_Http_UserAgent $userAgent = null

  Use this method to set or retrieve the `UserAgent` instance. Passing an instance will set it; passing no arguments will retrieve it. If no previous instance has been registered, one will be lazy-loaded using defaults.

`setUserAgent` Zend_Http_UserAgent $userAgent

  If you have an instance of the helper -- for instance, by calling the view object's `getHelper()` method -- you may use this method to set the `UserAgent` instance.

`getUserAgent`

  Retrieves the `UserAgent` instance; if none is registered, it will lazy-load one using default values.