title: Error: Call to a member function on array
body: <p>I'm trying to get the products from my selection in the Category object but I gives me the following error</p>
  
  <blockquote>
    <p>Error: Call to a member function getProducts() on array in
    /Users/jurrejan/Documents/projects/audsur2/src/Audsur/ShopBundle/Controller/DefaultController.php
    line 94</p>
  </blockquote>
  
  <p>Where am I going wrong?</p>
  
  <p>The object has multiple products</p>
  
  <pre><code>array(1) {
    [0]=&gt;
    object(stdClass)#329 (6) {
      ["__CLASS__"]=&gt;
      string(33) "Audsur\ShopBundle\Entity\Category"
      ["id"]=&gt;
      int(4)
      ["name"]=&gt;
      string(8) "Receiver"
      ["slug"]=&gt;
      string(8) "receiver"
      ["description"]=&gt;
      string(5) "descr"
      ["products"]=&gt;
      array(47) {
        [0]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [1]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [2]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [3]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [4]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [5]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [6]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [7]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [8]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [9]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [10]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [11]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [12]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [13]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [14]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [15]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [16]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [17]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [18]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [19]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [20]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [21]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [22]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [23]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [24]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [25]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [26]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [27]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [28]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [29]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [30]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [31]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [32]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [33]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [34]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [35]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [36]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [37]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [38]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [39]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [40]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [41]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [42]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [43]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [44]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [45]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
        [46]=&gt;
        string(32) "Audsur\ShopBundle\Entity\Product"
      }
    }
  }
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>&lt;?php
  
  namespace Audsur\ShopBundle\Controller;
  
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  
  use Audsur\ShopBundle\Entity\Category;
  use Audsur\ShopBundle\Entity\Brand;
  use Audsur\ShopBundle\Entity\Product;
  use Symfony\Component\HttpFoundation\Response;
  
  class DefaultController extends Controller
  {
      /* removed irrelevant functions */
  
      public function getGroupAction($slug, $type = null, $grouped = true)
      {
  
          $group = $this-&gt;getDoctrine()
              -&gt;getRepository('AudsurShopBundle:'.$type)
              -&gt;findBy(array( 'name' =&gt; $slug ))
              -&gt;getProducts();
  
  
          return $this-&gt;render('AudsurShopBundle:Default:productOverview.html.twig', array(
                  'group' =&gt; $group
              )
          );
  
      }
  
  }
  </code></pre>
  
  <p>src/Audsur/ShopBundle/Entity/Category.php</p>
  
  <pre><code>&lt;?php
  
  namespace Audsur\ShopBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Doctrine\Common\Collections\ArrayCollection;
  
  /**
   * @ORM\Entity
   * @ORM\Table(name="category")
   */
  class Category
  {
      /**
       * @ORM\Column(type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      protected $id;
  
      /**
       * @ORM\Column(type="string", length=100, unique=true)
       */
      protected $name;
  
      /**
       * @ORM\Column(type="string", length=255, nullable=false, unique=true)
       */
      protected $slug;
  
      /**
       * @ORM\Column(type="text")
       */
      protected $description;
  
      /**
       * @ORM\OneToMany(targetEntity="Product", mappedBy="category")
       */
      protected $products;
  
      public function __construct()
      {
          $this-&gt;products = new ArrayCollection();
      }
  
  
      /**
       * Get id
       *
       * @return integer 
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Set name
       *
       * @param string $name
       * @return Category
       */
      public function setName($name)
      {
          $this-&gt;name = $name;
  
          return $this;
      }
  
      /**
       * Get name
       *
       * @return string 
       */
      public function getName()
      {
          return $this-&gt;name;
      }
  
      /**
       * Set slug
       *
       * @param string $slug
       * @return Category
       */
      public function setSlug($slug)
      {
          $this-&gt;slug = $slug;
  
          return $this;
      }
  
      /**
       * Get slug
       *
       * @return string 
       */
      public function getSlug()
      {
          return $this-&gt;slug;
      }
  
      /**
       * Set description
       *
       * @param string $description
       * @return Category
       */
      public function setDescription($description)
      {
          $this-&gt;description = $description;
  
          return $this;
      }
  
      /**
       * Get description
       *
       * @return string 
       */
      public function getDescription()
      {
          return $this-&gt;description;
      }
  
      /**
       * Add products
       *
       * @param \Audsur\ShopBundle\Entity\Product $products
       * @return Category
       */
      public function addProduct(\Audsur\ShopBundle\Entity\Product $products)
      {
          $this-&gt;products[] = $products;
  
          return $this;
      }
  
      /**
       * Remove products
       *
       * @param \Audsur\ShopBundle\Entity\Product $products
       */
      public function removeProduct(\Audsur\ShopBundle\Entity\Product $products)
      {
          $this-&gt;products-&gt;removeElement($products);
      }
  
      /**
       * Get products
       *
       * @return \Doctrine\Common\Collections\Collection 
       */
      public function getProducts()
      {
          return $this-&gt;products;
      }
  }
  </code></pre>