* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Add a group to a user. * * @package symfony * @subpackage task * @author Fabien Potencier * @version SVN: $Id$ */ class sfGuardAddGroupTask extends sfDoctrineBaseTask { /** * @see sfTask */ protected function configure() { $this->addArguments(array( new sfCommandArgument('username', sfCommandArgument::REQUIRED, 'The user name'), new sfCommandArgument('group', sfCommandArgument::REQUIRED, 'The group name'), )); $this->addOptions(array( new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', null), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel'), )); $this->namespace = 'guard'; $this->name = 'add-group'; $this->briefDescription = 'Adds a group to a user'; $this->detailedDescription = <<configuration); $user = Doctrine::getTable('sfGuardUser')->findOneByUsername($arguments['username']); if (!$user) { throw new sfCommandException(sprintf('User "%s" does not exist.', $arguments['username'])); } $user->addGroupByName($arguments['group']); $this->logSection('guard', sprintf('Add group %s to user %s', $arguments['group'], $arguments['username'])); } }