public function EntityType::addProperty in Entity Construction Kit (ECK) 7.2
Same name and namespace in other branches
- 7.3 eck.classes.inc \EntityType::addProperty()
Add a new property to the entity type.
Parameters
string $name: The name.
string $label: A label.
string $type: The type of the property.
string $behavior: A behavior to attach to the property.
File
- ./
eck.classes.inc, line 257 - Classes for all the different objects used in ECK.
Class
- EntityType
- An entity type database object.
Code
public function addProperty($name, $label, $type, $behavior = NULL) {
if (!$this->isNew) {
$this
->recordFieldChange('add', $name);
}
$p = $p2 = $this->properties;
// @todo check that type is an actual type.
$p[$name] = array(
'label' => $label,
'type' => $type,
'behavior' => $behavior,
);
$this->properties = $p;
// If the property did not exist already, let the behaviors execute some
// code.
if (!array_key_exists($name, $p2)) {
eck_property_behavior_invoke_plugin($this, 'property_add', array(
'name' => $name,
'property' => $p[$name],
'entity_type' => $this,
));
}
}