|
@@ -223,7 +223,7 @@ function tripal_entities_entity_info() {
|
|
|
'module' => 'tripal_entities',
|
|
|
// Enable the entity API's admin UI.
|
|
|
'admin ui' => array (
|
|
|
- 'path' => 'admin/structure/bio_data',
|
|
|
+ 'path' => 'admin/structure/bio_data/' . $voc->db_id->name,
|
|
|
'controller class' => 'TripalDataTypeUIController',
|
|
|
'file' => 'includes/TripalDataTypeUIController.inc',
|
|
|
'menu wildcard' => '%tripal_data_type',
|
|
@@ -249,14 +249,17 @@ function tripal_entities_entity_info_alter(&$entity_info) {
|
|
|
// associated with a base entity type.
|
|
|
// We want to dynamically add the bundles (or term types) to the entity.
|
|
|
$cvterm = $term->cvterm_id;
|
|
|
- $bundle_id = $cvterm->dbxref_id->db_id->name . '_' . $cvterm->dbxref_id->accession;
|
|
|
+ $entity_type = $cvterm->dbxref_id->db_id->name;
|
|
|
+ $accession = $cvterm->dbxref_id->accession;
|
|
|
+ $bundle_id = $entity_type . '_' . $accession;
|
|
|
+
|
|
|
$label = preg_replace('/_/', ' ', ucwords($cvterm->name));
|
|
|
- $entity_info[$cvterm->dbxref_id->db_id->name]['bundles'][$bundle_id] = array (
|
|
|
+ $entity_info[$entity_type]['bundles'][$bundle_id] = array (
|
|
|
'label' => $label,
|
|
|
'admin' => array (
|
|
|
- 'path' => 'admin/structure/bio_data/manage/%tripal_data_type',
|
|
|
- 'real path' => 'admin/structure/bio_data/manage/' . $bundle_id,
|
|
|
- 'bundle argument' => 4,
|
|
|
+ 'path' => 'admin/structure/bio_data/' . $entity_type . '/manage/%tripal_data_type',
|
|
|
+ 'real path' => 'admin/structure/bio_data/' . $entity_type . '/manage/' . $bundle_id,
|
|
|
+ 'bundle argument' => 5,
|
|
|
'access arguments' => array (
|
|
|
'administer tripal data types'
|
|
|
)
|
|
@@ -296,4 +299,54 @@ function tripal_entities_get_published_terms_as_select_options($cv_id = NULL) {
|
|
|
}
|
|
|
}
|
|
|
return $options;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Menu argument loader; Load a tripal data type by string.
|
|
|
+ *
|
|
|
+ * @param $type
|
|
|
+ * The machine-readable name of a tripal data type to load.
|
|
|
+ * @return
|
|
|
+ * A tripal data type array or FALSE if $type does not exist.
|
|
|
+ */
|
|
|
+
|
|
|
+function tripal_data_type_load($bundle_type, $reset = FALSE) {
|
|
|
+ // Get the type of entity by the ID.
|
|
|
+ $bundle_types = db_select('tripal_data_type', 'tdt')
|
|
|
+ ->fields('tdt', array('id', 'type'))
|
|
|
+ ->condition('bundle', $bundle_type)
|
|
|
+ ->execute()
|
|
|
+ ->fetchObject();
|
|
|
+
|
|
|
+ // Load the tripal_data_type entity. These entities are always the same
|
|
|
+ // as an Tripal entity type but with a '_type' extension.
|
|
|
+ $entity = entity_load($bundle_types->type . '_type', array($bundle_types->id), array(), $reset);
|
|
|
+ return reset($entity);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Fetch a tripal_data object. Make sure that the wildcard you choose
|
|
|
+ * in the tripal_data entity definition fits the function name here.
|
|
|
+ *
|
|
|
+ * @param $id
|
|
|
+ * Integer specifying the tripal_data id.
|
|
|
+ * @param $reset
|
|
|
+ * A boolean indicating that the internal cache should be reset.
|
|
|
+ * @return
|
|
|
+ * A fully-loaded $tripal_data object or FALSE if it cannot be loaded.
|
|
|
+ *
|
|
|
+ * @see tripal_data_load_multiple()
|
|
|
+ */
|
|
|
+function tripal_data_load($id, $reset = FALSE) {
|
|
|
+
|
|
|
+ // Get the type of entity by the ID.
|
|
|
+ $entity_type = db_select('tripal_data', 'td')
|
|
|
+ ->fields('td', array('type'))
|
|
|
+ ->condition('id', $id)
|
|
|
+ ->execute()
|
|
|
+ ->fetchField();
|
|
|
+
|
|
|
+ // Load the entity.
|
|
|
+ $entity = entity_load($entity_type, array($id), array(), $reset);
|
|
|
+ return reset($entity);
|
|
|
}
|