Using relatedTo programatically? I'm trying to extend the ElementCriteriaModel using the guide here:

https://blog.tighten.co/craft-cms-building-complex-queries-by-extending-the-elementcriteriamodel 

However I need to re-implement relatedTo keyword somehow. This is what I have so far but doesn't seem to work at all

    $criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Category);
    $criteria-&gt;slug = 'seasonal-event';
    $criteria-&gt;limit = 1;

    $category = $criteria-&gt;find();

    $this-&gt;criteria-&gt;relatedTo = array(
        'targetElement' =&gt; $category
    );

    return $this;
You're using $criteria, but attempting to set the relatedTo property on $this-&gt;criteria.

Assuming that's not the issue, have you tried using $criteria-&gt;setAttribute('relatedTo', ['targetElement' =&gt; $category])?

I've found setAttribute to be more reliable than the ElementCriteriaModel magic methods.