Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
EAuth Class Reference

Public Member Functions

 getServices ()
 getServiceType ($service)
 getIdentity ($service)
 redirect ($url, $jsRedirect=true)
 renderWidget ($properties=array())
 toString ($identity)
 fromString ($identity)

Public Attributes

 $services = array()
 $popup = true

Protected Member Functions

 getService ($service)

Detailed Description

Definition at line 14 of file EAuth.php.

Member Function Documentation

EAuth::fromString (   $identity)

Serialize the identity class.

Parameters
string$identityserialized value.
Returns
EAuthServiceBase the class instance.

Definition at line 144 of file EAuth.php.

{
return unserialize($identity);
}
EAuth::getIdentity (   $service)

Returns the service identity class.

Parameters
string$servicethe service name.
Returns
IAuthService the identity class.

Definition at line 82 of file EAuth.php.

Referenced by getServices().

{
$service = strtolower($service);
if (!isset($this->services[$service]))
throw new EAuthException(Yii::t('eauth', 'Undefined service name: {service}.', array('{service}' => $service)), 500);
$service = $this->services[$service];
$class = $service['class'];
$point = strrpos($class, '.');
// if it is yii path alias
if ($point > 0) {
Yii::import($class);
$class = substr($class, $point + 1);
}
unset($service['class']);
$identity = new $class();
$identity->init($this, $service);
return $identity;
}
EAuth::getService (   $service)
protected

Returns the settings of the service.

Parameters
string$servicethe service name.
Returns
array the service settings.

Definition at line 59 of file EAuth.php.

References getServices().

Referenced by getServiceType().

{
$service = strtolower($service);
$services = $this->getServices();
if (!isset($services[$service]))
throw new EAuthException(Yii::t('eauth', 'Undefined service name: {service}.', array('{service}' => $service)), 500);
return $services[$service];
}
EAuth::getServices ( )

Returns services settings declared in the authorization classes. For perfomance reasons it uses Yii::app()->cache to store settings array.

Returns
array services settings.

Definition at line 31 of file EAuth.php.

References getIdentity().

Referenced by getService().

{
if (Yii::app()->hasComponent('cache'))
$services = Yii::app()->cache->get('EAuth.services');
if (!isset($services) || !is_array($services)) {
$services = array();
foreach ($this->services as $service => $options) {
if ((!isset($options['class']) || $options['class']=='')) {
continue;
}
$class = $this->getIdentity($service);
$services[$service] = (object) array(
'id' => $class->getServiceName(),
'title' => $class->getServiceTitle(),
'type' => $class->getServiceType(),
'jsArguments' => $class->getJsArguments(),
);
}
if (Yii::app()->hasComponent('cache'))
Yii::app()->cache->set('EAuth.services', $services);
}
return $services;
}
EAuth::getServiceType (   $service)

Returns the type of the service.

Parameters
string$servicethe service name.
Returns
string the service type.

Definition at line 72 of file EAuth.php.

References getService().

{
$service = $this->getService($service);
return $service->type;
}
EAuth::redirect (   $url,
  $jsRedirect = true 
)

Redirects to url. If the authorization dialog opened in the popup window, it will be closed instead of redirect. Set $jsRedirect=true if you want to redirect anyway.

Parameters
mixed$urlurl to redirect. Can be route or normal url. See CHtml::normalizeUrl.
boolean$jsRedirectwhether to use redirect while popup window is used. Defaults to true.

Definition at line 108 of file EAuth.php.

{
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'EAuthRedirectWidget.php';
$widget = Yii::app()->getWidgetFactory()->createWidget($this, 'EAuthRedirectWidget', array(
'url' => CHtml::normalizeUrl($url),
'redirect' => $jsRedirect,
));
$widget->init();
$widget->run();
}
EAuth::renderWidget (   $properties = array())

Simple wrapper for CController::widget function for render the EAuthWidget widget.

Parameters
array$propertiesthe widget properties.
Deprecated:
use CComponent->widget('ext.eauth.EAuthWidget', $properties) instead.

Definition at line 123 of file EAuth.php.

{
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'EAuthWidget.php';
$widget = Yii::app()->getWidgetFactory()->createWidget($this, 'EAuthWidget', $properties);
$widget->init();
$widget->run();
}
EAuth::toString (   $identity)

Serialize the identity class.

Parameters
EAuthServiceBase$identitythe class instance.
Returns
string serialized value.

Definition at line 135 of file EAuth.php.

{
return serialize($identity);
}

The documentation for this class was generated from the following file: