LTIToolProviderConsumerEntityController.class.php

  1. cis7 sites/all/modules/ulmus/lti_tool_provider/LTIToolProviderConsumerEntityController.class.php
  2. cle7 sites/all/modules/ulmus/lti_tool_provider/LTIToolProviderConsumerEntityController.class.php
  3. ecd7 sites/all/modules/ulmus/lti_tool_provider/LTIToolProviderConsumerEntityController.class.php
  4. elmsmedia7 sites/all/modules/ulmus/lti_tool_provider/LTIToolProviderConsumerEntityController.class.php
  5. harmony7 sites/all/modules/ulmus/lti_tool_provider/LTIToolProviderConsumerEntityController.class.php
  6. icor7 sites/all/modules/ulmus/lti_tool_provider/LTIToolProviderConsumerEntityController.class.php
  7. meedjum_blog7 sites/all/modules/ulmus/lti_tool_provider/LTIToolProviderConsumerEntityController.class.php
  8. mooc7 sites/all/modules/ulmus/lti_tool_provider/LTIToolProviderConsumerEntityController.class.php

Contains LTIToolProviderConsumerEntityController.

Classes

Interfaces

File

sites/all/modules/ulmus/lti_tool_provider/LTIToolProviderConsumerEntityController.class.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Contains LTIToolProviderConsumerEntityController.
  5. */
  6. interface LTIToolProviderConsumerEntityControllerInterface
  7. extends DrupalEntityControllerInterface {
  8. /**
  9. * Create.
  10. */
  11. public function create();
  12. /**
  13. * Save.
  14. *
  15. * @param object $entity
  16. * The consumer.
  17. */
  18. public function save($entity);
  19. /**
  20. * Delete.
  21. *
  22. * @param object $entity
  23. * The consumer.
  24. */
  25. public function delete($entity);
  26. }
  27. class LTIToolProviderConsumerEntityController
  28. extends DrupalDefaultEntityController
  29. implements LTIToolProviderConsumerEntityControllerInterface {
  30. /**
  31. * Create a consumer.
  32. *
  33. * @return object
  34. * The consumer.
  35. */
  36. public function create() {
  37. $entity = new stdClass();
  38. $entity->lti_tool_provider_consumer_id = 0;
  39. $entity->lti_tool_provider_consumer_key = '';
  40. $entity->lti_tool_provider_consumer_secret = '';
  41. $entity->lti_tool_provider_consumer_consumer = '';
  42. $entity->lti_tool_provider_consumer_domain = '';
  43. $entity->lti_tool_provider_consumer_dummy_pref = FALSE;
  44. $extra_cols = lti_tool_provider_get_extra_columns();
  45. foreach ($extra_cols as $col) {
  46. $entity->$col = '';
  47. }
  48. return $entity;
  49. }
  50. /**
  51. * Save a consumer.
  52. *
  53. * @param object $entity
  54. * The consumer.
  55. *
  56. * @return object|boolean
  57. * The consumer or false if save failed.
  58. */
  59. public function save($entity) {
  60. $transaction = db_transaction();
  61. try {
  62. $entity->is_new = empty($enity->lti_tool_provider_consumer_id);
  63. if (empty($entity->date_joined)) {
  64. $entity->date_joined = REQUEST_TIME;
  65. }
  66. field_attach_presave('lti_tool_provider_consumer', $entity);
  67. $primary_key = $entity->lti_tool_provider_consumer_id ? 'lti_tool_provider_consumer_id' : array();
  68. if (empty($primary_key)) {
  69. drupal_write_record('lti_tool_provider_consumer', $entity);
  70. field_attach_insert('lti_tool_provider_consumer', $entity);
  71. $op = 'insert';
  72. }
  73. else {
  74. drupal_write_record('lti_tool_provider_consumer', $entity, $primary_key);
  75. $op = 'update';
  76. }
  77. $function = 'field_attach_' . $op;
  78. $function('lti_tool_provider_consumer', $entity);
  79. module_invoke_all('entity_' . $op, $entity, 'lti_tool_provider_consumer');
  80. unset($entity->is_new);
  81. db_ignore_slave();
  82. return $entity;
  83. }
  84. catch (Exception $e) {
  85. $transaction->rollback();
  86. drupal_set_message(t('%e', array('%e' => $entity->$e)));
  87. watchdog_exception('lti_tool_provider_consumer', $e, NULL, WATCHDOG_ERROR);
  88. return FALSE;
  89. }
  90. }
  91. /**
  92. * Delete a consumer.
  93. *
  94. * @param object $entity
  95. * The consumer.
  96. */
  97. public function delete($entity) {
  98. $this->deleteMultiple(array($entity));
  99. }
  100. /**
  101. * Delete multiple consumers.
  102. *
  103. * @param array $entities
  104. * An array of consumers.
  105. *
  106. * @throws Exception
  107. * From the db api.
  108. */
  109. public function deleteMultiple($entities) {
  110. $ids = array();
  111. if (!empty($entities)) {
  112. $transaction = db_transaction();
  113. try {
  114. foreach ($entities as $entity) {
  115. module_invoke_all('lti_tool_provider_consumer_delete', $entity);
  116. // Invoke hook_entity_delete().
  117. module_invoke_all('entity_delete', $entity, 'lti_tool_provider_consumer');
  118. field_attach_delete('lti_tool_provider_consumer', $entity);
  119. $ids[] = $entity->lti_tool_provider_consumer_id;
  120. }
  121. db_delete('lti_tool_provider_consumer')
  122. ->condition('lti_tool_provider_consumer_id', $ids, 'IN')
  123. ->execute();
  124. }
  125. catch (Exception $e) {
  126. $transaction->rollback();
  127. watchdog_exception('lti_tool_provider_consumer', $e);
  128. throw $e;
  129. }
  130. }
  131. }
  132. }
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.