Roomify / bat_drupal

Booking and Availability Management Tools for Drupal 7 and Drupal 8
33 stars 7 forks source link

Support Entity API #25

Closed derimagia closed 7 years ago

derimagia commented 8 years ago

There are a decent amount of places where the Module does not adhere to the Entity API with the entity_metadata_wrapper properties, etc.

This should be cleaned up..

Specifically I have found so far:

  1. Event States are not in the API at all so you can't get the information programmatically using the Entity API. I started working on this but it was taking too much time so I haven't gotten back to it.
  2. Event Start Dates and End Dates are not in the API. Most likely because they are Datetimes which is not the same as Created/Updated/other things in Drupal. This may be a bigger issue that this is unlike every other module properties, but we can work around it if this is needed by creating custom getter/setter functions.

I'll continue to update this as I find more.

istos commented 8 years ago

Definitely would appreciate pull requests especially if you already spot the places with issues.

  1. What exactly are you trying to do for this. Event States are referenced using a field - where you working on improving that field's behavior?
  2. Getters and setters could be a good idea - there are a couple of gotchas in terms of what we need to do with dates when displaying to the user and saving them back to BAT but happy to work with you on a pull request. We are currently focusing on building a lot of the other functionality that BAT needs so would love some help on this.
derimagia commented 8 years ago

Right now you can't use entity_metadata_wrapper to query / set the event states like you can do it for entity reference fields. Not sure how familiar you are with this, but if you aren't take a look since it makes dealing with entities and fields a lot less painful:

https://www.drupal.org/documentation/entity-metadata-wrappers

Entity metadata wrapper is a must use for us when we use Drupal for Mobile Services, as I am currently using it for.

I started this work but for time sake for now all I did was do a field_info_alter so set the property type of the field to be "integer" so I can get/set the ID of the state at the very least for now. In an ideal world the getter would auto-load the state, similar to how entityreference works with EMW.