You are here

function eck__activate_default_property in Entity Construction Kit (ECK) 7.3

Activate default properties.

1 string reference to 'eck__activate_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 24
Default properties are a grouping of a property and a behavior.

Code

function eck__activate_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 active");
    }
    else {
      $info = eck_get_default_property($property);
      $entity_type
        ->addProperty($property, $info['label'], $info['type'], $info['behavior']);
      $entity_type
        ->save();
      EntityType::loadAll(NULL, TRUE);
    }
  }
  else {
    drupal_set_message("{$property} is not a default property", "error");
  }

  // @todo more uses of goto??
  drupal_goto(eck__entity_type__path() . "/{$entity_type->name}/property");
}