12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- /*
- * This file is part of Packagist.
- *
- * (c) Jordi Boggiano <j.boggiano@seld.be>
- * Nils Adermann <naderman@naderman.de>
- *
- * 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 <j.boggiano@seld.be>
- */
- 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();
- }
- }
|