public function Bundle::save in Entity Construction Kit (ECK) 7.2
Same name and namespace in other branches
- 7.3 eck.classes.inc \Bundle::save()
Save the entity type.
Overrides DBObject::save
File
- ./
eck.classes.inc, line 574 - Classes for all the different objects used in ECK.
Class
- Bundle
- A bundle database object.
Code
public function save() {
// Lets do some checks before the bundle is saved.
if (isset($this->entity_type) && isset($this->name)) {
$save = TRUE;
// Lets set the machine name.
$this
->createMachineName();
// If this bundle isNew we need to check that it does not exist.
// @todo we just need to change the field in the db to be unique.
if ($this->isNew) {
$bundle = Bundle::loadByMachineName($this->machine_name);
if (!empty($bundle) && !$bundle->isNew) {
$save = FALSE;
}
}
if (!isset($this->label)) {
$this
->createLabel();
}
if ($save) {
parent::save();
global $_eck_bundles_cache;
$cache_enabled = isset($_eck_bundles_cache) ? TRUE : FALSE;
if ($cache_enabled) {
$_eck_bundles_cache
->reset();
}
eck_clean_up_request();
}
else {
// @todo throw some error.
}
}
else {
// If the name an entity type are not set, we can not save the bundle.
// @todo throw soem error or exception.
}
}