title: Symfony 4: Returning only active records
body: <p>I would like to only get records where the active indicator is true:</p>
  
  <pre><code>class Question {
     /**
      * One Question has one Figure
      * @ORM\OneToOne(targetEntity="QuestionFigure", mappedBy="question")
      */
      private $figure;
  
      public function getFigure()
      {   
       $criteria = Criteria::create()-&gt;where(Criteria::expr()-&gt;eq("active", true));
       return $this-&gt;figure-&gt;matching($criteria);
      }
  </code></pre>
  
  <p>When I do this, I get the error:</p>
  
  <pre><code>Attempted to call an undefined method named "matching" of class 
  </code></pre>
  
  <p>I believe this is because the matching method can only be applied to an ArrayCollection which $this->figure is not. What would be a similar way of achieving this same result?</p>
  
  <p>Edit based on answer provided by Ihor Kostrov:</p>
  
  <p>getActive() is returning nothing. Testing this out, this works:</p>
  
  <pre><code>public function getFigure()
      {
           if (!empty($this-&gt;figure) &amp;&amp; $this-&gt;figure-&gt;getId() === 1) {
              return $this-&gt;figure;
          }
  
          return null;
      }
  </code></pre>
  
  <p>But changing the id to 2 does not work ($this->figure->getId() === 2). I am thinking this is because of the one-to-one relationship doctrine only fetches one row?</p>