Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ogg group and pvb plugin #1

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mgurjanov
Copy link
Owner

@mgurjanov mgurjanov commented Jan 5, 2023

This PR is for the purpose of Gizra's home assignment for Drupal dev position (BE part). In order to test it you should:

  • clone this repo
  • switch to add_ogg_group_and_pvb_plugin branch
  • run command "ddev composer install"
  • run command "cp .ddev/config.local.yaml.example .ddev/config.local.yaml"
  • run command: "ddev restart"
  • in order to run test you should: "ddev drush cr && ddev phpunit --verbose --filter ServerGeneralOgGroupTest"
  • for manual testing you should create new content node of type "Group" and then visit that node as logged in user that is not the author of the mentioned node. Below you can see 3 situations and how OG group field looks like for different users:

1) Og group content type

001_gizra_ha_og_group_content_type

2) Adding node of OG group type

002_gizra_ha_og_group_content_node

3) Node created + view from node author user

003_gizra_ha_og_group_content_node_created

4) Group node as seen from anonymous user (showing default og group field)

004_gizra_ha_og_group_content_node_anonymous_user

5) Group node as seen from logged-in user that is not the node author (offering to request subscription but with overridden content showing username and group name)

005_gizra_ha_og_group_content_node_logged_user

This is based on Entity View Builder plugin that is overriding OG group entity display based on user role, login and group membership status. Styling is added just to make distinction for this message content as this was actually the task requirement.

6) Result of OG group test file

006_gizra_ha_og_group_test

private function checkMembershipAndSubscribeAccess(NodeInterface $entity, AccountInterface $account) {
$override = FALSE;

if ($account->isAuthenticated() && ($entity instanceof EntityOwnerInterface) && ($entity->getOwnerId() != $account->id())) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

`if (!$account->isAuthenticated()) {
// User is not auth ...
return FALSE;
}

$override = FALSE;

if ($account->isAuthenticated() && ($entity instanceof EntityOwnerInterface) && ($entity->getOwnerId() != $account->id())) {
if (!$this->ogMembershipManager->getMembership($entity, $account->id(), OgMembershipInterface::ALL_STATES)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This includes the Block state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants