diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..1463066
Binary files /dev/null and b/.DS_Store differ
diff --git a/app/Resources/views/base.html.twig b/app/Resources/views/base.html.twig
index 7e93622..3a492f2 100644
--- a/app/Resources/views/base.html.twig
+++ b/app/Resources/views/base.html.twig
@@ -49,7 +49,7 @@
{% if user is defined and user %}
- {{ user.username }}
+ {{ user.username }}
| Odhlásit
{% else %}
Přihlásit
diff --git a/app/Resources/views/user/add_address.html.twig b/app/Resources/views/user/add_address.html.twig
new file mode 100644
index 0000000..0ebefa7
--- /dev/null
+++ b/app/Resources/views/user/add_address.html.twig
@@ -0,0 +1,14 @@
+{% extends 'base.html.twig' %}
+
+{% block body %}
+
Přidat adresu uživatele
+ {{ form_start(form) }}
+ {{ form_row(form.firstName) }}
+ {{ form_row(form.lastName) }}
+ {{ form_row(form.street) }}
+ {{ form_row(form.city) }}
+ {{ form_row(form.zip) }}
+
+
+ {{ form_end(form) }}
+{% endblock %}
\ No newline at end of file
diff --git a/src/AppBundle/Controller/UserController.php b/src/AppBundle/Controller/UserController.php
index d0958e3..2124e03 100644
--- a/src/AppBundle/Controller/UserController.php
+++ b/src/AppBundle/Controller/UserController.php
@@ -1,8 +1,10 @@
userFacade->getUser()) {
+ throw new UnauthorizedHttpException("Přihlašte se");
+ }
+
+ $address = new Address();
+ $form = $this->formFactory->create(UserEditFormType::class, $address);
+
+ $form->handleRequest($request);
+ if ($form->isSubmitted() && $form->isValid()) {
+
+ $this->entityManager->persist($address);
+ $this->entityManager->flush();
+
+ return RedirectResponse::create($this->router->generate("homepage"));
+ }
+
+ return [
+ "form" => $form->createView(),
+ "user" => $this->userFacade->getUser(),
+ ];
+
+ }
+
}
\ No newline at end of file
diff --git a/src/AppBundle/Entity/Address.php b/src/AppBundle/Entity/Address.php
new file mode 100644
index 0000000..fc62bae
--- /dev/null
+++ b/src/AppBundle/Entity/Address.php
@@ -0,0 +1,151 @@
+
+ * @author Jan Klat
+ *
+ * @ORM\Entity(repositoryClass="AppBundle\Repository\AddressRepository")
+ * @ORM\Table(name="address")
+ */
+class Address
+{
+
+ /**
+ * @var int
+ * @ORM\Id
+ * @ORM\GeneratedValue
+ * @ORM\Column(type="integer")
+ */
+ private $id;
+
+ /**
+ * @ORM\Column(type="string", length=255, unique=false, name="firstName")
+ * @Assert\NotBlank()
+ */
+ private $firstName;
+
+ /**
+ * @ORM\Column(type="string", length=255, unique=false, name="lastName")
+ * @Assert\NotBlank()
+ */
+ private $lastName;
+
+ /**
+ * @ORM\Column(type="string", length=255, unique=false, name="street")
+ * @Assert\NotBlank()
+ */
+ private $street;
+
+ /**
+ * @ORM\Column(type="string", length=255, unique=false, name="city")
+ * @Assert\NotBlank()
+ */
+ private $city;
+
+ /**
+ * @ORM\Column(type="string", length=5, unique=false, name="zip")
+ * @Assert\NotBlank()
+ */
+ private $zip;
+
+ /**
+ * @return mixed
+ */
+ public function getFirstName()
+ {
+ return $this->firstName;
+ }
+
+ /**
+ * @return int
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getCity()
+ {
+ return $this->city;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getLastName()
+ {
+ return $this->lastName;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getStreet()
+ {
+ return $this->street;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getZip()
+ {
+ return $this->zip;
+ }
+
+ /**
+ * @param mixed $city
+ */
+ public function setCity($city)
+ {
+ $this->city = $city;
+ }
+
+ /**
+ * @param mixed $firstName
+ */
+ public function setFirstName($firstName)
+ {
+ $this->firstName = $firstName;
+ }
+
+ /**
+ * @param mixed $street
+ */
+ public function setStreet($street)
+ {
+ $this->street = $street;
+ }
+
+ /**
+ * @param mixed $lastName
+ */
+ public function setLastName($lastName)
+ {
+ $this->lastName = $lastName;
+ }
+
+ /**
+ * @param mixed $zip
+ */
+ public function setZip($zip)
+ {
+ $this->zip = $zip;
+ }
+
+ /**
+ * @param int $id
+ */
+ public function setId($id)
+ {
+ $this->id = $id;
+ }
+}
diff --git a/src/AppBundle/Entity/User.php b/src/AppBundle/Entity/User.php
index 5dd2213..c3168ab 100644
--- a/src/AppBundle/Entity/User.php
+++ b/src/AppBundle/Entity/User.php
@@ -23,6 +23,12 @@ class User implements UserInterface
*/
private $id;
+ /**
+ * @var Address
+ * @ORM\OneToMany(targetEntity="Address")
+ */
+ private $address;
+
/**
* @ORM\Column(type="string", length=255, unique=true, name="email")
* @Assert\NotBlank()
@@ -129,4 +135,11 @@ public function eraseCredentials()
return;
}
+ /**
+ * @param Address $address
+ */
+ public function setAddress($address)
+ {
+ $this->address = $address;
+ }
}
diff --git a/src/AppBundle/FormType/UserEditFormType.php b/src/AppBundle/FormType/UserEditFormType.php
new file mode 100644
index 0000000..61c64c7
--- /dev/null
+++ b/src/AppBundle/FormType/UserEditFormType.php
@@ -0,0 +1,59 @@
+
+ * @author Jan Klat
+ */
+class UserEditFormType extends AbstractType
+{
+ public function buildForm(FormBuilderInterface $builder, array $options)
+ {
+ $builder
+ ->add("firstName", EmailType::class, [
+ "label" => "Jméno",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ ])
+ ->add("surName", EmailType::class, [
+ "label" => "Příjmení",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ ])
+ ->add("street", EmailType::class, [
+ "label" => "Ulice",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ ])
+ ->add("city", EmailType::class, [
+ "label" => "Město",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ ])
+ ->add("zip", EmailType::class, [
+ "label" => "PSČ",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ ]);
+ }
+
+ public function configureOptions(OptionsResolver $resolver)
+ {
+ $resolver->setDefaults(array(
+ "data_class" => Address::class,
+ ));
+ }
+}
\ No newline at end of file
diff --git a/src/AppBundle/Repository/AddressRepository.php b/src/AppBundle/Repository/AddressRepository.php
new file mode 100644
index 0000000..3913c44
--- /dev/null
+++ b/src/AppBundle/Repository/AddressRepository.php
@@ -0,0 +1,10 @@
+