πŸ‡ΈπŸ‡°Slovakia @yurg

Account created on 2 March 2006, almost 19 years ago
#

Recent comments

πŸ‡ΈπŸ‡°Slovakia yurg

yurg β†’ created an issue.

πŸ‡ΈπŸ‡°Slovakia yurg

#55 works for Drupal 10.2.6 / Page manager4.0@RC

πŸ‡ΈπŸ‡°Slovakia yurg

Had to add two more Devel-related routes to #5 for Drupal 10.2.6 / Page Manager 4.0.0-rc2.

if ($entity_types['page']->hasLinkTemplate('devel-definition')) {
    $entity_types['page']->setLinkTemplate('devel-definition', '/devel/page/{page}');
  }
  if ($entity_types['page']->hasLinkTemplate('devel-load-with-references')) {
    $entity_types['page']->setLinkTemplate('devel-load-with-references', '/devel/page/{page}');
  }
πŸ‡ΈπŸ‡°Slovakia yurg

Well then, it's all about Tokens indeed: have had to use Rules token chaining to get right ones.
Here is the list in case someone needs it, basically, we add the "target_id" everywhere:

- Customer UID: [commerce_order:uid:target_id]
Makes sense for logged-in user only.

- Store ID: [commerce_order:store_id:target_id]
ID of a Store the purchased product belongs to.

- Store owner ID: [commerce_order:store_id:entity:uid:target_id]

- Group ID: [commerce_order:store_id:entity:field_group_reference:target_id]
field_group_reference here is a name of your Store Entity Reference field, referencing Groups.
Same should work for the other reference fields.

πŸ‡ΈπŸ‡°Slovakia yurg

@jurgenhaas Thank you, it's tokens issue indeed and it should be a [simple] matter of retrieving proper IDs from orders and filling the correct combination of Group ID / UUID, Entity ID / UUID and Entity fields. And finding out why would a member be added twice ( have tried with hard-coded tokens already ).

πŸ‡ΈπŸ‡°Slovakia yurg

@jurgenhaas Thank you for your note! We've been trying to escalate permissions by user switch - should have been easy since a Store owner and a Group creator is the same UID ([commerce_order:store_id:entity:uid] in our case).
Wrong Successors perhaps?

uuid: fa4067bd-f1ab-474e-84bb-213925c3ca6c
langcode: en
status: true
dependencies:
  module:
    - eca_commerce
    - eca_user
    - group_action
id: newordertagall
modeller: core
label: 'Add customer to a Group'
version: ''
weight: -10
events:
  eca_commerce_order_create:
    plugin: 'eca_commerce:order_create'
    label: 'Order: Create'
    configuration: {  }
    successors:
      -
        id: eca_switch_account
        condition: null
      -
        id: group_add_member
        condition: null
conditions: {  }
gateways: {  }
actions:
  eca_switch_account:
    plugin: eca_switch_account
    label: 'User: switch current account'
    configuration:
      user_id: '[commerce_order:store_id:entity:uid]'
    successors:
      -
        id: group_add_member
        condition: null
  group_add_member:
    plugin: group_add_member
    label: 'Group: add customer as member'
    configuration:
      values: {  }
      operation: create
      content_plugin: group_membership
      group_id: '[commerce_order:store_id:entity:field_group_reference:id]'
      entity_id: ''
      add_method: skip_existing
      object: '[commerce_order:uid:entity]'
      replace_tokens: false
    successors: {  }

πŸ‡ΈπŸ‡°Slovakia yurg

Additional Drush output

$ ddev drush cr 
PHP Fatal error:  Could not check compatibility between Drupal\webprofiler\Entity\GroupRelationshipTypeStorageDecorator::loadByGroupType(Drupal\webprofiler\Entity\GroupTypeInterface $group_type) and Drupal\group\Entity\Storage\GroupRelationshipTypeStorageInterface::loadByGroupType(Drupal\group\Entity\GroupTypeInterface $group_type), because class Drupal\webprofiler\Entity\GroupTypeInterface is not available in /var/www/html/web/sites/default/files/php/webprofiler/group_relationship_type/5HXngiDWe6IlMRJW-ClAlbhu78jCQXE2B5E74bEnGUc.php on line 11

Fatal error: Could not check compatibility between Drupal\webprofiler\Entity\GroupRelationshipTypeStorageDecorator::loadByGroupType(Drupal\webprofiler\Entity\GroupTypeInterface $group_type) and Drupal\group\Entity\Storage\GroupRelationshipTypeStorageInterface::loadByGroupType(Drupal\group\Entity\GroupTypeInterface $group_type), because class Drupal\webprofiler\Entity\GroupTypeInterface is not available in /var/www/html/web/sites/default/files/php/webprofiler/group_relationship_type/5HXngiDWe6IlMRJW-ClAlbhu78jCQXE2B5E74bEnGUc.php on line 11

πŸ‡ΈπŸ‡°Slovakia yurg

The patch works for Dompdf 2.0.4 update as well.

πŸ‡ΈπŸ‡°Slovakia yurg

For those found this in 2024: drupal_get_path() is deprecated.
Now it is \Drupal::service('extension.list.module')->getPath('commerce')

πŸ‡ΈπŸ‡°Slovakia yurg

@marcoliver
Thank you, it looks working with the most recent Version: 3.1.30

πŸ‡ΈπŸ‡°Slovakia yurg

There are a lot of
"

Drupal\Component\Plugin\Exception\ContextException: The 'entity:user' context is required and not present. in Drupal\Core\Plugin\Context\Context->getContextValue()

" mentions across the versions.

For me the #44 πŸ› User context missing when using toUrl in some circumstances Needs work is a life-saver. Thanks.

πŸ‡ΈπŸ‡°Slovakia yurg

@marcoliver Thank you, have tried the patch with the latest Drupal 10.1.6 upgrade. Almost there, there is a block of code where empty $user throws an error, please see below:

  • Error: Call to a member function getRoles() on null in Drupal\permissions_by_term\Service\AccessCheck->isAccessAllowedByDatabase() (line 165 of /permissions_by_term/src/Service/AccessCheck.php).
  • Error: Call to a member function id() on null in Drupal\permissions_by_term\Service\AccessCheck->isAccessAllowedByDatabase() (line 175 of /permissions_by_term/src/Service/AccessCheck.php).

After wrapping foreach ($user->getRoles() as $sUserRole) { to if(!empty($user)) { the issue is gone. Well, mostly: there is a lot of The 'entity:user' context is required and not present. but I suppose it comes from somewhere else.
Thank you for all your help.

πŸ‡ΈπŸ‡°Slovakia yurg

@sarwan_verma, @sahana _N thank you, there is one more place in the code to edit, it is at line 85 near the "(int) $user->id()":

if ((int) $user->id() !== (int) $node->getOwnerId() && !$node->isPublished()) {
      return FALSE;
    }

I'd also checked a few lines starting from the line 56:

    if (empty($uid)) {
      $uid = \Drupal::currentUser()->id();
    }
    $user = User::load($uid);

How about this (from https://api.drupal.org/api/drupal/core%21lib%21Drupal.php/function/Drupa...):

$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()
  ->id());

Also we may want to handle anonymous users, e.g.

if ($uid === 0)
// or
if(isset($user))
πŸ‡ΈπŸ‡°Slovakia yurg

In our case (all defaults, incl. subtheme name) it was "drupal8_w3css_theme/d8w3css-gfin-open-sans" to find:

function drupal8_w3css_subtheme_page_attachments_alter(array &$attachments) {
 // print_r($attachments);
  $gfex_open_sans = array_search('drupal8_w3css_theme/d8w3css-gfin-open-sans', $attachments['#attached']['library'], TRUE);
  unset($attachments['#attached']['library'][$gfex_open_sans]);
}
Production build 0.71.5 2024