Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Testas
2 changes: 2 additions & 0 deletions config/packages/easy_admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ 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:
- { property: 'email', type: 'email' }
- { property: 'roles', type: 'collection' }
- { property: 'plainPassword', type: 'password' }
- { property: 'homepage', type: 'url' }
- { property: 'linkedin', type: 'url' }

user:
name_property_path: "email"
2 changes: 1 addition & 1 deletion scripts/mysql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 24 additions & 0 deletions src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
1 change: 1 addition & 0 deletions src/Form/RegistrationFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down
35 changes: 35 additions & 0 deletions src/Migrations/Version20191126200231.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20191126200231 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}

public function up(Schema $schema) : void
{
// this up() 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('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');
Copy link
Owner

Choose a reason for hiding this comment

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

Migracijų esmė: pridėti pakeitmus, o ne viską daryti iš naujo.

Veiksmų seka:

  • Paimamas kitų kodas: lokali duomenų bazė atnaujinama pagal kodą
  • Atliekami pakeitimai: sugeneruojamas migracijos failas(-ai) – kurie tik prideda prie jau esančių failų
  • Pas kolegą (ar serveryje) įvykdomi visi migracijos failai iš eilės

Ir dėl šios priežasties – neveikia testai ir negaliu pilnai įvertinti visų projekto funkcijų
image

Plačiau:

}

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');
}
}
35 changes: 35 additions & 0 deletions src/Migrations/Version20191126204328.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20191126204328 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}

public function up(Schema $schema) : void
{
// this up() 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, CHANGE roles roles JSON NOT NULL, CHANGE homepage homepage VARCHAR(255) DEFAULT NULL, CHANGE password_changed password_changed DATETIME DEFAULT NULL');
Copy link
Owner

Choose a reason for hiding this comment

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

P.S. savo testuose (scripts/insert-test-user.sh) darau prielaidą, kad laukelis bus linkedin

}

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');
}
}
3 changes: 2 additions & 1 deletion templates/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@
<li class="nav-item">
<a class="nav-link" href="{{ path('app_logout') }}">Atsijungti</a>
</li>
{% if is_granted('ROLE_ADMIN') %}
<li class="nav-item">
<a class="nav-link" href="{{ path('easyadmin') }}">Administravimas</a>
</li>

{% endif %}
{% else %}

<li class="nav-item">
Expand Down
1 change: 1 addition & 0 deletions templates/registration/register.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{{ form_row(registrationForm.email) }}
{{ form_row(registrationForm.plainPassword) }}
{{ form_row(registrationForm.homepage) }}
{{ form_row(registrationForm.linkedIn) }}
{{ form_row(registrationForm.agreeTerms) }}

<button class="btn">Register</button>
Expand Down
3 changes: 3 additions & 0 deletions templates/security/profile.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
<div class="mb-2">
<span class="badge badge-primary">Website</span> <a href="{{ user.homepage }}"></a>{{ user.homepage }}
</div>
<div class="mb-2">
<span class="badge badge-primary">LinkedIn</span> <a href="{{ user.linkedin }}"></a>{{ user.linkedin }}
</div>
</div>
{% endblock %}