Tripal
Public Member Functions | Protected Member Functions | List of all members
TripalEntityController Class Reference
Inheritance diagram for TripalEntityController:
Inheritance graph
[legend]
Collaboration diagram for TripalEntityController:
Collaboration graph
[legend]

Public Member Functions

 __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)
 

Protected Member Functions

 attachLoad (&$queried_entities, $revision_id=FALSE, $field_ids=[])
 

Detailed Description

TripalEntityController extends DrupalDefaultEntityController.

Our subclass of DrupalDefaultEntityController lets us add a few important create, update, and delete methods.

Member Function Documentation

◆ 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_entitiesThe list of queried
$revision_idID 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
$typeThe 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$idsAn array of the ids denoting which entities to delete.
DatabaseTransaction$transactionOptionally 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
$idsThe list of entity IDs to load.
$conditionsThe list of key/value filters for querying the entity.
$field_idsThe list of numeric field IDs for fields that should be attached.
$cacheWhen 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
$entityA TripalEntity object to save.
$cacheThis 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
$entityThe entity whose URL alias should be changed.
$aliasThe 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().
$cacheThis 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
$entityThe entity whose title should be changed.
$titleThe 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().
$cacheThis 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$idsAn array of the ids denoting which entities to delete.
DatabaseTransaction$transactionOptionally a DatabaseTransaction object to use. Allows overrides to pass in their transaction object.

The documentation for this class was generated from the following file: