Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UserBundle] adding commands to promote or demote a user by adding or removing a role #4212

Merged
merged 7 commits into from
Mar 30, 2016

Conversation

loic425
Copy link
Member

@loic425 loic425 commented Feb 18, 2016

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Fixed tickets
License MIT
Doc PR

@pjedrzejewski pjedrzejewski added DX Issues and PRs aimed at improving Developer eXperience. New Feature labels Feb 18, 2016
if (empty($email)) {
throw new \Exception('Email can not be empty');
}
return $email;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing blank line

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines are a copy/paste from existing "CreateUserCommand".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still, there should be a blank line before return statement. See

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, my bad. I'm gonna fix that.

@loic425
Copy link
Member Author

loic425 commented Mar 7, 2016

@pjedrzejewski Theses 2 commands handle with RBAC roles now. I omitted this concept.


/**
* @param string $role
* @return RoleInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing blank line

@loic425
Copy link
Member Author

loic425 commented Mar 8, 2016

@pjedrzejewski I've done all changes from lchrusciel review.

@loic425
Copy link
Member Author

loic425 commented Mar 29, 2016

@pjedrzejewski @lchrusciel
Is that ok ? Or should i improve something ?

/**
* @author Loïc Frémont <loic@mobizel.com>
*/
interface RoleCommandInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of this interface? You do not inject it anywhere.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AbstractRoleCommand object use this interface. This command calls "executeRoleCommand" method. Thus, to extend AbstractRoleCommand, you need to add executeRoleCommand method.

*/
protected function findAuthorizationRole($role)
{
$roleRepository = $this->getContainer()->get('sylius.repository.role');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This couples SyliusUserBundle to SyliusRbacBundle, which is something we would like to avoid. Sorry, I just noticed it. I think there should be a separate command in RbacBundle to do this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pjedrzejewski
Ok, I see. The actual CreateUserCommand has the same problem.

I'm gonna work (if you agree) on two commands, one for SyliusUserBundle and one for SyliusRbacBundle.
I can also work on another pull request to improve CreateUserCommand.

@pjedrzejewski
Copy link
Member

This coupling to RbacBundle is a blocker atm. :/ We cannot use sylius.repository.role because it comes from RbacBundle. We should move the command or figure out something else.

@loic425
Copy link
Member Author

loic425 commented Mar 30, 2016

@pjedrzejewski
I remove SyliusRbacBundle dependencies. Now, the command only add or remove security roles.

->setHelp(<<<EOT
The <info>sylius:user:demote</info> command demotes a user by removing security roles

<info>php app/console fos:user:demote matthieu@email.com</info>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sylius:user:demote

@pjedrzejewski pjedrzejewski merged commit 69d34f3 into Sylius:master Mar 30, 2016
@pjedrzejewski
Copy link
Member

Thank you @loic425!

@loic425 loic425 deleted the promoteAndDemoteUserCommands branch August 9, 2018 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Issues and PRs aimed at improving Developer eXperience.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants