diff --git a/app/Resources/views/base.html.twig b/app/Resources/views/base.html.twig
index 7e93622..bc0982d 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/addaddress.html.twig b/app/Resources/views/user/addaddress.html.twig
new file mode 100644
index 0000000..a290dcb
--- /dev/null
+++ b/app/Resources/views/user/addaddress.html.twig
@@ -0,0 +1,18 @@
+{% extends 'base.html.twig' %}
+
+{% block body %}
+
+
+
+ {{ form_start(form) }}
+ {{ form_row(form.street) }}
+ {{ form_row(form.city) }}
+ {{ form_row(form.postcode) }}
+ {{ form_row(form.country) }}
+
+
+ {{ form_end(form) }}
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/app/Resources/views/user/changepassword.html.twig b/app/Resources/views/user/changepassword.html.twig
new file mode 100644
index 0000000..ab1c8d8
--- /dev/null
+++ b/app/Resources/views/user/changepassword.html.twig
@@ -0,0 +1,10 @@
+{% extends 'base.html.twig' %}
+
+{% block body %}
+ {{ form_start(form) }}
+ {{ form_row(form.plainPassword.first) }}
+ {{ form_row(form.plainPassword.second) }}
+
+
+ {{ form_end(form) }}
+{% endblock %}
\ No newline at end of file
diff --git a/app/Resources/views/user/profile.html.twig b/app/Resources/views/user/profile.html.twig
new file mode 100644
index 0000000..499dca6
--- /dev/null
+++ b/app/Resources/views/user/profile.html.twig
@@ -0,0 +1,26 @@
+{% extends 'base.html.twig' %}
+
+{% block body %}
+
+
+
Osobní údaje
+
Změnit heslo
+ {{ form_start(form) }}
+ {{ form_row(form.username) }}
+ {{ form_row(form.name) }}
+ {{ form_row(form.phone) }}
+
+
+ {{ form_end(form) }}
+
+
+
Adresy
+ {% for address in addresses %}
+
+
{{ address.street }}, {{ address.postcode }} {{ address.city }}, {{ address.country }}
+
+ {% endfor %}
+
Správa adres
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/app/config/security.yml b/app/config/security.yml
index 82c6691..d50f979 100644
--- a/app/config/security.yml
+++ b/app/config/security.yml
@@ -24,4 +24,8 @@ security:
# The route name the user can go to in order to logout
path: user_logout
# The name of the route to redirect to after logging out
- target: homepage
\ No newline at end of file
+ target: homepage
+
+ access_control:
+ - { path: /prihlasit, roles: IS_AUTHENTICATED_ANONYMOUSLY }
+ - { path: /uzivatel/*, roles: IS_AUTHENTICATED_FULLY }
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..9e4c16e
--- /dev/null
+++ b/readme.md
@@ -0,0 +1 @@
+ahoj codecampe
\ No newline at end of file
diff --git a/src/AppBundle/Controller/UserController.php b/src/AppBundle/Controller/UserController.php
index d0958e3..6314cd5 100644
--- a/src/AppBundle/Controller/UserController.php
+++ b/src/AppBundle/Controller/UserController.php
@@ -1,8 +1,12 @@
router = $router;
}
- /**
- * @Route("/registrovat", name="user_registration")
- * @Template("user/registration.html.twig")
- *
- * @param Request $request
- * @return RedirectResponse|array
- */
- public function registrationAction(Request $request)
- {
- // 1) build the form
- $user = new User();
- $form = $this->formFactory->create(RegistrationFormType::class, $user);
-
- // 2) handle the submit (will only happen on POST)
- $form->handleRequest($request);
- if ($form->isSubmitted() && $form->isValid()) {
-
- // 3) Encode the password (you could also do this via Doctrine listener)
- $user->setPassword(
- $this->passwordEncoder->encodePassword($user->getPlainPassword(), null)
- );
-
- // 4) save the User!
- $this->entityManager->persist($user);
- $this->entityManager->flush();
-
- // ... do any other work - like sending them an email, etc
- // maybe set a "flash" success message for the user
- return RedirectResponse::create($this->router->generate("homepage"));
- }
+ /**
+ * @Route("/registrovat", name="user_registration")
+ * @Template("user/registration.html.twig")
+ *
+ * @param Request $request
+ * @return RedirectResponse|array
+ */
+ public function registrationAction(Request $request)
+ {
+ // 1) build the form
+ $user = new User();
+ $form = $this->formFactory->create(RegistrationFormType::class, $user);
- return [
- "form" => $form->createView(),
- ];
- }
+ // 2) handle the submit (will only happen on POST)
+ $form->handleRequest($request);
+ if ($form->isSubmitted() && $form->isValid()) {
- /**
+ // 3) Encode the password (you could also do this via Doctrine listener)
+ $user->setPassword(
+ $this->passwordEncoder->encodePassword($user->getPlainPassword(), null)
+ );
+
+ // 4) save the User!
+ $this->entityManager->persist($user);
+ $this->entityManager->flush();
+
+ // ... do any other work - like sending them an email, etc
+ // maybe set a "flash" success message for the user
+ return RedirectResponse::create($this->router->generate("homepage"));
+ }
+
+ return [
+ "form" => $form->createView(),
+ ];
+ }
+
+ /**
+ * @Route("/uzivatel/zmenit-heslo", name="user_changepassword")
+ * @Template("user/changepassword.html.twig")
+ *
+ * @param Request $request
+ * @return RedirectResponse|array
+ */
+ public function changepasswordAction(Request $request)
+ {
+ $user = $this->userFacade->getUser();
+ $form = $this->formFactory->create(ChangePasswordFormType::class, $user);
+
+ $form->handleRequest($request);
+ if ($form->isSubmitted()) {
+
+ $user->setPassword(
+ $this->passwordEncoder->encodePassword($user->getPlainPassword(), null)
+ );
+
+ $this->entityManager->persist($user);
+ $this->entityManager->flush();
+
+ return RedirectResponse::create($this->router->generate("user_profile"));
+ }
+
+ return [
+ "form" => $form->createView(),
+ "user" => $this->userFacade->getUser(),
+ ];
+ }
+
+ /**
* @Route("/prihlasit", name="user_login")
* @Template("user/login.html.twig")
*
@@ -113,4 +148,61 @@ public function superSecretAction()
];
}
+ /**
+ * @Route("/uzivatel/profil", name="user_profile")
+ * @Template("user/profile.html.twig")
+ *
+ * @param Request $request
+ * @return RedirectResponse|array
+ */
+ public function profileAction(Request $request)
+ {
+ $user = $this->userFacade->getUser();
+ $form = $this->formFactory->create(ProfileFormType::class, $user);
+ $addresses = $user->getAddresses();
+
+ $form->handleRequest($request);
+ if ($form->isSubmitted()) {
+
+ $this->entityManager->persist($user);
+ $this->entityManager->flush();
+
+ return RedirectResponse::create($this->router->generate("user_profile"));
+ }
+
+ return [
+ "form" => $form->createView(),
+ "user" => $this->userFacade->getUser(),
+ "addresses" => $addresses,
+ ];
+ }
+
+ /**
+ * @Route("/uzivatel/pridat-adresu", name="add_address")
+ * @Template("user/addaddress.html.twig")
+ *
+ * @param Request $request
+ * @return RedirectResponse|array
+ */
+ public function addAddressAction(Request $request)
+ {
+ $user = $this->userFacade->getUser();
+ $address = new Address();
+ $form = $this->formFactory->create(AddressFormType::class, $address);
+
+ $form->handleRequest($request);
+ if ($form->isSubmitted()) {
+
+ $address->setUser($user);
+
+ $this->entityManager->persist($address);
+ $this->entityManager->flush();
+
+ return RedirectResponse::create($this->router->generate("user_profile"));
+ }
+
+ return [
+ "form" => $form->createView(),
+ ];
+ }
}
\ 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..1a9450b
--- /dev/null
+++ b/src/AppBundle/Entity/Address.php
@@ -0,0 +1,187 @@
+id;
+ }
+
+ /**
+ * Set street
+ *
+ * @param string $street
+ *
+ * @return Address
+ */
+ public function setStreet($street)
+ {
+ $this->street = $street;
+
+ return $this;
+ }
+
+ /**
+ * Get street
+ *
+ * @return string
+ */
+ public function getStreet()
+ {
+ return $this->street;
+ }
+
+ /**
+ * Set city
+ *
+ * @param string $city
+ *
+ * @return Address
+ */
+ public function setCity($city)
+ {
+ $this->city = $city;
+
+ return $this;
+ }
+
+ /**
+ * Get city
+ *
+ * @return string
+ */
+ public function getCity()
+ {
+ return $this->city;
+ }
+
+ /**
+ * Set postcode
+ *
+ * @param string $postcode
+ *
+ * @return Address
+ */
+ public function setPostcode($postcode)
+ {
+ $this->postcode = $postcode;
+
+ return $this;
+ }
+
+ /**
+ * Get postcode
+ *
+ * @return string
+ */
+ public function getPostcode()
+ {
+ return $this->postcode;
+ }
+
+ /**
+ * Set country
+ *
+ * @param string $country
+ *
+ * @return Address
+ */
+ public function setCountry($country)
+ {
+ $this->country = $country;
+
+ return $this;
+ }
+
+ /**
+ * Get country
+ *
+ * @return string
+ */
+ public function getCountry()
+ {
+ return $this->country;
+ }
+
+ /**
+ * Set user
+ *
+ * @param \AppBundle\Entity\User $user
+ *
+ * @return Address
+ */
+ public function setUser(\AppBundle\Entity\User $user = null)
+ {
+ $this->user = $user;
+
+ return $this;
+ }
+
+ /**
+ * Get user
+ *
+ * @return \AppBundle\Entity\User
+ */
+ public function getUser()
+ {
+ return $this->user;
+ }
+}
diff --git a/src/AppBundle/Entity/Adress.php~ b/src/AppBundle/Entity/Adress.php~
new file mode 100644
index 0000000..492aba2
--- /dev/null
+++ b/src/AppBundle/Entity/Adress.php~
@@ -0,0 +1,164 @@
+id;
+ }
+
+ /**
+ * Set street
+ *
+ * @param string $street
+ *
+ * @return Adress
+ */
+ public function setStreet($street)
+ {
+ $this->street = $street;
+
+ return $this;
+ }
+
+ /**
+ * Get street
+ *
+ * @return string
+ */
+ public function getStreet()
+ {
+ return $this->street;
+ }
+
+ /**
+ * Set city
+ *
+ * @param string $city
+ *
+ * @return Adress
+ */
+ public function setCity($city)
+ {
+ $this->city = $city;
+
+ return $this;
+ }
+
+ /**
+ * Get city
+ *
+ * @return string
+ */
+ public function getCity()
+ {
+ return $this->city;
+ }
+
+ /**
+ * Set postcode
+ *
+ * @param string $postcode
+ *
+ * @return Adress
+ */
+ public function setPostcode($postcode)
+ {
+ $this->postcode = $postcode;
+
+ return $this;
+ }
+
+ /**
+ * Get postcode
+ *
+ * @return string
+ */
+ public function getPostcode()
+ {
+ return $this->postcode;
+ }
+
+ /**
+ * Set country
+ *
+ * @param string $country
+ *
+ * @return Adress
+ */
+ public function setCountry($country)
+ {
+ $this->country = $country;
+
+ return $this;
+ }
+
+ /**
+ * Get country
+ *
+ * @return string
+ */
+ public function getCountry()
+ {
+ return $this->country;
+ }
+}
+
diff --git a/src/AppBundle/Entity/Category.php b/src/AppBundle/Entity/Category.php
index 2074d06..1b04ac1 100644
--- a/src/AppBundle/Entity/Category.php
+++ b/src/AppBundle/Entity/Category.php
@@ -236,4 +236,4 @@ public function isLowestLevel()
return ($this->getRight() - $this->getLeft()) === 1;
}
-}
\ No newline at end of file
+}
diff --git a/src/AppBundle/Entity/Category.php~ b/src/AppBundle/Entity/Category.php~
new file mode 100644
index 0000000..2074d06
--- /dev/null
+++ b/src/AppBundle/Entity/Category.php~
@@ -0,0 +1,239 @@
+
+ * @author Jan Klat
+ *
+ * @ORM\Entity(repositoryClass="AppBundle\Repository\CategoryRepository")
+ */
+class Category
+{
+
+ /**
+ * @var int
+ * @ORM\Id
+ * @ORM\GeneratedValue
+ * @ORM\Column(type="integer")
+ */
+ private $id;
+
+ /**
+ * @var string
+ * @ORM\Column(type="string")
+ */
+ private $title;
+
+ /**
+ * @var string
+ * @ORM\Column(type="string")
+ */
+ private $slug;
+
+ /**
+ * @var int
+ * @ORM\Column(type="integer")
+ */
+ private $rank;
+
+ /**
+ * @var Category
+ * @ORM\ManyToOne(targetEntity="Category")
+ */
+ private $parentCategory;
+
+ /**
+ * @var Category
+ * @ORM\ManyToOne(targetEntity="Category")
+ */
+ private $topCategory;
+
+ /**
+ * @var int
+ * @ORM\Column(type="integer")
+ */
+ private $left;
+
+ /**
+ * @var int
+ * @ORM\Column(type="integer")
+ */
+ private $right;
+
+ /**
+ * @var int
+ * @ORM\Column(type="integer")
+ */
+ private $level;
+
+ /**
+ * @return int
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * @param string $title
+ * @return self
+ */
+ public function setTitle($title)
+ {
+ $this->title = $title;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getSlug()
+ {
+ return $this->slug;
+ }
+
+ /**
+ * @param string $slug
+ * @return self
+ */
+ public function setSlug($slug)
+ {
+ $this->slug = $slug;
+ return $this;
+ }
+
+ /**
+ * @return int
+ */
+ public function getRank()
+ {
+ return $this->rank;
+ }
+
+ /**
+ * @param int $rank
+ * @return self
+ */
+ public function setRank($rank)
+ {
+ $this->rank = $rank;
+ return $this;
+ }
+
+ /**
+ * @return Category
+ */
+ public function getParentCategory()
+ {
+ return $this->parentCategory;
+ }
+
+ /**
+ * @param Category $parentCategory
+ * @return self
+ */
+ public function setParentCategory(Category $parentCategory)
+ {
+ $this->parentCategory = $parentCategory;
+ return $this;
+ }
+
+ /**
+ * @return Category
+ */
+ public function getTopCategory()
+ {
+ return $this->topCategory;
+ }
+
+ /**
+ * @param Category $topCategory
+ * @return self
+ */
+ public function setTopCategory(Category $topCategory)
+ {
+ $this->topCategory = $topCategory;
+ return $this;
+ }
+
+ /**
+ * @return int
+ */
+ public function getLeft()
+ {
+ return $this->left;
+ }
+
+ /**
+ * @param int $left
+ * @return self
+ */
+ public function setLeft($left)
+ {
+ $this->left = $left;
+ return $this;
+ }
+
+ /**
+ * @return int
+ */
+ public function getRight()
+ {
+ return $this->right;
+ }
+
+ /**
+ * @param int $right
+ * @return self
+ */
+ public function setRight($right)
+ {
+ $this->right = $right;
+ return $this;
+ }
+
+ /**
+ * @return int
+ */
+ public function getLevel()
+ {
+ return $this->level;
+ }
+
+ /**
+ * @param int $level
+ * @return self
+ */
+ public function setLevel($level)
+ {
+ $this->level = $level;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getMenuTitle()
+ {
+ return str_repeat("-", $this->getLevel()) . " " . $this->getTitle();
+ }
+
+ /**
+ * @return bool
+ */
+ public function isLowestLevel()
+ {
+ return ($this->getRight() - $this->getLeft()) === 1;
+ }
+
+}
\ No newline at end of file
diff --git a/src/AppBundle/Entity/Product.php b/src/AppBundle/Entity/Product.php
index 155d28f..1337a0f 100644
--- a/src/AppBundle/Entity/Product.php
+++ b/src/AppBundle/Entity/Product.php
@@ -172,4 +172,4 @@ public function setRank($rank)
$this->rank = $rank;
return $this;
}
-}
\ No newline at end of file
+}
diff --git a/src/AppBundle/Entity/Product.php~ b/src/AppBundle/Entity/Product.php~
new file mode 100644
index 0000000..155d28f
--- /dev/null
+++ b/src/AppBundle/Entity/Product.php~
@@ -0,0 +1,175 @@
+
+ * @author Jan Klat
+ *
+ * @ORM\Entity(repositoryClass="AppBundle\Repository\ProductRepository")
+ */
+class Product
+{
+
+ /**
+ * @var int
+ * @ORM\Id
+ * @ORM\GeneratedValue
+ * @ORM\Column(type="integer")
+ */
+ private $id;
+
+ /**
+ * @var string
+ * @ORM\Column(type="string")
+ */
+ private $title;
+
+ /**
+ * @var string
+ * @ORM\Column(type="string")
+ */
+ private $image;
+
+ /**
+ * @var string
+ * @ORM\Column(type="string")
+ */
+ private $slug;
+
+ /**
+ * @var string
+ * @ORM\Column(type="string")
+ */
+ private $description;
+
+ /**
+ * @var float
+ * @ORM\Column(type="float")
+ */
+ private $price;
+
+ /**
+ * var int
+ * @ORM\Column(type="integer")
+ */
+ private $rank;
+
+ /**
+ * @return int
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * @param string $title
+ * @return self
+ */
+ public function setTitle($title)
+ {
+ $this->title = $title;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getImage()
+ {
+ return $this->image;
+ }
+
+ /**
+ * @param string $image
+ * @return self
+ */
+ public function setImage($image)
+ {
+ $this->image = $image;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getSlug()
+ {
+ return $this->slug;
+ }
+
+ /**
+ * @param string $slug
+ * @return self
+ */
+ public function setSlug($slug)
+ {
+ $this->slug = $slug;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * @param string $description
+ * @return self
+ */
+ public function setDescription($description)
+ {
+ $this->description = $description;
+ return $this;
+ }
+
+ /**
+ * @return float
+ */
+ public function getPrice()
+ {
+ return $this->price;
+ }
+
+ /**
+ * @param float $price
+ * @return self
+ */
+ public function setPrice($price)
+ {
+ $this->price = $price;
+ return $this;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getRank()
+ {
+ return $this->rank;
+ }
+
+ /**
+ * @param mixed $rank
+ * @return self
+ */
+ public function setRank($rank)
+ {
+ $this->rank = $rank;
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/src/AppBundle/Entity/ProductCategory.php b/src/AppBundle/Entity/ProductCategory.php
index c292120..0de2e0a 100644
--- a/src/AppBundle/Entity/ProductCategory.php
+++ b/src/AppBundle/Entity/ProductCategory.php
@@ -69,4 +69,4 @@ public function setCategory(Category $category) {
$this->category = $category;
}
-}
\ No newline at end of file
+}
diff --git a/src/AppBundle/Entity/ProductCategory.php~ b/src/AppBundle/Entity/ProductCategory.php~
new file mode 100644
index 0000000..c292120
--- /dev/null
+++ b/src/AppBundle/Entity/ProductCategory.php~
@@ -0,0 +1,72 @@
+
+ * @author Jan Klat
+ *
+ * @ORM\Entity(repositoryClass="AppBundle\Repository\ProductCategoryRepository")
+ * @ORM\Table(name="product_category")
+ */
+class ProductCategory
+{
+
+ /**
+ * @var int
+ * @ORM\Id
+ * @ORM\GeneratedValue
+ * @ORM\Column(type="integer")
+ */
+ private $id;
+
+ /**
+ * @var Product
+ * @ORM\ManyToOne(targetEntity="Product")
+ */
+ private $product;
+
+ /**
+ * @var Category
+ * @ORM\ManyToOne(targetEntity="Category")
+ */
+ private $category;
+
+ /**
+ * @return int
+ */
+ public function getId() {
+ return $this->id;
+ }
+
+ /**
+ * @return Product
+ */
+ public function getProduct() {
+ return $this->product;
+ }
+
+ /**
+ * @param Product $product
+ */
+ public function setProduct(Product $product) {
+ $this->product = $product;
+ }
+
+ /**
+ * @return Category
+ */
+ public function getCategory() {
+ return $this->category;
+ }
+
+ /**
+ * @param Category $category
+ */
+ public function setCategory(Category $category) {
+ $this->category = $category;
+ }
+
+}
\ No newline at end of file
diff --git a/src/AppBundle/Entity/User.php b/src/AppBundle/Entity/User.php
index 5dd2213..1b1409e 100644
--- a/src/AppBundle/Entity/User.php
+++ b/src/AppBundle/Entity/User.php
@@ -5,6 +5,7 @@
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
+use Doctrine\Common\Collections\ArrayCollection;
/**
* @author Vašek Boch
@@ -41,7 +42,27 @@ class User implements UserInterface
*/
private $plainPassword;
- /**
+ /**
+ * @ORM\Column(type="string", length=50)
+ */
+ private $name;
+
+ /**
+ * @ORM\Column(type="string", length=15)
+ */
+ private $phone;
+
+ /**
+ * @ORM\OneToMany(targetEntity="Address", mappedBy="user")
+ */
+ private $addresses;
+
+ public function __construct()
+ {
+ $this->addresses = new ArrayCollection();
+ }
+
+ /**
* @return int
*/
public function getId()
@@ -129,4 +150,86 @@ public function eraseCredentials()
return;
}
+
+ /**
+ * Set name
+ *
+ * @param string $name
+ *
+ * @return User
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+
+ return $this;
+ }
+
+ /**
+ * Get name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Set phone
+ *
+ * @param string $phone
+ *
+ * @return User
+ */
+ public function setPhone($phone)
+ {
+ $this->phone = $phone;
+
+ return $this;
+ }
+
+ /**
+ * Get phone
+ *
+ * @return string
+ */
+ public function getPhone()
+ {
+ return $this->phone;
+ }
+
+ /**
+ * Add address
+ *
+ * @param \AppBundle\Entity\Address $address
+ *
+ * @return User
+ */
+ public function addAddress(\AppBundle\Entity\Address $address)
+ {
+ $this->addresses[] = $address;
+
+ return $this;
+ }
+
+ /**
+ * Remove address
+ *
+ * @param \AppBundle\Entity\Address $address
+ */
+ public function removeAddress(\AppBundle\Entity\Address $address)
+ {
+ $this->addresses->removeElement($address);
+ }
+
+ /**
+ * Get addresses
+ *
+ * @return \Doctrine\Common\Collections\Collection
+ */
+ public function getAddresses()
+ {
+ return $this->addresses;
+ }
}
diff --git a/src/AppBundle/Entity/User.php~ b/src/AppBundle/Entity/User.php~
new file mode 100644
index 0000000..eb2dc88
--- /dev/null
+++ b/src/AppBundle/Entity/User.php~
@@ -0,0 +1,200 @@
+
+ * @author Jan Klat
+ * @ORM\Entity
+ * @UniqueEntity(fields="username", message="Tento e-mail je již registrován")
+ */
+class User implements UserInterface
+{
+
+ /**
+ * @var int
+ * @ORM\Id
+ * @ORM\GeneratedValue
+ * @ORM\Column(type="integer")
+ */
+ private $id;
+
+ /**
+ * @ORM\Column(type="string", length=255, unique=true, name="email")
+ * @Assert\NotBlank()
+ * @Assert\Email()
+ */
+ private $username;
+
+ /**
+ * @ORM\Column(type="string", length=64)
+ */
+ private $password;
+
+ /**
+ * @Assert\NotBlank()
+ * @Assert\Length(max=4096)
+ */
+ private $plainPassword;
+
+ /**
+ * @ORM\Column(type="string", length=50)
+ */
+ private $name;
+
+ /**
+ * @ORM\Column(type="string", length=15)
+ */
+ private $phone;
+
+ /**
+ * @ORM\OneToMany(targetEntity="Adress", mappedBy="user")
+ */
+ private $adresses;
+
+ public function __construct()
+ {
+ $this->adresses = new ArrayCollection();
+ }
+
+ /**
+ * @return int
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * @param int $id
+ * @return self
+ */
+ public function setId($id)
+ {
+ $this->id = $id;
+ return $this;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getUsername()
+ {
+ return $this->username;
+ }
+
+ /**
+ * @param mixed $username
+ * @return self
+ */
+ public function setUsername($username)
+ {
+ $this->username = $username;
+ return $this;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getPassword()
+ {
+ return $this->password;
+ }
+
+ /**
+ * @param mixed $password
+ * @return self
+ */
+ public function setPassword($password)
+ {
+ $this->password = $password;
+ return $this;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getPlainPassword()
+ {
+ return $this->plainPassword;
+ }
+
+ /**
+ * @param mixed $plainPassword
+ * @return self
+ */
+ public function setPlainPassword($plainPassword)
+ {
+ $this->plainPassword = $plainPassword;
+ return $this;
+ }
+
+ public function getRoles()
+ {
+ return [];
+ }
+
+ public function getSalt()
+ {
+ return null;
+ }
+
+ public function eraseCredentials()
+ {
+ //nothing to do
+ return;
+ }
+
+
+ /**
+ * Set name
+ *
+ * @param string $name
+ *
+ * @return User
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+
+ return $this;
+ }
+
+ /**
+ * Get name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Set phone
+ *
+ * @param string $phone
+ *
+ * @return User
+ */
+ public function setPhone($phone)
+ {
+ $this->phone = $phone;
+
+ return $this;
+ }
+
+ /**
+ * Get phone
+ *
+ * @return string
+ */
+ public function getPhone()
+ {
+ return $this->phone;
+ }
+}
diff --git a/src/AppBundle/FormType/AddressFormType.php b/src/AppBundle/FormType/AddressFormType.php
new file mode 100644
index 0000000..4ea45e4
--- /dev/null
+++ b/src/AppBundle/FormType/AddressFormType.php
@@ -0,0 +1,47 @@
+add("street", TextType::class, [
+ "label" => "Ulice",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ ])
+ ->add("city", TextType::class, [
+ "label" => "Město",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ ])
+ ->add("postcode", TextType::class, [
+ "label" => "PSČ",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ ])
+ ->add("country", TextType::class, [
+ "label" => "Země",
+ "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/FormType/ChangePasswordFormType b/src/AppBundle/FormType/ChangePasswordFormType
new file mode 100644
index 0000000..192f5db
--- /dev/null
+++ b/src/AppBundle/FormType/ChangePasswordFormType
@@ -0,0 +1,43 @@
+
+ * @author Jan Klat
+ */
+class ChangePasswordFormType extends AbstractType
+{
+ public function buildForm(FormBuilderInterface $builder, array $options)
+ {
+ $builder
+ ->add("plainPassword", RepeatedType::class, [
+ "type" => PasswordType::class,
+ "first_options" => [
+ "label" => "Heslo",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ ],
+ "second_options" => [
+ "label" => "Heslo znova",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ ],
+ ]);
+ }
+
+ public function configureOptions(OptionsResolver $resolver)
+ {
+ $resolver->setDefaults(array(
+ "data_class" => User::class,
+ ));
+ }
+}
\ No newline at end of file
diff --git a/src/AppBundle/FormType/ProfileFormType.php b/src/AppBundle/FormType/ProfileFormType.php
new file mode 100644
index 0000000..7c6ab08
--- /dev/null
+++ b/src/AppBundle/FormType/ProfileFormType.php
@@ -0,0 +1,42 @@
+add("username", EmailType::class, [
+ "label" => "E-mail",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ ])
+ ->add("name", TextType::class, [
+ "label" => "Jméno a příjmení",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ ])
+ ->add("phone", TextType::class, [
+ "label" => "Telefon",
+ "attr" => [
+ "class" => "form-control",
+ ],
+ ]);
+ }
+
+ public function configureOptions(OptionsResolver $resolver)
+ {
+ $resolver->setDefaults(array(
+ "data_class" => User::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..407c58f
--- /dev/null
+++ b/src/AppBundle/Repository/AddressRepository.php
@@ -0,0 +1,15 @@
+