function eck_add_property_schema in Entity Construction Kit (ECK) 7
Generates schema definition for additional ECK properties.
Parameters
$&schema: Schema definition.
$property: Property to generate schema definition for.
2 calls to eck_add_property_schema()
- eck__entity_type__form_submit in ./
eck.entity_type.inc - Submit handler for adding and entity type.
- eck__entity_type__schema in ./
eck.entity_type.inc - Create the default schema for an entity type.
File
- ./
eck.properties.inc, line 24
Code
function eck_add_property_schema(&$schema, $entity_type, $property) {
if (!isset($schema['fields'])) {
$schema['fields'] = array();
}
switch ($property) {
case 'uuid':
// Prepend UUID field.
$schema['fields'] = array(
'uuid' => array(
'type' => 'char',
'length' => 36,
'not null' => TRUE,
'default' => '',
'description' => 'The Universally Unique Identifier.',
),
) + $schema['fields'];
break;
case 'uid':
// Append author id.
$schema['fields']['uid'] = array(
'description' => "The {users}.uid that owns this {$entity_type->name}; initially, this is the user that created it.",
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'initial' => $GLOBALS['user']->uid,
);
$schema['indexes']['uid'] = array(
'uid',
);
$schema['foreign keys']["{$entity_type->name}_author"] = array(
'table' => 'users',
'columns' => array(
'uid' => 'uid',
),
);
break;
case 'created':
// Append created timestamp.
$schema['fields']['created'] = array(
'description' => "The Unix timestamp when the {$entity_type->name} was created.",
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'initial' => REQUEST_TIME,
);
$schema['indexes']["{$entity_type->name}_created"] = array(
'created',
);
break;
case 'changed':
// Append changed timestamp.
$schema['fields']['changed'] = array(
'description' => "The Unix timestamp when the {$entity_type->name} was most recently saved.",
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'initial' => REQUEST_TIME,
);
$schema['indexes']["{$entity_type->name}_changed"] = array(
'changed',
);
break;
case 'state':
$schema['fields']['state'] = array(
'description' => "{$entity_type->name} state",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
);
break;
}
}