TripalEntity.inc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * A class the controller will use for instantiating the TripalEntity entity.
  4. */
  5. class TripalEntity extends Entity {
  6. public function __construct($values = [], $entity_type) {
  7. parent::__construct($values, $entity_type);
  8. }
  9. protected function defaultLabel() {
  10. return $this->title;
  11. }
  12. protected function defaultUri() {
  13. return ['path' => 'TripalEntity/' . $this->id];
  14. }
  15. /**
  16. * Permanently saves the entity.
  17. *
  18. * @param $cache
  19. * This array is used to store objects you want to cache for performance
  20. * reasons, as well as, cache related options. The following are supported:
  21. * - boolean $clear_cached_fields
  22. * Clearing cached fields is NECESSARY. IF you choose to set this to
  23. * false then YOU must clear the cache yourself using
  24. * cache_clear_all('field:TripalEntity:[entity_id]', 'cache_field', TRUE).
  25. * The only known reason to set this to FALSE is to clear the cache in bulk
  26. * for perfomance reasons.
  27. * - TripalBundle $bundle
  28. * The bundle for the current entity.
  29. * - TripalTerm $term
  30. * The term for the current entity.
  31. *
  32. * @see entity_save()
  33. */
  34. public function save($cache = []) {
  35. return entity_get_controller($this->entityType)->save($this, $cache);
  36. }
  37. }