em = $em; $this->mapCalendarToUser = $mapCalendarToUser; $this->userRepository = $userRepository; } public function execute(InputInterface $input, OutputInterface $output): int { $limit = 2; $offset = 0; $total = $this->userRepository->countByNotHavingAttribute(MapCalendarToUser::METADATA_KEY); while ($offset < $total) { $users = $this->userRepository->findByNotHavingAttribute(MapCalendarToUser::METADATA_KEY, $limit, $offset); foreach ($users as $user) { $this->mapCalendarToUser->writeMetadata($user); ++$offset; } $this->em->flush(); $this->em->clear(); } return 0; } }