/** * @param $slackId * @param $title * @param $url * @param array $tags * @return Link */ public static function fromSlack(MessageId $slackId, User $user, Datetime $createdTs, $title, $url, array $tags = array()) { $link = new Link(); $link->slackId = $slackId->getValue(); $link->user = $user; $link->createdTs = $createdTs; $link->title = $title; $link->url = $url; $link->author = $user->getName(); foreach ($tags as $tag) { $link->addTag(new Tag($tag)); } return $link; }
/** * @param SlackUser[] $users */ private function importUsers(array $users, OutputInterface $output) { foreach ($users as $slackUser) { if ($slackUser->isDeleted() || $slackUser->data['is_bot'] === true) { $output->writeln(sprintf('Skipping %s (%s)', $slackUser->data['name'], $slackUser->getId())); continue; } $output->writeln(sprintf('Importing %s', $slackUser->getEmail())); $user = User::fromSlack(new UserId($slackUser->data['id']), $slackUser->data['name'], $slackUser->getEmail(), $slackUser->data['profile']['image_72']); $this->objectManager->persist($user); } $this->objectManager->flush(); }