FOS\UserBundle\Command\ChangePasswordCommand::execute PHP Метод

execute() защищенный Метод

См. также: Command
protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->container->get('security.context')->setToken(new UsernamePasswordToken('command.line', null, array(User::ROLE_SUPERADMIN)));
        $userManager = $this->container->get('fos_user.user_manager');
        $user = $userManager->findUserByUsername($input->getArgument('username'));
        if (!$user) {
            throw new \InvalidArgumentException(sprintf('User identified by "%s" username does not exist.', $input->getArgument('username')));
        }
        $user->setPlainPassword($input->getArgument('password'));
        $userManager->updateUser($user);
        $output->writeln(sprintf('Changed password for user <comment>%s</comment>', $user->getUsername()));
    }
ChangePasswordCommand