/** * Convert POST relationship values to an array of Entity objects keyed by * ContentType. * * @param Content $content * @param array|null $formValues */ private function setPostedRelations(Content $content, $formValues) { if (!isset($formValues['relation'])) { return; } $entities = []; foreach ($formValues['relation'] as $contentType => $relations) { $repo = $this->app['storage']->getRepository($contentType); foreach ($relations as $id) { if ($relation = $repo->find($id)) { $entities[$contentType][] = $relation; } } } $content->setRelation($entities); }