/** * addPostReferences. * * @param $post * @param $data */ protected function addPostReferences(&$post, $data) { $typeMap = array('user' => ReferenceType::USER, 'page' => ReferenceType::PAGE, 'group' => ReferenceType::GROUP, 'application' => ReferenceType::APPLICATION); if (!isset($data['message_tags'])) { return; } foreach ($data['message_tags'] as $messageTagGroup) { foreach ($messageTagGroup as $messageTag) { $reference = new Reference(); $reference->setIndices(array($messageTag['offset'], $messageTag['offset'] + $messageTag['length']))->setType($typeMap[$messageTag['type']])->setData($messageTag); $post->addReference($reference); } } }
/** * addTweetReferences. * * @param $tweet * @param $data */ protected function addTweetReferences(&$tweet, $data) { $typeMap = array('urls' => ReferenceType::URL, 'user_mentions' => ReferenceType::USER, 'hashtags' => ReferenceType::HASHTAG, 'video' => ReferenceType::VIDEO, 'media' => ReferenceType::MEDIA, 'photo' => ReferenceType::MEDIA); foreach ($data['entities'] as $entityType => $entities) { foreach ($entities as $entity) { $reference = new Reference(); $reference->setIndices($entity['indices'])->setType($typeMap[$entityType])->setData($entity); $tweet->addReference($reference); } } if (isset($data['extended_entities'])) { foreach ($data['extended_entities'] as $entities) { foreach ($entities as $entity) { $reference = new Reference(); $reference->setIndices($entity['indices'])->setType($typeMap[$entity['type']])->setData($entity); $tweet->addReference($reference); } } } }