Convert og_is_member to Og:isMember and add test coverage#53
Conversation
There was a problem hiding this comment.
We need to create a map of the group ids as getEntityGroups currently returns a map of membership_id > group entity for each type.
|
This is blocker number 1 for #40 |
2ceab76 to
4ac5d1e
Compare
|
@amitaibu @RoySegall this is looking pretty good. |
There was a problem hiding this comment.
I think maybe it's a good time to replace the arguments with the entity objects, so it will be isMember(EntityInterface $group_entity, EntityInterface $entity) instead. Thoughts?
There was a problem hiding this comment.
Yeah I would Def prefer this but just kept it the same. I am happy to
change it here though.
On 30 Nov 2015 18:11, "Amitai Burstein" notifications@github.com wrote:
In src/Og.php
#53 (comment):
- * The entity type of the group.
- * @param string|int $group_id
- * The group ID.
- * @param string $entity_type
- * The entity type.
- * @param string|int $entity_id
- * The entity ID.
- * @param array $states
- * (optional) Array with the state to return. If empty groups of all state
- * will return.
- * @return bool
- * TRUE if the entity (e.g. the user) belongs to a group and is not pending
- * or blocked.
- */
- public static function isMember($group_entity_type, $group_id, $entity_type, $entity_id = NULL, $states = [OG_STATE_ACTIVE]) {
I think maybe it's a good time to replace the arguments with the entity
objects, so it will be isMember(EntityInterface $group_entity,
EntityInterface $entity) instead. Thoughts?—
Reply to this email directly or view it on GitHub
https://github.com/amitaibu/og/pull/53/files#r46179638.
There was a problem hiding this comment.
Go for it. Back in D7 I took the approach that if we must get the entity type, then at least we won't force getting the entity object, and maybe save some entity loading. I prefer the D8 way :)
|
@amitaibu Should all be addressed now. Having the entities as parameters instead is soooo much nicer :) |
There was a problem hiding this comment.
btw, sometimes we call it $entity_type, and sometimes $entity_type_id. Lets go with $entity_type and $bundle?
There was a problem hiding this comment.
I don't mind too much, trouble with that is now that D8 has $entity_type, which can be an EntityType object, just the ID.
There was a problem hiding this comment.
I don't mind too much
Me neither, just want to be consistent. I could go with $entity_type_id as-well.
There was a problem hiding this comment.
OK. I think I've been using the _id suffixed versions. So go with that??
On 1 Dec 2015 10:50, "Amitai Burstein" notifications@github.com wrote:
In src/Og.php
#53 (comment):@@ -117,7 +116,10 @@ public static function createField($plugin_id, $entity_type, $bundle, array $set
* the OG membership ID and the group ID as the value. If nothing found,
* then an empty array.
*/
- public static function getEntityGroups($entity_type, $entity_id, $states = [OG_STATE_ACTIVE], $field_name = NULL) {
- public static function getEntityGroups(EntityInterface $entity, $states = [OG_STATE_ACTIVE], $field_name = NULL) {
- $entity_type = $entity->getEntityTypeId();
I don't mind too much
Me neither, just want to be consistent. I could go with $entity_type_id
as-well.—
Reply to this email directly or view it on GitHub
https://github.com/amitaibu/og/pull/53/files#r46264240.
Convert og_is_member to Og:isMember and add test coverage
This converts the method and adds new test coverage for it. The
EntityGroupsTestalso coversOg::getEntityGroupsasOg::isMemberis basically that and doesn't currently have coverage.