Using PHP + Doctrine I get this:
//retrieve data
$entityManager = $this->getEntityManager();
$all = $entityManager->getRepository('\Entity\ServiceType')->findAll();
foreach($all as $value)
$options[$value->getId()] = $value->getServiceType();
Autocomplete within IDE does not suggest methods that follow ->
, namely things like getId()
, and getServiceType()
.
And PHP does not offer (easy) casting to desired type....
This appears to work (v12.5):
foreach ($all as $key => $value)
/**
* @var $value ServiceType
*/
$options[$value->getId()] = $value->getId();
This appears to work as well (v13.0):
/**
* @var $all ServiceType
*/
foreach ($all as $key => $value)
$options[$value->getId()] = $value->getId();