Ok, not sure why I was so hesitant with this approach, same could be said about partnerships and injecting a user serializer—
Sent from Mailbox for iPhone

On Sat, Feb 15, 2014 at 6:32 PM, Jeff Carouth <notifications@github.com>
wrote:

>> @@ -144,7 +144,32 @@
>>      $app->response->setStatus(200);
>>  });
>>  
>> -$app->get('/v1/skill/:id', function($id) use ($app) {
>> +$app->get('/v1/users', function() use ($app) {
>> +    $skillService = new \MentorApp\SkillService($app->db);
>> +    $skillSerializer = new \MentorApp\SkillArraySerializer();
>> +    $userService = new \MentorApp\UserService($app->db);
>> +    $userSerializer = new \MentorApp\UserArraySerializer();
>> +    $users = $userService->retrieveAll();
>> +    $response = array();
>> +    foreach ($users as $user) {
>> +        $learningSkills = $skillService->retrieveByIds($user->learningSkills);
>> +        $teachingSkills = $skillService->retrieveByIds($user->teachingSkills);
>> +        $serializedUser = $userSerializer->toArray($user);
>> +        $serializedUser['learningSkills'] = [];
>> +        $serializedUser['teachingSkills'] = [];
> Yeah that doesn't seem like a bad approach. The whold point of the serializer is to know how to translate a domain object into a basic data type for response. So if a `User` response is not valid without the skills arrays serializing a `User` should also serialize its value objects/composed properties, IMO. Thus, injecting a SkillArraySerializer is one way you could accomplish that goal.
> It has the benefit that it's miles better than having to handle this logic in the client code.
> ---
> Reply to this email directly or view it on GitHub:
> https://github.com/phpmentoring/mentor-app/pull/74/files#r9774987