class WsConfigType in Web Service Data 7
The class used for wsconfig type entities
Hierarchy
- class \Entity implements EntityInterface
- class \WsConfigType
Expanded class hierarchy of WsConfigType
1 string reference to 'WsConfigType'
- wsconfig_entity_info in modules/
wsconfig/ wsconfig.module - Implements hook_entity_info().
File
- modules/
wsconfig/ wsconfig.entity.inc, line 379 - Entity classes
View source
class WsConfigType extends Entity {
public $type;
public $label;
public function __construct($values = array()) {
parent::__construct($values, 'wsconfig_type');
if (is_array($this->data) and !isset($this->data['degraded_backoff'])) {
$this->data['degraded_backoff'] = WSCONFIG_DEFAULT_DEGRADED_BACKOFF;
}
}
/**
* Gets the enabled language plugin
*
* @return array|boolean
* Returns the language plugin and settings, FALSE otherwise.
*/
public function getEnabledLanguagePlugin() {
$plugin = FALSE;
if (!empty($this->data['language plugin'])) {
$plugin = array(
$this->data['language plugin'] => isset($this->data['language plugin settings']) ? $this->data['language plugin settings'] : array(),
);
}
return $plugin;
}
/*
* API function to get endpoint from the WSConfig Type
*/
public function setEndpoint($endpoint) {
$this->data['endpoint'] = $endpoint;
return true;
}
/*
* API function to set the endpoint in the WSConfig Type.
*/
public function getEndpoint() {
$endpoint = $this->data['endpoint'];
$matches = array();
preg_match_all('/\\$\\{(.+?)(:.+){0,1}\\}/', $endpoint, $matches);
if (!empty($matches[0])) {
for ($n = 0; $n < count($matches[0]); $n++) {
$default = '';
if (isset($matches[2][$n])) {
$default = drupal_substr($matches[2][$n], 1);
}
$replacements[] = (string) variable_get($matches[1][$n], $default);
}
$endpoint = str_replace($matches[0], $replacements, $endpoint);
}
return $endpoint;
}
/**
* API function to disabled this wsconfig type.
*/
public function disable($degraded = FALSE) {
$reason = '';
if ($degraded) {
if (!isset($this->data['degraded_backoff'])) {
$this->data['degraded_backoff'] = WSCONFIG_DEFAULT_DEGRADED_BACKOFF;
}
if ($this->data['degraded_backoff'] == 0) {
return;
}
$reason = ' ' . t('Automatically disabled due to degrated service.');
$this->data['degraded'] = time();
}
$this->data['disabled'] = TRUE;
watchdog('wsconfig', t('WSConfig Type %label (%type) was disabled.', array(
'%label' => $this->label,
'%type' => $this->type,
)) . $reason);
$this
->save();
}
/**
* API function to enabled this wsconfig type.
*/
public function enable($degraded = FALSE) {
unset($this->data['degraded']);
unset($this->data['disabled']);
$reason = '';
if ($degraded) {
$reason = ' ' . t('Automatically re-enabling previously degrated service.');
}
watchdog('wsconfig', t('WSConfig Type %label (%type) was enabled.', array(
'%label' => $this->label,
'%type' => $this->type,
)) . $reason);
$this
->save();
}
/**
* API function to check if this wsconfig type is disabled.
*/
public function isDisabled() {
if (!isset($this->data['degraded_backoff'])) {
$this->data['degraded_backoff'] = WSCONFIG_DEFAULT_DEGRADED_BACKOFF;
}
if (isset($this->data['degraded']) and $this->data['degraded'] < time() - $this->data['degraded_backoff']) {
$this
->enable(TRUE);
return FALSE;
}
return isset($this->data['disabled']) ? $this->data['disabled'] : FALSE;
}
public function getDegraded() {
if (!isset($this->data['degraded_backoff'])) {
$this->data['degraded_backoff'] = WSCONFIG_DEFAULT_DEGRADED_BACKOFF;
}
if (isset($this->data['degraded'])) {
return $this->data['degraded'] - time() + $this->data['degraded_backoff'];
}
return 0;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Entity:: |
protected | property | 1 | |
Entity:: |
protected | property | ||
Entity:: |
protected | property | ||
Entity:: |
protected | property | ||
Entity:: |
protected | property | ||
Entity:: |
public | function |
Builds a structured array representing the entity's content. Overrides EntityInterface:: |
1 |
Entity:: |
public | function |
Returns the bundle of the entity. Overrides EntityInterface:: |
|
Entity:: |
protected | function | Defines the entity label if the 'entity_class_label' callback is used. | 1 |
Entity:: |
protected | function | Override this in order to implement a custom default URI and specify 'entity_class_uri' as 'uri callback' hook_entity_info(). | |
Entity:: |
public | function |
Permanently deletes the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the info of the type of the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the type of the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Exports the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Gets the raw, translated value of a property or field. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Checks if the entity has a certain exportable status. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the entity identifier, i.e. the entities name or numeric id. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the internal, numeric identifier. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Checks whether the entity is the default revision. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the label of the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Permanently saves the entity. Overrides EntityInterface:: |
|
Entity:: |
protected | function | Set up the object instance on construction or unserializiation. | |
Entity:: |
public | function |
Returns the uri of the entity just as entity_uri(). Overrides EntityInterface:: |
|
Entity:: |
public | function |
Generate an array for rendering the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the EntityMetadataWrapper of the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function | Magic method to only serialize what's necessary. | |
Entity:: |
public | function | Magic method to invoke setUp() on unserialization. | |
WsConfigType:: |
public | property | ||
WsConfigType:: |
public | property | ||
WsConfigType:: |
public | function | API function to disabled this wsconfig type. | |
WsConfigType:: |
public | function | API function to enabled this wsconfig type. | |
WsConfigType:: |
public | function | ||
WsConfigType:: |
public | function | Gets the enabled language plugin | |
WsConfigType:: |
public | function | ||
WsConfigType:: |
public | function | API function to check if this wsconfig type is disabled. | |
WsConfigType:: |
public | function | ||
WsConfigType:: |
public | function |
Overrides Entity:: |