class HostingFieldCleanup in Aegir Objects 7.3
@file The HostingFieldCleanup class.
Hierarchy
- class \HostingFieldCleanup
Expanded class hierarchy of HostingFieldCleanup
File
- classes/
HostingFieldCleanup.inc, line 6 - The HostingFieldCleanup class.
View source
class HostingFieldCleanup {
// The module for which we're handling cleanup.
protected $module = FALSE;
public function __construct($module) {
$this->module = $module;
}
/**
* Call this method when disabling a module.
*/
public function disableModule() {
return $this
->deleteFieldInstances();
}
/**
* Call this method when uninstalling a module.
*/
public function uninstallModule() {
return $this
->deleteFieldData();
}
/**
* Delete all fields instances defined in this module from their bundles.
*/
protected function deleteFieldInstances() {
if (module_load_include('inc', $this->module, $this->module . '.features.field_instance')) {
$function = $this->module . '_field_default_field_instances';
if (function_exists($function)) {
foreach ($function() as $instance) {
field_delete_instance($instance, FALSE);
}
}
}
}
/**
* Delete data for all fields defined in this module.
*/
protected function deleteFieldData() {
if (module_load_include('inc', $this->module, $this->module . '.features.field_base')) {
$function = $this->module . '_field_default_field_bases';
if (function_exists($function)) {
$fields = array_keys($function());
foreach ($fields as $field) {
field_delete_field($field);
}
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
HostingFieldCleanup:: |
protected | property | ||
HostingFieldCleanup:: |
protected | function | Delete data for all fields defined in this module. | |
HostingFieldCleanup:: |
protected | function | Delete all fields instances defined in this module from their bundles. | |
HostingFieldCleanup:: |
public | function | Call this method when disabling a module. | |
HostingFieldCleanup:: |
public | function | Call this method when uninstalling a module. | |
HostingFieldCleanup:: |
public | function |