In my Symfony app, I have a subscriber wherein I need to iterate over IRIs stored in an array and access their entity's methods. How can I do this?
For instance:
function sendMail ($event) {
...
$instance = $event->getControllerResult();
...
$recipients = $instance->getRecipients(); // returns array of IRIs
foreach ($recipients as $recipient) {
$r = // instance of IRI-associated entity
if ($r instanceof User) {
// send to user
$email = $r->getEmail();
// send an email
} else if ($r instanceof Group) {
// send to group
foreach ($r->getUsers() as $user) {
$email = $user->getEmail();
// send an email
}
}
}
...
}
Although I have likely overlooked it, I have not found a method of doing so in the documentation and my knowledge of Symfony is still growing.