public function remote__data::__construct
3.x remote__data.inc | public remote__data::__construct($field, $instance) |
Instantiates a new TripalField object.
Parameters
$field: An array containing the field data as returned by field_info_field().
$instance: An array containing the instance data as returned by field_instance_info().
Overrides TripalField::__construct
File
- tripal_ws/
includes/ TripalFields/ remote__data/ remote__data.inc, line 101
Class
- remote__data
- @class Purpose:
Code
public function __construct($field, $instance) {
parent::__construct($field, $instance);
// This field should not do anything if it is loaded via web-services.
// We don't want remote content to be available in web services. There
// is an if statement to not show this field in the web services but the
// entity_load function doesn't know this field shouldn't be loaded so
// we need to short-circuit that.
$_SERVER['REQUEST_URI'];
if (preg_match('/^web-services/', $_SERVER['REQUEST_URI'])) {
$this->loaded_via_ws = TRUE;
return;
}
// Get the site url from the tripal_sites table.
if (array_key_exists('data_info', $instance['settings'])) {
$site_id_ws = $instance['settings']['data_info']['remote_site'];
if ($site_id_ws) {
$this->remote_site = db_select('tripal_sites', 'ts')
->fields('ts')
->condition('ts.id', $site_id_ws)
->execute()
->fetchObject();
}
}
}