State.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /**
  3. * @file
  4. * Definition of Drupal\wing\Plugin\Core\Entity\State.
  5. */
  6. namespace Drupal\wing\Plugin\Core\Entity;
  7. use Drupal\Core\Entity\EntityInterface;
  8. use Drupal\Core\Entity\EntityNG;
  9. use Drupal\Component\Annotation\Plugin;
  10. use Drupal\Core\Annotation\Translation;
  11. /**
  12. * Defines the Wing State entity class.
  13. *
  14. * @Plugin(
  15. * id = "wing_state",
  16. * label = @Translation("Wing: State"),
  17. * bundle_label = @Translation("Workflow"),
  18. * module = "wing",
  19. * controller_class = "Drupal\wing\WingStorageController",
  20. * render_controller_class = "Drupal\wing\WingRenderController",
  21. * form_controller_class = {
  22. * "default" = "Drupal\wing\WingFormController"
  23. * },
  24. * translation_controller_class = "Drupal\wing\WingTranslationController",
  25. * base_table = "wing_state",
  26. * uri_callback = "wing_uri",
  27. * fieldable = FALSE,
  28. * static_cache = TRUE,
  29. * entity_keys = {
  30. * "id" = "id",
  31. * "bundle" = "workflow",
  32. * "label" = "title",
  33. * "uuid" = "uuid"
  34. * }
  35. * )
  36. */
  37. class State extends EntityNG implements EntityInterface { // Or ContentEntityInterface ?
  38. /**
  39. * The State ID.
  40. *
  41. * @var \Drupal\Core\Entity\Field\FieldInterface
  42. */
  43. public $id;
  44. /**
  45. * The State UUID.
  46. *
  47. * @var \Drupal\Core\Entity\Field\FieldInterface
  48. */
  49. public $uuid;
  50. /**
  51. * The State language code.
  52. *
  53. * @var \Drupal\Core\Entity\Field\FieldInterface
  54. */
  55. public $langcode;
  56. /**
  57. * The State title.
  58. *
  59. * @var \Drupal\Core\Entity\Field\FieldInterface
  60. */
  61. public $title;
  62. /**
  63. * The time that the State was created.
  64. *
  65. * @var \Drupal\Core\Entity\Field\FieldInterface
  66. */
  67. public $created;
  68. /**
  69. * The time that the State was last edited.
  70. *
  71. * @var \Drupal\Core\Entity\Field\FieldInterface
  72. */
  73. public $changed;
  74. /**
  75. * The workflow to which the State belongs.
  76. *
  77. * @var \Drupal\Core\Entity\Field\FieldInterface
  78. */
  79. public $workflow;
  80. /**
  81. * The plain data values of the contained properties.
  82. *
  83. * Define default values.
  84. *
  85. * @var array
  86. */
  87. protected $values = array(
  88. 'langcode' => array(LANGUAGE_DEFAULT => array(0 => array('value' => LANGUAGE_NOT_SPECIFIED))),
  89. );
  90. /**
  91. * Initialize the object. Invoked upon construction and wake up.
  92. */
  93. protected function init() {
  94. parent::init();
  95. // We unset all defined properties, so magic getters apply.
  96. $rc = new \ReflectionClass($this);
  97. $properties = $rc->getProperties(\ReflectionProperty::IS_PUBLIC);
  98. foreach ($properties as $property) {
  99. unset($this->{$property->name});
  100. }
  101. }
  102. /**
  103. * Implements Drupal\Core\Entity\EntityInterface::id().
  104. */
  105. public function id() {
  106. return $this->get('id')->value;
  107. }
  108. }