forked from JLepeltier/sfDoctrineGuardPlugin
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added user:list group:permission-list tasks
- Loading branch information
Showing
6 changed files
with
104 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the symfony package. | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
/** | ||
* Associates a sfGuard group with a permission. | ||
* | ||
* @package symfony | ||
* @subpackage task | ||
* @author Emanuele Panzeri <[email protected]> | ||
*/ | ||
class sfGuardGroupPermissionListTask extends sfBaseTask | ||
{ | ||
protected function configure() | ||
{ | ||
$this->addArguments(array( | ||
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'), | ||
)); | ||
|
||
$this->namespace = 'guard'; | ||
$this->name = 'group:permission-list'; | ||
$this->briefDescription = 'List the group permissions'; | ||
} | ||
|
||
protected function execute($arguments = array(), $options = array()) | ||
{ | ||
$databaseManager = new sfDatabaseManager($this->configuration); | ||
|
||
/** @var sfGuardGroup $group */ | ||
$group = Doctrine_Core::getTable('sfGuardGroup')->findOneByName($arguments['group']); | ||
if (!$group) { | ||
$this->logSection('guard', sprintf('Group "%s" not found!', $arguments['group']), null, 'ERROR'); | ||
return -1; | ||
} | ||
|
||
$this->logSection('guard', sprintf('Listing permissions for Group "%s"', $group->getName())); | ||
|
||
/** @var sfGuardPermission $permission */ | ||
foreach ($group->getPermissions() as $permission) { | ||
$this->logSection('guard', sprintf(' - %s', $permission->getName())); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,17 +9,14 @@ | |
*/ | ||
|
||
/** | ||
* Create a new Permission. | ||
* Delete a group-permission. | ||
* | ||
* @package symfony | ||
* @subpackage task | ||
* @author Emanuele Panzeri <[email protected]> | ||
*/ | ||
class sfGuardPermissionDeleteTask extends sfBaseTask | ||
{ | ||
/** | ||
* @see sfTask | ||
*/ | ||
protected function configure() | ||
{ | ||
$this->addArguments(array( | ||
|
@@ -35,17 +32,8 @@ protected function configure() | |
$this->namespace = 'guard'; | ||
$this->name = 'permission:delete'; | ||
$this->briefDescription = 'Delete a Permission'; | ||
|
||
$this->detailedDescription = <<<EOF | ||
The [guard:permission:delete|INFO] task deletes a Permission: | ||
[./symfony guard:permission:delete PermissionName"|INFO] | ||
EOF; | ||
} | ||
|
||
/** | ||
* @see sfTask | ||
*/ | ||
protected function execute($arguments = array(), $options = array()) | ||
{ | ||
$databaseManager = new sfDatabaseManager($this->configuration); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,22 +9,17 @@ | |
*/ | ||
|
||
/** | ||
* Add a group to a user. | ||
* List the available Permissions. | ||
* | ||
* @package symfony | ||
* @subpackage task | ||
* @author Fabien Potencier <[email protected]> | ||
* @version SVN: $Id$ | ||
* @author Emanuele Panzeri <[email protected]> | ||
*/ | ||
class sfGuardPermissionListTask extends sfBaseTask | ||
{ | ||
/** | ||
* @see sfTask | ||
*/ | ||
protected function configure() | ||
{ | ||
$this->addArguments(array( | ||
)); | ||
$this->addArguments(array()); | ||
|
||
$this->addOptions(array( | ||
new sfCommandOption('with-groups', null, sfCommandOption::PARAMETER_NONE, 'Join with Groups'), | ||
|
@@ -36,17 +31,8 @@ protected function configure() | |
$this->namespace = 'guard'; | ||
$this->name = 'permission:list'; | ||
$this->briefDescription = 'List Permissions'; | ||
|
||
$this->detailedDescription = <<<EOF | ||
The [guard:permission:list|INFO] list permissions: | ||
[./symfony guard:list-groups|INFO] | ||
EOF; | ||
} | ||
|
||
/** | ||
* @see sfTask | ||
*/ | ||
protected function execute($arguments = array(), $options = array()) | ||
{ | ||
$databaseManager = new sfDatabaseManager($this->configuration); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the symfony package. | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
/** | ||
* List the sfGuard users. | ||
* | ||
* @package symfony | ||
* @subpackage task | ||
* @author Emanuele Panzeri <[email protected]> | ||
*/ | ||
class sfGuardUserListTask extends sfBaseTask | ||
{ | ||
protected function configure() | ||
{ | ||
$this->addArguments(array()); | ||
|
||
$this->addOptions(array( | ||
new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', null), | ||
new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), | ||
)); | ||
|
||
$this->namespace = 'guard'; | ||
$this->name = 'user:list'; | ||
$this->briefDescription = 'List users'; | ||
} | ||
|
||
protected function execute($arguments = array(), $options = array()) | ||
{ | ||
$databaseManager = new sfDatabaseManager($this->configuration); | ||
|
||
$model = sfConfig::get('app_sf_guard_user_model', 'sfGuardUser'); | ||
$users = Doctrine_Core::getTable($model)->findAll(); | ||
/** @var sfGuardUser $user */ | ||
foreach ($users as $user) { | ||
$this->logSection('guard', sprintf('%s (name: "%s", email: "%s")', $user->getUsername(), $user->getName(), $user->getEmailAddress())); | ||
} | ||
} | ||
} |