Using search criteria in modifyEntrySources plugin I have articles with a multi-select named theme.

This works fine in a template:

{% set entries = craft.entries.section('article').search('theme:themeFoobar') %}
&lt;p&gt;{{ entries | length }}&lt;/p&gt;


I'm working on a plugin to create a custom source containing only those articles that have themeFoobar selected in their multi-select, this is what I have:

public function modifyEntrySources(&amp;$sources, $context)
{
  $sources[] = array('heading' =&gt; 'Themes');

  $sources['theme:foobar'] = array(
    'label' =&gt; 'Theme: Foobar',
    'criteria' =&gt; array(
      'section' =&gt; 'article',
      'search' =&gt; 'theme:themeFoobar'
    )
  );
}


The result of this is that the source contains all articles, it looks like the search criteria is completely ignored.

Is search not the correct criteria to use here? Is there another criteria I can use to find only the articles with themeFoobar selected in the multi-select?

Further information

The multi-select used to be just a dropdown. When it was a dropdown, this plugin worked fine:

public function modifyEntrySources(&amp;$sources, $context)
{
  $sources[] = array('heading' =&gt; 'Themes');

  $sources['theme:foobar'] = array(
    'label' =&gt; 'Theme: Foobar',
    'criteria' =&gt; array(
      'section' =&gt; 'article',
      'theme' =&gt; 'themeFoobar'
    )
  );
}
My solution, thanks to @carlcs:

public function modifyEntrySources(&amp;$sources, $context)
{
    $sources[] = array('heading' =&gt; Craft::t('Themes'));

    $themes = array(
        'THEME_FOO' =&gt; 'themeFoo',
        'THEME_BAR' =&gt; 'themeBar'
    );

    $criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
    $criteria-&gt;section = 'article';
    $articles = $criteria-&gt;find();

    foreach ($themes as $theme =&gt; $label)
    {
        // Loop through all articles and check if they contain the current theme.
        // If they do, add it to the ids array which we will later use to filter
        // just the articles with this theme.
        $ids = [];
        foreach ($articles as $article)
        {
            foreach ($article-&gt;theme as $articleTheme)
            {
                if ($articleTheme == $themes[$theme])
                {
                    array_push($ids, $article-&gt;id);
                    break;
                }
            }
        }

        $sources['theme:' . $label] = array(
            'label' =&gt; Craft::t('Theme') . ': ' . Craft::t($theme),
            'criteria' =&gt; array(
                'section' =&gt; 'article',
                'id' =&gt; $ids
            )
        );
    }
}


The PHP itself could be cleaned up, but this works for now.

Categories would probably have been a simpler solution had I gone for that originally.