Both of this things are awesome, and it is already working, but it is a shame that you have to explicitly create a wrapper to get your setters, getters, and validation working with your properties. Currently ECK wraps the entity before saving it through the UI, but if someone is dealing with entities programatically, they will have to set up the wrapper themselves. I think ECK can provide an ECKEntity class that makes use of the wrapper seamlessly.

so instead of doing

$wrapper = entity_metadata_wrapper($entity_type, $entity);
$wrapper->some_property->set($value);

we can simply do

$entity->some_property = $value;

Going from 2 lines of code to 1 doesn't seem like a great improvement, but what it does mean is that if you are already using entities programatically, and you decide that you want to use the capabilities of the EntityMetadataWrapper, all you have to do is use hook_entity_property_info_alter to let the system know about your setter/getter/validator, and all your code should just work, no need to search all through your code wrapping your entities to get some validation.

I guess we could go a little further and abstract some of this thing with the property behavior system, so there won't be a need to be dealing with entity_property_info arrays directly.

Thoughts?

Comments

fmizzell’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev
Status: Active » Closed (fixed)

3.x implements this

josh waihi’s picture

Version: 7.x-3.x-dev » 7.x-2.x-dev
Issue summary: View changes
Status: Closed (fixed) » Needs work

Reopening this issue since 3.x is dead. Can we get this ported to 2.x?

dieterholvoet’s picture

Status: Needs work » Closed (won't fix)

We're dropping support for Drupal 7 since it has officially reached end of life on the 5th of January 2025.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.