/** * @param BuildTokensFromRecipientEvent $event * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ public function buildRecipientTokens(BuildTokensFromRecipientEvent $event) { // TODO evaluate this method /** @noinspection PhpUnusedLocalVariableInspection */ $recipient = $event->getRecipient(); /* if (!preg_match('~^member:(\d+)$~', $recipient, $matches)) { return; } $memberId = $matches[1]; $member = \MemberModel::findByPk($memberId); // member does not exists (anymore) if (!$member) { return; } /** @var \MemberModel $member * / $tokens = $event->getTokens(); foreach ($member->row() as $key => $value) { $tokens['recipient_' . $key] = $value; } */ }
/** * @param BuildTokensFromRecipientEvent $event */ public function buildRecipientTokens(BuildTokensFromRecipientEvent $event) { global $container; $recipient = $event->getRecipient(); if (!$recipient instanceof Recipient) { return; } /** @var EntityAccessor $entityAccessor */ $entityAccessor = $container['doctrine.orm.entityAccessor']; $tokens = $event->getTokens(); $properties = $entityAccessor->getProperties($recipient); foreach ($properties as $key => $value) { if (!is_object($value)) { $tokens['recipient_' . $key] = $value; } } }