Abstract Class yii\authclient\BaseOAuth

Inheritanceyii\authclient\BaseOAuth » yii\authclient\BaseClient » yii\base\Component
Implementsyii\authclient\ClientInterface
Subclassesyii\authclient\OAuth1, yii\authclient\OAuth2, yii\authclient\OpenIdConnect, yii\authclient\clients\Facebook, yii\authclient\clients\GitHub, yii\authclient\clients\Google, yii\authclient\clients\GoogleHybrid, yii\authclient\clients\LinkedIn, yii\authclient\clients\Live, yii\authclient\clients\Twitter, yii\authclient\clients\TwitterOAuth2, yii\authclient\clients\VKontakte, yii\authclient\clients\Yandex
Available since extension's version2.0
Source Code https://github.com/yiisoft/yii2-authclient/blob/master/src/BaseOAuth.php

BaseOAuth is a base class for the OAuth clients.

See also http://oauth.net/.

Public Properties

Hide inherited properties

Property Type Description Defined By
$accessToken yii\authclient\OAuthToken Auth token instance. yii\authclient\BaseOAuth
$apiBaseUrl string API base URL. yii\authclient\BaseOAuth
$authUrl string Authorize URL. yii\authclient\BaseOAuth
$autoRefreshAccessToken boolean Whether to automatically perform 'refresh access token' request on expired access token. yii\authclient\BaseOAuth
$httpClient \yii\httpclient\Client Internal HTTP client. yii\authclient\BaseClient
$id string Service id. yii\authclient\BaseClient
$name string Service name. yii\authclient\BaseClient
$normalizeUserAttributeMap array Normalize user attribute map. yii\authclient\BaseClient
$requestOptions array HTTP request options. yii\authclient\BaseClient
$returnUrl string Return URL. yii\authclient\BaseOAuth
$scope string Auth request scope. yii\authclient\BaseOAuth
$signatureMethod yii\authclient\signature\BaseMethod Signature method instance. yii\authclient\BaseOAuth
$stateStorage yii\authclient\StateStorageInterface Stage storage. yii\authclient\BaseClient
$title string Service title. yii\authclient\BaseClient
$userAttributes array List of user attributes. yii\authclient\BaseClient
$version string Protocol version. yii\authclient\BaseOAuth
$viewOptions array View options in format: optionName => optionValue. yii\authclient\BaseClient

Public Methods

Hide inherited methods

Method Description Defined By
api() Performs request to the OAuth API returning response data. yii\authclient\BaseOAuth
applyAccessTokenToRequest() Applies access token to the HTTP request instance. yii\authclient\BaseOAuth
beforeApiRequestSend() Handles Request::EVENT_BEFORE_SEND event. yii\authclient\BaseOAuth
createApiRequest() Creates an HTTP request for the API call. yii\authclient\BaseOAuth
createRequest() Creates HTTP request instance. yii\authclient\BaseClient
getAccessToken() yii\authclient\BaseOAuth
getHttpClient() Returns HTTP client. yii\authclient\BaseClient
getId() yii\authclient\BaseClient
getName() yii\authclient\BaseClient
getNormalizeUserAttributeMap() yii\authclient\BaseClient
getRequestOptions() yii\authclient\BaseClient
getReturnUrl() yii\authclient\BaseOAuth
getSignatureMethod() yii\authclient\BaseOAuth
getStateStorage() yii\authclient\BaseClient
getTitle() yii\authclient\BaseClient
getUserAttributes() yii\authclient\BaseClient
getViewOptions() yii\authclient\BaseClient
refreshAccessToken() Gets new auth token to replace expired one. yii\authclient\BaseOAuth
setAccessToken() Sets access token to be used. yii\authclient\BaseOAuth
setHttpClient() Sets HTTP client to be used. yii\authclient\BaseOAuth
setId() yii\authclient\BaseClient
setName() yii\authclient\BaseClient
setNormalizeUserAttributeMap() yii\authclient\BaseClient
setRequestOptions() yii\authclient\BaseClient
setReturnUrl() yii\authclient\BaseOAuth
setSignatureMethod() Set signature method to be used. yii\authclient\BaseOAuth
setStateStorage() yii\authclient\BaseClient
setTitle() yii\authclient\BaseClient
setUserAttributes() yii\authclient\BaseClient
setViewOptions() yii\authclient\BaseClient

Protected Methods

Hide inherited methods

Method Description Defined By
composeUrl() Composes URL from base URL and GET params. yii\authclient\BaseOAuth
createHttpClient() Creates HTTP client instance from reference or configuration. yii\authclient\BaseOAuth
createSignatureMethod() Creates signature method instance from its configuration. yii\authclient\BaseOAuth
createToken() Creates token from its configuration. yii\authclient\BaseOAuth
defaultName() Generates service name. yii\authclient\BaseClient
defaultNormalizeUserAttributeMap() Returns the default $normalizeUserAttributeMap value. yii\authclient\BaseClient
defaultRequestOptions() Returns default HTTP request options. yii\authclient\BaseOAuth
defaultReturnUrl() Composes default $returnUrl value. yii\authclient\BaseOAuth
defaultTitle() Generates service title. yii\authclient\BaseClient
defaultViewOptions() Returns the default $viewOptions value. yii\authclient\BaseClient
getState() Returns persistent state value. yii\authclient\BaseClient
getStateKeyPrefix() Returns session key prefix, which is used to store internal states. yii\authclient\BaseClient
initUserAttributes() Initializes authenticated user attributes. yii\authclient\BaseClient
normalizeUserAttributes() Normalize given user attributes according to $normalizeUserAttributeMap. yii\authclient\BaseClient
removeState() Removes persistent state value. yii\authclient\BaseClient
restoreAccessToken() Restores access token. yii\authclient\BaseOAuth
saveAccessToken() Saves token as persistent state. yii\authclient\BaseOAuth
sendRequest() Sends the given HTTP request, returning response data. yii\authclient\BaseOAuth
setState() Sets persistent state. yii\authclient\BaseClient

Property Details

Hide inherited properties

$accessToken public property

Auth token instance. Note that the type of this property differs in getter and setter. See getAccessToken() and setAccessToken() for details.

$apiBaseUrl public property

API base URL. This field will be used as \yii\httpclient\Client::baseUrl value of $httpClient. Note: changing this property will take no effect after $httpClient is instantiated.

public string $apiBaseUrl null
$authUrl public property

Authorize URL.

public string $authUrl null
$autoRefreshAccessToken public property (available since version 2.0.6)

Whether to automatically perform 'refresh access token' request on expired access token.

$returnUrl public property

Return URL.

public string $returnUrl null
$scope public property

Auth request scope.

public string $scope null
$signatureMethod public property

Signature method instance. Note that the type of this property differs in getter and setter. See getSignatureMethod() and setSignatureMethod() for details.

$version public property

Protocol version.

public string $version '1.0'

Method Details

Hide inherited methods

api() public method

Performs request to the OAuth API returning response data.

You may use createApiRequest() method instead, gaining more control over request execution.

See also createApiRequest().

public api( string $apiSubUrl, string $method 'GET', array|string $data = [], array $headers = [] ): array
$apiSubUrl string

API sub URL, which will be append to $apiBaseUrl, or absolute API URL.

$method string

Request method.

$data array|string

Request data or content.

$headers array

Additional request headers.

return array

API response data.

                public function api($apiSubUrl, $method = 'GET', $data = [], $headers = [])
{
    $request = $this->createApiRequest()
        ->setMethod($method)
        ->setUrl($apiSubUrl)
        ->addHeaders($headers);
    if (!empty($data)) {
        if (is_array($data)) {
            $request->setData($data);
        } else {
            $request->setContent($data);
        }
    }
    return $this->sendRequest($request);
}

            
applyAccessTokenToRequest() public abstract method (available since version 2.1)

Applies access token to the HTTP request instance.

public abstract applyAccessTokenToRequest( \yii\httpclient\Request $request, yii\authclient\OAuthToken $accessToken ): mixed
$request \yii\httpclient\Request

HTTP request instance.

$accessToken yii\authclient\OAuthToken

Access token instance.

                abstract public function applyAccessTokenToRequest($request, $accessToken);

            
beforeApiRequestSend() public method (available since version 2.1)

Handles Request::EVENT_BEFORE_SEND event.

Applies $accessToken to the request.

public beforeApiRequestSend( \yii\httpclient\RequestEvent $event ): mixed
$event \yii\httpclient\RequestEvent

Event instance.

throws \yii\base\Exception

on invalid access token.

                public function beforeApiRequestSend($event)
{
    $accessToken = $this->getAccessToken();
    if (!is_object($accessToken) || !$accessToken->getIsValid()) {
        throw new Exception('Invalid access token.');
    }
    $this->applyAccessTokenToRequest($event->request, $accessToken);
}

            
composeUrl() protected method

Composes URL from base URL and GET params.

protected composeUrl( string $url, array $params = [] ): string
$url string

Base URL.

$params array

GET params.

return string

Composed URL.

                protected function composeUrl($url, array $params = [])
{
    if (!empty($params)) {
        if (strpos($url, '?') === false) {
            $url .= '?';
        } else {
            $url .= '&';
        }
        $url .= http_build_query($params, '', '&', PHP_QUERY_RFC3986);
    }
    return $url;
}

            
createApiRequest() public method (available since version 2.1)

Creates an HTTP request for the API call.

The created request will be automatically processed adding access token parameters and signature before sending. You may use createRequest() to gain full control over request composition and execution.

See also createRequest().

public createApiRequest( ): \yii\httpclient\Request
return \yii\httpclient\Request

HTTP request instance.

                public function createApiRequest()
{
    $request = $this->createRequest();
    $request->on(Request::EVENT_BEFORE_SEND, [$this, 'beforeApiRequestSend']);
    return $request;
}

            
createHttpClient() protected method (available since version 2.1)

Creates HTTP client instance from reference or configuration.

protected createHttpClient( mixed $reference ): \yii\httpclient\Client
$reference mixed

Component name or array configuration.

return \yii\httpclient\Client

HTTP client instance.

                protected function createHttpClient($reference)
{
    $httpClient = parent::createHttpClient($reference);
    $httpClient->baseUrl = $this->apiBaseUrl;
    return $httpClient;
}

            
createRequest() public method (available since version 2.1)

Defined in: yii\authclient\BaseClient::createRequest()

Creates HTTP request instance.

public createRequest( ): \yii\httpclient\Request
return \yii\httpclient\Request

HTTP request instance.

                public function createRequest()
{
    return $this->getHttpClient()
        ->createRequest()
        ->addOptions($this->defaultRequestOptions())
        ->addOptions($this->getRequestOptions());
}

            
createSignatureMethod() protected method

Creates signature method instance from its configuration.

protected createSignatureMethod( array $signatureMethodConfig ): yii\authclient\signature\BaseMethod
$signatureMethodConfig array

Signature method configuration.

return yii\authclient\signature\BaseMethod

Signature method instance.

                protected function createSignatureMethod(array $signatureMethodConfig)
{
    if (!array_key_exists('class', $signatureMethodConfig)) {
        $signatureMethodConfig['class'] = signature\HmacSha1::className();
    }
    return Yii::createObject($signatureMethodConfig);
}

            
createToken() protected method

Creates token from its configuration.

protected createToken( array $tokenConfig = [] ): yii\authclient\OAuthToken
$tokenConfig array

Token configuration.

return yii\authclient\OAuthToken

Token instance.

                protected function createToken(array $tokenConfig = [])
{
    if (!array_key_exists('class', $tokenConfig)) {
        $tokenConfig['class'] = OAuthToken::className();
    }
    return Yii::createObject($tokenConfig);
}

            
defaultName() protected method

Defined in: yii\authclient\BaseClient::defaultName()

Generates service name.

protected defaultName( ): string
return string

Service name.

                protected function defaultName()
{
    return Inflector::camel2id(StringHelper::basename(get_class($this)));
}

            
defaultNormalizeUserAttributeMap() protected method

Defined in: yii\authclient\BaseClient::defaultNormalizeUserAttributeMap()

Returns the default $normalizeUserAttributeMap value.

Particular client may override this method in order to provide specific default map.

protected defaultNormalizeUserAttributeMap( ): array
return array

Normalize attribute map.

                protected function defaultNormalizeUserAttributeMap()
{
    return [];
}

            
defaultRequestOptions() protected method (available since version 2.1)

Returns default HTTP request options.

protected defaultRequestOptions( ): array
return array

HTTP request options.

                protected function defaultRequestOptions()
{
    return [
        'userAgent' => Yii::$app->name . ' OAuth ' . $this->version . ' Client',
        'timeout' => 30,
        'sslVerifyPeer' => false,
    ];
}

            
defaultReturnUrl() protected method

Composes default $returnUrl value.

protected defaultReturnUrl( ): string
return string

Return URL.

                protected function defaultReturnUrl()
{
    return Yii::$app->getRequest()->getAbsoluteUrl();
}

            
defaultTitle() protected method

Defined in: yii\authclient\BaseClient::defaultTitle()

Generates service title.

protected defaultTitle( ): string
return string

Service title.

                protected function defaultTitle()
{
    return StringHelper::basename(get_class($this));
}

            
defaultViewOptions() protected method

Defined in: yii\authclient\BaseClient::defaultViewOptions()

Returns the default $viewOptions value.

Particular client may override this method in order to provide specific default view options.

protected defaultViewOptions( ): array
return array

List of default $viewOptions

                protected function defaultViewOptions()
{
    return [];
}

            
getAccessToken() public method

public getAccessToken( ): yii\authclient\OAuthToken
return yii\authclient\OAuthToken

Auth token instance.

                public function getAccessToken()
{
    if (!is_object($this->_accessToken)) {
        $this->_accessToken = $this->restoreAccessToken();
    }
    return $this->_accessToken;
}

            
getHttpClient() public method (available since version 2.1)

Defined in: yii\authclient\BaseClient::getHttpClient()

Returns HTTP client.

public getHttpClient( ): \yii\httpclient\Client
return \yii\httpclient\Client

Internal HTTP client.

                public function getHttpClient()
{
    if (!is_object($this->_httpClient)) {
        $this->_httpClient = $this->createHttpClient($this->_httpClient);
    }
    return $this->_httpClient;
}

            
getId() public method
public getId( ): string
return string

Service id

                public function getId()
{
    if (empty($this->_id)) {
        $this->_id = $this->getName();
    }
    return $this->_id;
}

            
getName() public method
public getName( ): string
return string

Service name.

                public function getName()
{
    if ($this->_name === null) {
        $this->_name = $this->defaultName();
    }
    return $this->_name;
}

            
getNormalizeUserAttributeMap() public method
public getNormalizeUserAttributeMap( ): array
return array

Normalize user attribute map.

                public function getNormalizeUserAttributeMap()
{
    if ($this->_normalizeUserAttributeMap === null) {
        $this->_normalizeUserAttributeMap = $this->defaultNormalizeUserAttributeMap();
    }
    return $this->_normalizeUserAttributeMap;
}

            
getRequestOptions() public method (available since version 2.1)
public getRequestOptions( ): array
return array

HTTP request options.

                public function getRequestOptions()
{
    return $this->_requestOptions;
}

            
getReturnUrl() public method

public getReturnUrl( ): string
return string

Return URL.

                public function getReturnUrl()
{
    if ($this->_returnUrl === null) {
        $this->_returnUrl = $this->defaultReturnUrl();
    }
    return $this->_returnUrl;
}

            
getSignatureMethod() public method

public getSignatureMethod( ): yii\authclient\signature\BaseMethod
return yii\authclient\signature\BaseMethod

Signature method instance.

                public function getSignatureMethod()
{
    if (!is_object($this->_signatureMethod)) {
        $this->_signatureMethod = $this->createSignatureMethod($this->_signatureMethod);
    }
    return $this->_signatureMethod;
}

            
getState() protected method

Defined in: yii\authclient\BaseClient::getState()

Returns persistent state value.

protected getState( string $key ): mixed
$key string

State key.

return mixed

State value.

                protected function getState($key)
{
    return $this->getStateStorage()->get($this->getStateKeyPrefix() . $key);
}

            
getStateKeyPrefix() protected method

Defined in: yii\authclient\BaseClient::getStateKeyPrefix()

Returns session key prefix, which is used to store internal states.

protected getStateKeyPrefix( ): string
return string

Session key prefix.

                protected function getStateKeyPrefix()
{
    return get_class($this) . '_' . $this->getId() . '_';
}

            
getStateStorage() public method
public getStateStorage( ): yii\authclient\StateStorageInterface
return yii\authclient\StateStorageInterface

Stage storage.

                public function getStateStorage()
{
    if (!is_object($this->_stateStorage)) {
        $this->_stateStorage = Yii::createObject($this->_stateStorage);
    }
    return $this->_stateStorage;
}

            
getTitle() public method
public getTitle( ): string
return string

Service title.

                public function getTitle()
{
    if ($this->_title === null) {
        $this->_title = $this->defaultTitle();
    }
    return $this->_title;
}

            
getUserAttributes() public method
public getUserAttributes( ): array
return array

List of user attributes

                public function getUserAttributes()
{
    if ($this->_userAttributes === null) {
        $this->_userAttributes = $this->normalizeUserAttributes($this->initUserAttributes());
    }
    return $this->_userAttributes;
}

            
getViewOptions() public method
public getViewOptions( ): array
return array

View options in format: optionName => optionValue

                public function getViewOptions()
{
    if ($this->_viewOptions === null) {
        $this->_viewOptions = $this->defaultViewOptions();
    }
    return $this->_viewOptions;
}

            
initUserAttributes() protected abstract method

Defined in: yii\authclient\BaseClient::initUserAttributes()

Initializes authenticated user attributes.

protected abstract initUserAttributes( ): array
return array

Auth user attributes.

                abstract protected function initUserAttributes();

            
normalizeUserAttributes() protected method

Defined in: yii\authclient\BaseClient::normalizeUserAttributes()

Normalize given user attributes according to $normalizeUserAttributeMap.

protected normalizeUserAttributes( array $attributes ): array
$attributes array

Raw attributes.

return array

Normalized attributes.

throws \yii\base\InvalidConfigException

on incorrect normalize attribute map.

                protected function normalizeUserAttributes($attributes)
{
    foreach ($this->getNormalizeUserAttributeMap() as $normalizedName => $actualName) {
        if (is_scalar($actualName)) {
            if (array_key_exists($actualName, $attributes)) {
                $attributes[$normalizedName] = $attributes[$actualName];
            }
        } else {
            if (is_callable($actualName)) {
                $attributes[$normalizedName] = call_user_func($actualName, $attributes);
            } elseif (is_array($actualName)) {
                $haystack = $attributes;
                $searchKeys = $actualName;
                $isFound = true;
                while (($key = array_shift($searchKeys)) !== null) {
                    if (is_array($haystack) && array_key_exists($key, $haystack)) {
                        $haystack = $haystack[$key];
                    } else {
                        $isFound = false;
                        break;
                    }
                }
                if ($isFound) {
                    $attributes[$normalizedName] = $haystack;
                }
            } else {
                throw new InvalidConfigException('Invalid actual name "' . gettype($actualName) . '" specified at "' . get_class($this) . '::normalizeUserAttributeMap"');
            }
        }
    }
    return $attributes;
}

            
refreshAccessToken() public abstract method

Gets new auth token to replace expired one.

public abstract refreshAccessToken( yii\authclient\OAuthToken $token ): yii\authclient\OAuthToken
$token yii\authclient\OAuthToken

Expired auth token.

return yii\authclient\OAuthToken

New auth token.

                abstract public function refreshAccessToken(OAuthToken $token);

            
removeState() protected method

Defined in: yii\authclient\BaseClient::removeState()

Removes persistent state value.

protected removeState( string $key ): boolean
$key string

State key.

return boolean

Success.

                protected function removeState($key)
{
    return $this->getStateStorage()->remove($this->getStateKeyPrefix() . $key);
}

            
restoreAccessToken() protected method

Restores access token.

protected restoreAccessToken( ): yii\authclient\OAuthToken
return yii\authclient\OAuthToken

Auth token.

                protected function restoreAccessToken()
{
    $token = $this->getState('token');
    if (is_object($token)) {
        /* @var $token OAuthToken */
        if ($token->getIsExpired() && $this->autoRefreshAccessToken) {
            $token = $this->refreshAccessToken($token);
        }
    }
    return $token;
}

            
saveAccessToken() protected method

Saves token as persistent state.

protected saveAccessToken( yii\authclient\OAuthToken|null $token ): $this
$token yii\authclient\OAuthToken|null

Auth token to be saved.

return $this

The object itself.

                protected function saveAccessToken($token)
{
    return $this->setState('token', $token);
}

            
sendRequest() protected method (available since version 2.1)

Sends the given HTTP request, returning response data.

protected sendRequest( \yii\httpclient\Request $request ): array
$request \yii\httpclient\Request

HTTP request to be sent.

return array

Response data.

throws yii\authclient\InvalidResponseException

on invalid remote response.

                protected function sendRequest($request)
{
    $response = $request->send();
    if (!$response->getIsOk()) {
        throw new InvalidResponseException($response, 'Request failed with code: ' . $response->getStatusCode() . ', message: ' . $response->getContent());
    }
    return $response->getData();
}

            
setAccessToken() public method

Sets access token to be used.

public setAccessToken( array|yii\authclient\OAuthToken $token ): mixed
$token array|yii\authclient\OAuthToken

Access token or its configuration.

                public function setAccessToken($token)
{
    if (!is_object($token) && $token !== null) {
        $token = $this->createToken($token);
    }
    $this->_accessToken = $token;
    $this->saveAccessToken($token);
}

            
setHttpClient() public method (available since version 2.1)

Sets HTTP client to be used.

public setHttpClient( mixed $httpClient ): mixed
$httpClient mixed

Internal HTTP client.

                public function setHttpClient($httpClient)
{
    if (is_object($httpClient)) {
        $httpClient = clone $httpClient;
        $httpClient->baseUrl = $this->apiBaseUrl;
    }
    parent::setHttpClient($httpClient);
}

            
setId() public method
public setId( string $id ): mixed
$id string

Service id.

                public function setId($id)
{
    $this->_id = $id;
}

            
setName() public method
public setName( string $name ): mixed
$name string

Service name.

                public function setName($name)
{
    $this->_name = $name;
}

            
setNormalizeUserAttributeMap() public method
public setNormalizeUserAttributeMap( array $normalizeUserAttributeMap ): mixed
$normalizeUserAttributeMap array

Normalize user attribute map.

                public function setNormalizeUserAttributeMap($normalizeUserAttributeMap)
{
    $this->_normalizeUserAttributeMap = $normalizeUserAttributeMap;
}

            
setRequestOptions() public method (available since version 2.1)
public setRequestOptions( array $options ): mixed
$options array

HTTP request options.

                public function setRequestOptions(array $options)
{
    $this->_requestOptions = $options;
}

            
setReturnUrl() public method

public setReturnUrl( string $returnUrl ): mixed
$returnUrl string

Return URL

                public function setReturnUrl($returnUrl)
{
    $this->_returnUrl = $returnUrl;
}

            
setSignatureMethod() public method

Set signature method to be used.

public setSignatureMethod( array|yii\authclient\signature\BaseMethod $signatureMethod ): mixed
$signatureMethod array|yii\authclient\signature\BaseMethod

Signature method instance or its array configuration.

throws \yii\base\InvalidParamException

on wrong argument.

                public function setSignatureMethod($signatureMethod)
{
    if (!is_object($signatureMethod) && !is_array($signatureMethod)) {
        throw new InvalidParamException('"' . get_class($this) . '::signatureMethod" should be instance of "\yii\autclient\signature\BaseMethod" or its array configuration. "' . gettype($signatureMethod) . '" has been given.');
    }
    $this->_signatureMethod = $signatureMethod;
}

            
setState() protected method

Defined in: yii\authclient\BaseClient::setState()

Sets persistent state.

protected setState( string $key, mixed $value ): $this
$key string

State key.

$value mixed

State value

return $this

The object itself

                protected function setState($key, $value)
{
    $this->getStateStorage()->set($this->getStateKeyPrefix() . $key, $value);
    return $this;
}

            
setStateStorage() public method
public setStateStorage( yii\authclient\StateStorageInterface|array|string $stateStorage ): mixed
$stateStorage yii\authclient\StateStorageInterface|array|string

Stage storage to be used.

                public function setStateStorage($stateStorage)
{
    $this->_stateStorage = $stateStorage;
}

            
setTitle() public method
public setTitle( string $title ): mixed
$title string

Service title.

                public function setTitle($title)
{
    $this->_title = $title;
}

            
setUserAttributes() public method
public setUserAttributes( array $userAttributes ): mixed
$userAttributes array

List of user attributes

                public function setUserAttributes($userAttributes)
{
    $this->_userAttributes = $this->normalizeUserAttributes($userAttributes);
}

            
setViewOptions() public method
public setViewOptions( array $viewOptions ): mixed
$viewOptions array

View options in format: optionName => optionValue

                public function setViewOptions($viewOptions)
{
    $this->_viewOptions = $viewOptions;
}