How to fiend entities when using domain access ?
Example 1 : Without changing user session.
$query = \Drupal::entityQuery('node');
$query->condition(DOMAIN_ACCESS_FIELD, 'domain_id'); // Set the domain id hear
$query->condition('type', 'article');
$query->condition('status', 1);
$nids = $query->execute();
print_r($nids);
If you can't get all domains data, do as the Example 2.
Example 2 : Using admin user session.
// Call the account switcher service
$accountSwitcher = \Drupal::service('account_switcher');
// Switch to the admin user
$accountSwitcher->switchTo(new \Drupal\Core\Session\UserSession(['uid' => 1]));
$query = \Drupal::entityQuery('node');
$query->condition(DOMAIN_ACCESS_FIELD, 'domain_id'); // Set the domain id hear
$query->condition('type', 'article');
$query->condition('status', 1);
$nids = $query->execute();
print_r($nids);
// Switch back to old session.
$accountSwitcher->switchBack();
Comments
essay writing services
I am glad to read your post Thank you so much .keep sharing this Insightful Drupal. It's a happy for me to read your article. Keep spread out information so that everyone will be aware of this. I would like you to recommend high quality essay content from custom essay writing services it is helpful to students who are studying in higher studies.
Search Entities when using Domain Access
Thanks for the code. He will definitely help me finish my programming work. By the way, I am currently developing a college essay writing service. How do you like the code?
https://grademiners.com/
Thank you for the code. The…
Thank you for the code. The part with using admin user changing was exactly what I looked for. Check this out as well https://express-essays.com
This code helped me a lot…
This code helped me a lot. Thank you for sharing. I have one useful link for those, who need writing help:
https://buy-essays-online.com/reliable-dissertation-results-writing-age…
The answer is detailed and…
The answer is detailed and useful, thanks!
https://primewritings.org/case-study-writing-service.php
Add new comment