|
| __construct ($entityType) |
|
| create (array $values=[]) |
|
| unpublish ($ids, $transaction=NULL) |
|
| delete ($ids, $transaction=NULL) |
|
| setTitle ($entity, $title=NULL, $cache=[]) |
|
| setAlias ($entity, $alias=NULL, $cache=[]) |
|
| save ($entity, $cache=[]) |
|
| load ($ids=[], $conditions=[], $field_ids=[], $cache=TRUE) |
|
|
| attachLoad (&$queried_entities, $revision_id=FALSE, $field_ids=[]) |
|
TripalEntityController extends DrupalDefaultEntityController.
Our subclass of DrupalDefaultEntityController lets us add a few important create, update, and delete methods.
◆ attachLoad()
TripalEntityController::attachLoad |
( |
& |
$queried_entities, |
|
|
|
$revision_id = FALSE , |
|
|
|
$field_ids = [] |
|
) |
| |
|
protected |
Override the attachLoad function.
A TripalEntity may have a large number of fields attached which may slow down the loading of pages and web services. Therefore, we only want to attach fields that are needed.
- Parameters
-
$queried_entities | The list of queried |
$revision_id | ID of the revision that was loaded, or FALSE if the most current revision was loaded. |
$field_ids | |
◆ create()
TripalEntityController::create |
( |
array |
$values = [] | ) |
|
Create a Tripal data entity
We first set up the values that are specific to our data schema but then also go through the EntityAPIController function.
- Parameters
-
$type | The machine-readable type of the entity. |
- Returns
- An object with all default fields initialized.
◆ delete()
TripalEntityController::delete |
( |
|
$ids, |
|
|
|
$transaction = NULL |
|
) |
| |
Overrides EntityAPIController::delete().
- Parameters
-
array | $ids | An array of the ids denoting which entities to delete. |
DatabaseTransaction | $transaction | Optionally a DatabaseTransaction object to use. Allows overrides to pass in their transaction object. |
◆ load()
TripalEntityController::load |
( |
|
$ids = [] , |
|
|
|
$conditions = [] , |
|
|
|
$field_ids = [] , |
|
|
|
$cache = TRUE |
|
) |
| |
Override the load function.
A TripalEntity may have a large number of fields attached which may slow down the loading of pages and web services. Therefore, we only want to attach fields that are needed.
- Parameters
-
$ids | The list of entity IDs to load. |
$conditions | The list of key/value filters for querying the entity. |
$field_ids | The list of numeric field IDs for fields that should be attached. |
$cache | When loading of entities they can be cached with Drupal for later faster loading. However, this can cause memory issues when running Tripal jobs that load lots of entities. Caching of entities can be disabled to improve memory performance by setting this to FALSE. |
◆ save()
TripalEntityController::save |
( |
|
$entity, |
|
|
|
$cache = [] |
|
) |
| |
Saves a new entity.
- Parameters
-
$entity | A TripalEntity object to save. |
$cache | This array is used to store objects you want to cache for performance reasons, as well as, cache related options. The following are supported:
- boolean $clear_cached_fields Clearing cached fields is NECESSARY. IF you choose to set this to false then YOU must clear the cache yourself using cache_clear_all('field:TripalEntity:[entity_id]', 'cache_field', TRUE). The only known reason to set this to FALSE is to clear the cache in bulk for perfomance reasons.
- TripalBundle $bundle The bundle for the current entity.
- TripalTerm $term The term for the current entity.
|
- Returns
- The saved entity object with updated properties.
◆ setAlias()
TripalEntityController::setAlias |
( |
|
$entity, |
|
|
|
$alias = NULL , |
|
|
|
$cache = [] |
|
) |
| |
Sets the URL alias for an entity.
- Parameters
-
$entity | The entity whose URL alias should be changed. |
$alias | The alias to use. It can contain tokens the correspond to field values. Token should be be compatible with those returned by tripal_get_entity_tokens(). |
$cache | This array is used to store objects you want to cache for performance reasons, as well as, cache related options. The following are supported:
|
◆ setTitle()
TripalEntityController::setTitle |
( |
|
$entity, |
|
|
|
$title = NULL , |
|
|
|
$cache = [] |
|
) |
| |
Sets the title for an entity.
- Parameters
-
$entity | The entity whose title should be changed. |
$title | The title to use. It can contain tokens the correspond to field values. Token should be be compatible with those returned by tripal_get_entity_tokens(). |
$cache | This array is used to store objects you want to cache for performance reasons, as well as, cache related options. The following are supported:
|
◆ unpublish()
TripalEntityController::unpublish |
( |
|
$ids, |
|
|
|
$transaction = NULL |
|
) |
| |
Provides an unpublish function.
- Parameters
-
array | $ids | An array of the ids denoting which entities to delete. |
DatabaseTransaction | $transaction | Optionally a DatabaseTransaction object to use. Allows overrides to pass in their transaction object. |
The documentation for this class was generated from the following file:
- tripal/includes/TripalEntityController.inc