I want to execute an entity query on a config entity type. However when I want to add an IN condition on a property which is an array I am getting an error.

For example, I want to retrieve all user roles that have the administer nodes permission:

$query = \Drupal::entityTypeManager()->getStorage('user_role')->getQuery();
$query->condition('permissions', ['administer nodes'], 'IN');

This gives the following error:

PHP Warning:  mb_strtolower() expects parameter 1 to be string, array given in core/lib/Drupal/Core/Config/Entity/Query/Condition.php on line 166

1 Answer 1


A config entity doesn't use a normalized table structure, so the normal array conditions which use JOIN don't work. Instead do a condition on property.*:

$query = \Drupal::entityTypeManager()->getStorage('user_role')->getQuery();
$query->condition('permissions.*', 'administer nodes');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.