From 74b66e29fc81c2017fa38c517631eacc2852ec50 Mon Sep 17 00:00:00 2001 From: Kestas <55563304+kestas144@users.noreply.github.com> Date: Tue, 26 Nov 2019 22:02:10 +0200 Subject: [PATCH 1/4] entity field added --- src/Entity/User.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Entity/User.php b/src/Entity/User.php index cac6aafc7..0c2c0a54c 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -49,6 +49,28 @@ class User implements UserInterface * @ORM\Column(type="string", length=255, nullable=true) */ private $homepage = ""; + /** + * @var null|string + * @ORM\Column(type="string", length=255, nullable=true) + */ + private $linkedIn; + + /** + * @return string|null + */ + public function getLinkedIn(): ?string + { + return $this->linkedIn; + } + + /** + * @param string|null $linkedIn + */ + public function setLinkedIn(?string $linkedIn): void + { + $this->linkedIn = $linkedIn; + } + public function getId(): ?int { From f6dfc880a97dea00ce7f2d3808f29c4f6d0d53ae Mon Sep 17 00:00:00 2001 From: Kestas <55563304+kestas144@users.noreply.github.com> Date: Tue, 26 Nov 2019 22:04:21 +0200 Subject: [PATCH 2/4] migration created --- src/Migrations/Version20191126200240.php | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/Migrations/Version20191126200240.php diff --git a/src/Migrations/Version20191126200240.php b/src/Migrations/Version20191126200240.php new file mode 100644 index 000000000..86e70f365 --- /dev/null +++ b/src/Migrations/Version20191126200240.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 linked_in 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 linked_in, 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'); + } +} From 671f823c60d434da9cf9891a5ce453bde7058a48 Mon Sep 17 00:00:00 2001 From: Kestas <55563304+kestas144@users.noreply.github.com> Date: Tue, 26 Nov 2019 22:35:34 +0200 Subject: [PATCH 3/4] templates edited --- config/packages/easy_admin.yaml | 2 ++ src/Form/RegistrationFormType.php | 1 + templates/base.html.twig | 9 ++++++--- templates/registration/register.html.twig | 1 + templates/security/profile.html.twig | 3 +++ 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/config/packages/easy_admin.yaml b/config/packages/easy_admin.yaml index a34b62ecb..b4cc3170f 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/Form/RegistrationFormType.php b/src/Form/RegistrationFormType.php index 31024cd40..fd0da7fe1 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/templates/base.html.twig b/templates/base.html.twig index eb61ed532..272cddca5 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -32,9 +32,12 @@ - + + {% if is_granted('ROLE_ADMIN')%} + + {% endif %} {% else %} diff --git a/templates/registration/register.html.twig b/templates/registration/register.html.twig index 7206a712a..e9b93d127 100644 --- a/templates/registration/register.html.twig +++ b/templates/registration/register.html.twig @@ -9,6 +9,7 @@ {{ form_row(registrationForm.email) }} {{ form_row(registrationForm.plainPassword) }} {{ form_row(registrationForm.homepage) }} + {{ form_row(registrationForm.linkedIn) }} {{ form_row(registrationForm.agreeTerms) }} diff --git a/templates/security/profile.html.twig b/templates/security/profile.html.twig index 4d6fd3f0b..ebd931f72 100644 --- a/templates/security/profile.html.twig +++ b/templates/security/profile.html.twig @@ -12,5 +12,8 @@
Website {{ user.homepage }}
+
+ LinkedIn {{ user.linkedIn }} +
{% endblock %} From e08af9f33608deb1e72daeb241da7f7057d504c5 Mon Sep 17 00:00:00 2001 From: Kestas <55563304+kestas144@users.noreply.github.com> Date: Tue, 26 Nov 2019 22:57:44 +0200 Subject: [PATCH 4/4] small fix --- config/packages/easy_admin.yaml | 4 +-- src/Entity/User.php | 12 ++++---- src/Form/RegistrationFormType.php | 2 +- src/Migrations/Version20191126205244.php | 35 +++++++++++++++++++++++ templates/registration/register.html.twig | 2 +- templates/security/profile.html.twig | 2 +- 6 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 src/Migrations/Version20191126205244.php diff --git a/config/packages/easy_admin.yaml b/config/packages/easy_admin.yaml index b4cc3170f..92c039863 100644 --- a/config/packages/easy_admin.yaml +++ b/config/packages/easy_admin.yaml @@ -10,7 +10,7 @@ easy_admin: - 'username' - { property: 'roles', template: 'admin/user/roles-type-read.html.twig' } - { property: 'homepage', type: 'url' } - - { property: 'linkedIn', type: 'url' } + - { property: 'linkedin', type: 'url' } - { property: 'password', template: 'admin/user/password-read.html.twig' } form: fields: @@ -18,7 +18,7 @@ easy_admin: - { property: 'roles', type: 'collection' } - { property: 'plainPassword', type: 'password' } - { property: 'homepage', type: 'url' } - - { property: 'linkedIn', 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 0c2c0a54c..da9e8f7c9 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -53,22 +53,22 @@ class User implements UserInterface * @var null|string * @ORM\Column(type="string", length=255, nullable=true) */ - private $linkedIn; + private $linkedin; /** * @return string|null */ - public function getLinkedIn(): ?string + public function getLinkedin(): ?string { - return $this->linkedIn; + return $this->linkedin; } /** - * @param string|null $linkedIn + * @param string|null $linkedin */ - public function setLinkedIn(?string $linkedIn): void + public function setLinkedin(?string $linkedin): void { - $this->linkedIn = $linkedIn; + $this->linkedin = $linkedin; } diff --git a/src/Form/RegistrationFormType.php b/src/Form/RegistrationFormType.php index fd0da7fe1..abd32eb31 100644 --- a/src/Form/RegistrationFormType.php +++ b/src/Form/RegistrationFormType.php @@ -36,7 +36,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ], ]) ->add('homepage', UrlType::class, ['required' => false]) - ->add('linkedIn', UrlType::class, ['required' => false]) + ->add('linkedin', UrlType::class, ['required' => false]) ->add('agreeTerms', CheckboxType::class, [ 'mapped' => false, 'constraints' => [ diff --git a/src/Migrations/Version20191126205244.php b/src/Migrations/Version20191126205244.php new file mode 100644 index 000000000..3ffcd8b3d --- /dev/null +++ b/src/Migrations/Version20191126205244.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, DROP linked_in, 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 ADD linked_in VARCHAR(255) DEFAULT \'NULL\' COLLATE utf8mb4_unicode_ci, 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/registration/register.html.twig b/templates/registration/register.html.twig index e9b93d127..76d7c8015 100644 --- a/templates/registration/register.html.twig +++ b/templates/registration/register.html.twig @@ -9,7 +9,7 @@ {{ form_row(registrationForm.email) }} {{ form_row(registrationForm.plainPassword) }} {{ form_row(registrationForm.homepage) }} - {{ form_row(registrationForm.linkedIn) }} + {{ form_row(registrationForm.linkedin) }} {{ form_row(registrationForm.agreeTerms) }} diff --git a/templates/security/profile.html.twig b/templates/security/profile.html.twig index ebd931f72..0525f6b81 100644 --- a/templates/security/profile.html.twig +++ b/templates/security/profile.html.twig @@ -13,7 +13,7 @@ Website {{ user.homepage }}
- LinkedIn {{ user.linkedIn }} + LinkedIn {{ user.linkedin }}
{% endblock %}