From 6ada9bcd86a6830af24e5ab65ca236315df459b6 Mon Sep 17 00:00:00 2001 From: gyts123 <48186077+gyts123@users.noreply.github.com> Date: Tue, 26 Nov 2019 21:04:54 +0200 Subject: [PATCH 1/2] Testas --- Test | 1 + 1 file changed, 1 insertion(+) create mode 100644 Test diff --git a/Test b/Test new file mode 100644 index 000000000..c91e36968 --- /dev/null +++ b/Test @@ -0,0 +1 @@ +Testas From faff1a9583f2fb64819cef9f9e7b46968a8e06f8 Mon Sep 17 00:00:00 2001 From: Gytis Date: Tue, 26 Nov 2019 22:48:49 +0200 Subject: [PATCH 2/2] Homework complete! --- config/packages/easy_admin.yaml | 2 ++ scripts/mysql.sh | 2 +- src/Entity/User.php | 24 ++++++++++++++++ src/Form/RegistrationFormType.php | 1 + src/Migrations/Version20191126200231.php | 35 +++++++++++++++++++++++ src/Migrations/Version20191126204328.php | 35 +++++++++++++++++++++++ templates/base.html.twig | 3 +- templates/registration/register.html.twig | 1 + templates/security/profile.html.twig | 3 ++ 9 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 src/Migrations/Version20191126200231.php create mode 100644 src/Migrations/Version20191126204328.php 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/scripts/mysql.sh b/scripts/mysql.sh index 418209416..fbe41467f 100755 --- a/scripts/mysql.sh +++ b/scripts/mysql.sh @@ -25,4 +25,4 @@ if [ -t 0 ]; then TTY="-it" # Current shell/terminal have stdin file descriptor. So we can use interactive (-it) mode fi -docker exec ${TTY} mysql.symfony mysql -uroot -h127.0.0.1 --password=p9iijKcfgENjBWDYgSH7 symfony -e "$@" +docker exec ${TTY} mysql.symfony mysql -uroot -h127.0.0.1 --password=p9iijKcfgENjBWDYgSH7 diff --git a/src/Entity/User.php b/src/Entity/User.php index cac6aafc7..a0f274c17 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -50,6 +50,12 @@ class User implements UserInterface */ private $homepage = ""; + /** + * @var null|string LinkedIn + * @ORM\Column(type="string", length=255, nullable=true) + */ + private $linkedIn; + public function getId(): ?int { return $this->id; @@ -187,4 +193,22 @@ public function setHomepage(?string $homepage): self return $this; } + + /** + * @return string|null + */ + public function getLinkedIn(): ?string + { + return $this->linkedIn; + } + + /** + * @param string|null $linkedIn + */ + public function setLinkedIn(?string $linkedIn): self + { + $this->linkedIn = $linkedIn; + + return $this; + } } 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/src/Migrations/Version20191126200231.php b/src/Migrations/Version20191126200231.php new file mode 100644 index 000000000..cadfaaae7 --- /dev/null +++ b/src/Migrations/Version20191126200231.php @@ -0,0 +1,35 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, password_changed DATETIME DEFAULT NULL, homepage VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_8D93D649E7927C74 (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB'); + } + + 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('DROP TABLE user'); + } +} diff --git a/src/Migrations/Version20191126204328.php b/src/Migrations/Version20191126204328.php new file mode 100644 index 000000000..e5be08904 --- /dev/null +++ b/src/Migrations/Version20191126204328.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'); + } +} diff --git a/templates/base.html.twig b/templates/base.html.twig index eb61ed532..849d78d73 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -32,10 +32,11 @@ + {% if is_granted('ROLE_ADMIN') %} - + {% endif %} {% else %}