WorkflowD7Base.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * @file
  4. * Contains workflow\includes\Field\WorkflowD7Base.
  5. */
  6. /*
  7. * A Retrofit/Stub class, that contains the most basic functions of the D8 WidgetBase class.
  8. * It serves as a superclass to containe the $field and $instance array structures for the Field Type and the Widget.
  9. * @todo D8: Remove this class.
  10. */
  11. abstract class WorkflowD7Base {
  12. // Properties for Field and Widget.
  13. protected $field = array();
  14. protected $instance = array();
  15. // Properties for Field.
  16. protected $entity = NULL;
  17. protected $entity_type = '';
  18. /**
  19. * Constructor, stub for D8 WidgetBase.
  20. */
  21. public function __construct(array $field, array $instance, $entity_type = '', $entity = NULL) {
  22. if (!empty($entity) && !is_object($entity)) {
  23. throw new Exception('Entity should be an object.');
  24. }
  25. // Properties for Widget and Field.
  26. $this->field = $field;
  27. $this->instance = $instance;
  28. // Properties for FieldItem.
  29. $this->entity = $entity;
  30. $this->entity_type = $entity_type;
  31. }
  32. public function getField() {
  33. return $this->field;
  34. }
  35. public function getInstance() {
  36. return $this->instance;
  37. }
  38. public function delete() {
  39. }
  40. protected function getSettings() {
  41. $settings = isset($this->instance['widget']['settings']) ? $this->instance['widget']['settings'] : array();
  42. $field_info = self::settings();
  43. return $settings += $field_info['workflow']['settings'];
  44. }
  45. protected function getSetting($key) {
  46. if (isset($this->instance['widget']['settings'][$key])) {
  47. return $this->instance['widget']['settings'][$key];
  48. }
  49. else {
  50. $field_info = $this->settings();
  51. return $field_info['workflow']['settings'][$key];
  52. }
  53. }
  54. }