mirror of
https://github.com/tchapi/davis.git
synced 2025-04-11 08:02:21 +02:00
Improve forms and constraints
This commit is contained in:
parent
d1f1981ac7
commit
fcdefffaad
@ -104,12 +104,14 @@ class AdminController extends AbstractController
|
||||
$calendarInstance = new CalendarInstance();
|
||||
$calendar = new Calendar();
|
||||
$calendarInstance->setPrincipalUri(Principal::PREFIX.$user->getUsername())
|
||||
->setUri('default') // No risk of collision since unicity is guaranteed by the new user principal
|
||||
->setDisplayName($trans->trans('default.calendar.title'))
|
||||
->setDescription($trans->trans('default.calendar.description', ['users' => $displayName]))
|
||||
->setCalendar($calendar);
|
||||
|
||||
$addressbook = new AddressBook();
|
||||
$addressbook->setPrincipalUri(Principal::PREFIX.$user->getUsername())
|
||||
->setUri('default') // No risk of collision since unicity is guaranteed by the new user principal
|
||||
->setDisplayName($trans->trans('default.addressbook.title'))
|
||||
->setDescription($trans->trans('default.addressbook.description', ['users' => $displayName]));
|
||||
$entityManager->persist($calendarInstance);
|
||||
|
@ -5,6 +5,7 @@ namespace App\Entity;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* @ORM\Table(name="addressbooks")
|
||||
@ -31,6 +32,7 @@ class AddressBook
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="binary", length=255)
|
||||
* @Assert\Regex("/[0-9a-z\-]+/")
|
||||
*/
|
||||
private $uri;
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* @ORM\Table(name="calendarinstances")
|
||||
@ -49,6 +50,7 @@ class CalendarInstance
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="binary", length=255, nullable=true)
|
||||
* @Assert\Regex("/[0-9a-z\-]+/")
|
||||
*/
|
||||
private $uri;
|
||||
|
||||
|
@ -3,10 +3,13 @@
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* @ORM\Table(name="principals")
|
||||
* @ORM\Entity(repositoryClass="App\Repository\PrincipalRepository")
|
||||
* @UniqueEntity("uri")
|
||||
*/
|
||||
class Principal
|
||||
{
|
||||
@ -20,12 +23,18 @@ class Principal
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="binary", length=255)
|
||||
* @ORM\Column(type="binary", length=255, unique=true)
|
||||
* @Assert\NotBlank
|
||||
* @Assert\Unique
|
||||
*/
|
||||
private $uri;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="binary", length=255, nullable=true)
|
||||
* @Assert\Email(
|
||||
* message = "The email '{{ value }}' is not a valid email."
|
||||
* )
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
private $email;
|
||||
|
||||
|
@ -3,10 +3,13 @@
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* @ORM\Table(name="users")
|
||||
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
|
||||
* @UniqueEntity("username")
|
||||
*/
|
||||
class User
|
||||
{
|
||||
@ -20,12 +23,14 @@ class User
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="binary", length=255)
|
||||
* @ORM\Column(type="binary", length=255, unique=true)
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
private $username;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="digesta1", type="binary", length=255)
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
private $password;
|
||||
|
||||
|
@ -26,6 +26,7 @@ class AddressBookType extends AbstractType
|
||||
])
|
||||
->add('description', TextAreaType::class, [
|
||||
'label' => 'form.description',
|
||||
'required' => false,
|
||||
])
|
||||
->add('save', SubmitType::class, [
|
||||
'label' => 'save',
|
||||
|
@ -28,6 +28,7 @@ class CalendarInstanceType extends AbstractType
|
||||
])
|
||||
->add('description', TextareaType::class, [
|
||||
'label' => 'form.description',
|
||||
'required' => false,
|
||||
])
|
||||
->add('calendarColor', TextType::class, [
|
||||
'label' => 'form.color',
|
||||
|
Loading…
x
Reference in New Issue
Block a user