diff --git a/config/packages/easy_admin.yaml b/config/packages/easy_admin.yaml index a34b62ecb..92c039863 100644 --- a/config/packages/easy_admin.yaml +++ b/config/packages/easy_admin.yaml @@ -10,6 +10,7 @@ easy_admin: - 'username' - { property: 'roles', template: 'admin/user/roles-type-read.html.twig' } - { property: 'homepage', type: 'url' } + - { property: 'linkedin', type: 'url' } - { property: 'password', template: 'admin/user/password-read.html.twig' } form: fields: @@ -17,6 +18,7 @@ easy_admin: - { property: 'roles', type: 'collection' } - { property: 'plainPassword', type: 'password' } - { property: 'homepage', type: 'url' } + - { property: 'linkedin', type: 'url' } user: name_property_path: "email" \ No newline at end of file diff --git a/src/Entity/User.php b/src/Entity/User.php index cac6aafc7..329a145fe 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -1,11 +1,9 @@ id; } - public function getEmail(): ?string { return $this->email; } - public function setEmail(string $email): self { $this->email = $email; - return $this; } - /** * A visual identifier that represents this user. * @@ -76,7 +69,6 @@ public function getUsername(): string { return (string)$this->email; } - /** * @see UserInterface */ @@ -85,35 +77,28 @@ public function getRoles(): array $roles = $this->roles; // guarantee every user at least has ROLE_USER $roles[] = 'ROLE_USER'; - return array_unique($roles); } - public function setRoles(array $roles): self { $this->roles = $roles; - return $this; } - /** Virtual method for EasyAdminBundle */ public function getPlainPassword(): string { return ''; // We store passwords hashed, it is impossible to regenerate back } - - /** Virtual method for EasyAdminBundle */ + /** Virtual metFixedhod for EasyAdminBundle */ public function setPlainPassword($password): self { if (!$password) { return $this; // For usability: Empty password means do not change password } - $this->passwordWasChanged = true; $hash = password_hash($password, PASSWORD_ARGON2I); return $this->setPassword($hash); } - /** * @return bool */ @@ -121,22 +106,18 @@ public function isPasswordWasChanged(): bool { return $this->passwordWasChanged; } - /** * @see UserInterface */ public function getPassword(): string { - return (string) $this->password; + return (string)$this->password; } - public function setPassword(string $password): self { $this->password = $password; - return $this; } - /** * @see UserInterface */ @@ -144,7 +125,6 @@ public function getSalt() { // not needed when using the "bcrypt" algorithm in security.yaml } - /** * @see UserInterface */ @@ -153,23 +133,20 @@ public function eraseCredentials() // If you store any temporary, sensitive data on the user, clear it here // $this->plainPassword = null; } - /** - * @return \DateTime|null + * @return DateTime|null */ - public function getPasswordChanged(): ?\DateTime + public function getPasswordChanged(): ?DateTime { return $this->passwordChanged; } - /** - * @param \DateTime|null $passwordChanged + * @param DateTime|null $passwordChanged */ - public function setPasswordChanged(?\DateTime $passwordChanged): void + public function setPasswordChanged(?DateTime $passwordChanged): void { $this->passwordChanged = $passwordChanged; } - /** * @return string|null */ @@ -177,14 +154,29 @@ public function getHomepage(): ?string { return $this->homepage; } - /** * @param string|null $homepage + * @return User */ public function setHomepage(?string $homepage): self { $this->homepage = $homepage; - return $this; } -} + /** + * @return string|null + */ + public function getLinkedin(): ?string + { + return $this->linkedin; + } + /** + * @param string|null $linkedin + * @return User + */ + public function setLinkedin(?string $linkedin): self + { + $this->linkedin = $linkedin; + return $this; + } +} \ No newline at end of file diff --git a/src/Form/RegistrationFormType.php b/src/Form/RegistrationFormType.php index 31024cd40..abd32eb31 100644 --- a/src/Form/RegistrationFormType.php +++ b/src/Form/RegistrationFormType.php @@ -36,6 +36,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ], ]) ->add('homepage', UrlType::class, ['required' => false]) + ->add('linkedin', UrlType::class, ['required' => false]) ->add('agreeTerms', CheckboxType::class, [ 'mapped' => false, 'constraints' => [ diff --git a/src/Migrations/Version20191125133334.php b/src/Migrations/Version20191125133334.php new file mode 100644 index 000000000..531a04de4 --- /dev/null +++ b/src/Migrations/Version20191125133334.php @@ -0,0 +1,35 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE user ADD linkedin VARCHAR(255) DEFAULT NULL, CHANGE roles roles JSON NOT NULL, CHANGE homepage homepage VARCHAR(255) DEFAULT NULL, CHANGE password_changed password_changed DATETIME DEFAULT NULL'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE user DROP linkedin, CHANGE roles roles LONGTEXT NOT NULL COLLATE utf8mb4_bin, CHANGE password_changed password_changed DATETIME DEFAULT \'NULL\', CHANGE homepage homepage VARCHAR(255) DEFAULT \'NULL\' COLLATE utf8mb4_unicode_ci'); + } +} diff --git a/templates/base.html.twig b/templates/base.html.twig index eb61ed532..7c735f505 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -32,9 +32,12 @@