From c34c8035ea46b92c69ae894b2d37992a660e74f8 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 10 Mar 2022 14:54:03 +0100 Subject: [PATCH] csfixes --- src/Bundle/ChillMainBundle/Entity/User.php | 37 ++++++++++--------- src/Bundle/ChillMainBundle/Form/UserType.php | 2 +- .../MenuBuilder/SectionMenuBuilder.php | 1 - .../migrations/Version20220308104030.php | 17 ++++++--- 4 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Entity/User.php b/src/Bundle/ChillMainBundle/Entity/User.php index 984d2da0c..6d320d019 100644 --- a/src/Bundle/ChillMainBundle/Entity/User.php +++ b/src/Bundle/ChillMainBundle/Entity/User.php @@ -112,6 +112,11 @@ class User implements AdvancedUserInterface */ private string $password = ''; + /** + * @ORM\Column(type="json") + */ + private array $roles = ['ROLE_USER']; + /** * @internal must be set to null if we use bcrypt * @@ -138,11 +143,6 @@ class User implements AdvancedUserInterface */ private ?string $usernameCanonical = null; - /** - * @ORM\Column(type="json") - */ - private array $roles = ['ROLE_USER']; - /** * User constructor. */ @@ -156,6 +156,13 @@ class User implements AdvancedUserInterface return $this->getLabel(); } + public function addGroupCenter(GroupCenter $groupCenter): self + { + $this->groupCenters->add($groupCenter); + + return $this; + } + // empty function... remove? public function eraseCredentials() { @@ -300,13 +307,6 @@ class User implements AdvancedUserInterface } } - public function addGroupCenter(GroupCenter $groupCenter): self - { - $this->groupCenters->add($groupCenter); - - return $this; - } - /** * Set attributes. * @@ -328,12 +328,6 @@ class User implements AdvancedUserInterface return $this; } - public function setRoles($roles): self - { - $this->roles = $roles; - return $this; - } - public function setEmail($email): self { $this->email = $email; @@ -390,6 +384,13 @@ class User implements AdvancedUserInterface return $this; } + public function setRoles($roles): self + { + $this->roles = $roles; + + return $this; + } + public function setSalt($salt): self { $this->salt = $salt; diff --git a/src/Bundle/ChillMainBundle/Form/UserType.php b/src/Bundle/ChillMainBundle/Form/UserType.php index 5c65dd7c7..efd9e12a8 100644 --- a/src/Bundle/ChillMainBundle/Form/UserType.php +++ b/src/Bundle/ChillMainBundle/Form/UserType.php @@ -65,7 +65,7 @@ class UserType extends AbstractType 'multiple' => true, 'expanded' => true, 'label' => 'Roles', - 'choices' => [ + 'choices' => [ 'Usager' => 'ROLE_USER', 'Administrateur' => 'ROLE_ADMIN', ], diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/SectionMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/SectionMenuBuilder.php index 62b71e442..6e266c3d2 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/SectionMenuBuilder.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/SectionMenuBuilder.php @@ -64,7 +64,6 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface ] ); - if ($this->authorizationChecker->isGranted(ChillExportVoter::EXPORT)) { $menu->addChild($this->translator->trans('Export Menu'), [ 'route' => 'chill_main_export_index', diff --git a/src/Bundle/ChillMainBundle/migrations/Version20220308104030.php b/src/Bundle/ChillMainBundle/migrations/Version20220308104030.php index 0c48b3568..df24dc3c0 100644 --- a/src/Bundle/ChillMainBundle/migrations/Version20220308104030.php +++ b/src/Bundle/ChillMainBundle/migrations/Version20220308104030.php @@ -1,5 +1,12 @@ addSql('ALTER TABLE users DROP roles'); + } + public function getDescription(): string { return 'Add roles property to user'; @@ -21,9 +33,4 @@ final class Version20220308104030 extends AbstractMigration { $this->addSql('ALTER TABLE users ADD roles JSONB DEFAULT \'["ROLE_USER"]\' NOT NULL'); } - - public function down(Schema $schema): void - { - $this->addSql('ALTER TABLE users DROP roles'); - } }