title: Symfony- passing an array of ids
body: <p>I wrote an api with a function that sets notification as read by passing it's id.</p>
  
  <p>But also, there should be an option to pass array of ids there, to mark several at once as read. I should extend function so that it handles the case where $this>data['id'] is an array.</p>
  
  <p>Is this the right way?</p>
  
  <p>My Service:</p>
  
  <pre><code> public function read($id = []){
  
   $notification = $this-&gt;getRepository()-&gt;findBy([
          'id' =&gt; $id
      ]);
  
      if($notification) {
         $notification[0]-&gt;setRead(new \DateTime());
         $this-&gt;em-&gt;flush();
      }
  }
  </code></pre>
  
  <p>My Controller:</p>
  
  <pre><code>public function readAction()
  {
      $this-&gt;requirePostParams(['id']);
      $this-&gt;get('app')-&gt;read(
          $this-&gt;data['id']
      );
  
      return $this-&gt;success();
  }
  </code></pre>