title: Symfony - Call to a member function setFunction() on null
body: <p>I wrote a code to return data but I keep getting an error "Call to a member function setFunction() on null"...</p>
  
  <p>My Service..</p>
  
  <pre><code>public function enableNotification($user)
  {
      $user-&gt;setNotification(1);
  
      $this-&gt;em-&gt;flush();
  }
  </code></pre>
  
  <p>My Controller..</p>
  
  <pre><code>   public function enableNotificationAction()
  {
      $user = $this-&gt;getUser();
  
      $this-&gt;container-&gt;get('my.route')-&gt;enableNotification($user);
  
      return $this-&gt;success('', 'true');
  }
  </code></pre>