Skip to content

Commit

Permalink
Generating (UU)IDs in ctors, corrected data types of members
Browse files Browse the repository at this point in the history
  • Loading branch information
sukovec committed Feb 11, 2018
1 parent 82c9bd1 commit 724e62f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/Entity/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class Event
*
* @ORM\Id
* @ORM\Column(type="Uuid", unique=true)
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class="Ramsey\Uuid\Doctrine\UuidGenerator")
*/
protected $id;

Expand All @@ -31,7 +29,7 @@ class Event
/**
* @var string
*
* @ORM\Column(type="string")
* @ORM\Column(type="text")
*/
protected $description;

Expand All @@ -41,8 +39,10 @@ class Event
*/
protected $eventType;

public function __construct() {

public function __construct(string $title, EventType $eventType) {
$this->id = Uuid::uuid4();
$this->title = $title;
$this->eventType = $eventType;
}

public function getId(): UuidInterface {
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/EventType.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class EventType

/**
* @var string|null
* @ORM\Column(type="text", nullable=true)
* @ORM\Column(type="string", nullable=true, length=512)
*/
protected $comment;

Expand Down
22 changes: 18 additions & 4 deletions src/Entity/SubEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ class SubEvent
*
* @ORM\Id
* @ORM\Column(type="Uuid", unique=true)
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class="Ramsey\Uuid\Doctrine\UuidGenerator")
*/
protected $id;

/**
* @var Event
*
* @ORM\ManyToOne(targetEntity="Event")
*/
protected $parent;

/**
* @var string
Expand All @@ -31,7 +35,7 @@ class SubEvent
/**
* @var string
*
* @ORM\Column(type="string")
* @ORM\Column(type="text")
*/
protected $description;

Expand All @@ -49,7 +53,9 @@ class SubEvent
*/
protected $endDate;

public function __construct(string $title, string $description, \DateTime $startDate, \DateTime $endDate) {
public function __construct(Event $parent, string $title, string $description, \DateTime $startDate, \DateTime $endDate) {
$this->id = Uuid::uuid4();
$this->parent = $parent;
$this->title = $title;
$this->description = $description;
$this->startDate = $startDate;
Expand All @@ -60,6 +66,14 @@ public function getId(): UuidInterface {
return $this->id;
}

public function getParent(): Event {
return $this->parent;
}

public function setParent(Event $parent): void {
$this->parent = $parent;
}

public function getTitle(): string {
return $this->title;
}
Expand Down

0 comments on commit 724e62f

Please sign in to comment.