#55 works for Drupal 10.2.6 / Page manager4.0@RC
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}');
}
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.
@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 ).
@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: { }
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
yurg β created an issue.
The patch works in 2024.
The patch works for Dompdf 2.0.4 update as well.
For those found this in 2024: drupal_get_path() is deprecated.
Now it is \Drupal::service('extension.list.module')->getPath('commerce')
@marcoliver
Thank you, it looks working with the most recent Version: 3.1.30
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.
@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.
@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))
cheers all, this patch https://www.drupal.org/comment/15025671#comment-15025671 β works indeed!
[3269449#comment-14462850] is a lifesaver, cheers @vflirt
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]);
}