protalk/protalk — pull request #228 by Tocacar (2014-03-28 14:47:20+00:00)
Title: Fix calls to API for media list

Fixes issue #221

The 'api_media_list' route was throwing an exception on line 105 of /ApiBundle/Helper/CMMIDataHelper.php

```
if(isset($iterator[$this->identifier]) === false) {
throw new HttpException(Codes::HTTP_BAD_REQUEST, 'Cannot add resource, identifier not known in the iterator');
}
```

The value of $this->identifier is 'slug'. The problem was occuring because the APIBundle:MediaController:fetchMediaItems method was getting an array of objects from the MediaRepository query it invoked, instead of an array of arrays(!!). The hydrator mode passed to the MediaRepository method was not being used in the query.

isset($iterator[$this->identifier]) was failing in the CMMIDataHelper class because the object properties held by $iterator were private, hence the need for an array instead of an entity object.