You are here

function eck__deactivate_default_property in Entity Construction Kit (ECK) 7.3

Deactivate default properties.

1 string reference to 'eck__deactivate_default_property'
eck__bundle__menu in ./eck.bundle.inc
This function creates the menu items relevant to bundle administration.

File

./eck.default_properties.inc, line 50
Default properties are a grouping of a property and a behavior.

Code

function eck__deactivate_default_property($entity_type_name, $property) {
  $entity_type = EntityType::loadByName($entity_type_name);
  if (eck__is_default_property($property)) {

    // We have 2 cases, if it is active, do nothing.
    $properties = $entity_type->properties;
    if (!array_key_exists($property, $properties)) {
      drupal_set_message("{$property} is already inactive");
    }
    else {
      $entity_type
        ->removeProperty($property);
      $entity_type
        ->save();
      EntityType::loadAll(NULL, TRUE);
    }
  }
  else {
    drupal_set_message("{$property} is not a default property", "error");
  }

  // @todo if we can not use drupal goto, that could be better.
  drupal_goto(eck__entity_type__path() . "/{$entity_type->name}/property");
}