示例#1
0
 public static function fromGroup(\AB\Bundle\Entity\Group $g)
 {
     $group = new ApiGroup();
     $group->mentor = ApiUser::fromUser($g->getMentor());
     $group->secondaryMentor = ApiUser::fromUser($g->getSecondaryMentor());
     $group->pupils = array_map(function ($u) {
         return ApiUser::fromUser($u);
     }, $g->getPupils()->getValues());
     return $group;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $serializer = SerializerBuilder::create()->build();
     $mailer = $this->getContainer()->get('ab_user.mailer');
     $em = $this->getContainer()->get('doctrine')->getManager();
     $list = $input->getArgument('pairings_json');
     $pairingsContents = file_get_contents($list);
     $groups = $serializer->deserialize($pairingsContents, 'array<AB\\Bundle\\ApiEntity\\ApiEmailOnlyGroup>', 'json');
     foreach ($groups as $emailGroup) {
         $apiGroup = new ApiGroup();
         $apiGroup->mentor = ApiUser::fromUser(self::findUserByEmail($em, $emailGroup->mentor, 'ABBundle:Mentor'));
         $apiGroup->secondaryMentor = ApiUser::fromUser(self::findUserByEmail($em, $emailGroup->secondaryMentor, 'ABBundle:Mentor'));
         $apiGroup->pupils = array_map(function ($u) use($em, $output) {
             return ApiUser::fromUser(self::findUserByEmail($em, $u, 'ABBundle:Pupil'));
         }, $emailGroup->pupils);
         $output->writeln($apiGroup->mentor->email);
         $mailer->sendMeetYourGroupMessage($apiGroup);
     }
     //$output->writeln($text);
 }