* Nils Adermann * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Packagist\WebBundle\Command; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Bridge\Doctrine\RegistryInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Finder\Finder; /** * @author Jordi Boggiano */ class GenerateTokensCommand extends ContainerAwareCommand { /** * {@inheritdoc} */ protected function configure() { $this ->setName('packagist:tokens:generate') ->setDescription('Generates all missing user tokens') ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $doctrine = $this->getContainer()->get('doctrine'); $userRepo = $doctrine->getRepository('PackagistWebBundle:User'); $users = $userRepo->findUsersMissingApiToken(); foreach ($users as $user) { $user->regenerateApiToken(); } $doctrine->getEntityManager()->flush(); } }