/** * @param \Doctrine\ORM\PersistentCollection $collection * @return array */ public static function getReferenceIds($collection) { if ($collection) { return $collection->map(function ($obj) { /** @var \User\Entity\Resource $obj */ return $obj->getId(); })->toArray(); } else { return null; } }