1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace VideoGamesRecords\CoreBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
6
|
|
|
use Knp\DoctrineBehaviors\Model\Timestampable\Timestampable; |
7
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
8
|
|
|
use VideoGamesRecords\CoreBundle\Model\Player\Player; |
|
|
|
|
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* GameMessage |
12
|
|
|
* |
13
|
|
|
* @ORM\Table(name="vgr_game_message", indexes={@ORM\Index(name="idxMessage", columns={"idMessage"})}) |
14
|
|
|
* @ORM\Entity(repositoryClass="VideoGamesRecords\CoreBundle\Repository\GameMessageRepository") |
15
|
|
|
*/ |
16
|
|
|
class GameMessage |
17
|
|
|
{ |
18
|
|
|
use Timestampable; |
19
|
|
|
use Player; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var integer |
23
|
|
|
* |
24
|
|
|
* @ORM\Column(name="idMessage", type="integer") |
25
|
|
|
* @ORM\Id |
26
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
27
|
|
|
*/ |
28
|
|
|
private $idMessage; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var string |
32
|
|
|
* |
33
|
|
|
* @Assert\NotBlank() |
34
|
|
|
* @ORM\Column(name="text", type="text", nullable=false) |
35
|
|
|
*/ |
36
|
|
|
private $text; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var GameTopic |
40
|
|
|
* |
41
|
|
|
* @Assert\NotNull |
42
|
|
|
* @ORM\ManyToOne(targetEntity="VideoGamesRecords\CoreBundle\Entity\GameTopic", inversedBy="messages") |
43
|
|
|
* @ORM\JoinColumns({ |
44
|
|
|
* @ORM\JoinColumn(name="idTopic", referencedColumnName="idTopic", nullable=false) |
45
|
|
|
* }) |
46
|
|
|
*/ |
47
|
|
|
private $topic; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @return string |
51
|
|
|
*/ |
52
|
|
|
public function __toString() |
53
|
|
|
{ |
54
|
|
|
return sprintf('Message [%d]', $this->idMessage); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Set idMessage |
59
|
|
|
* |
60
|
|
|
* @param integer $idMessage |
61
|
|
|
* @return GameMessage |
62
|
|
|
*/ |
63
|
|
|
public function setIdMessage($idMessage) |
64
|
|
|
{ |
65
|
|
|
$this->idMessage = $idMessage; |
66
|
|
|
return $this; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Get idMessage |
71
|
|
|
* |
72
|
|
|
* @return integer |
73
|
|
|
*/ |
74
|
|
|
public function getIdMessage() |
75
|
|
|
{ |
76
|
|
|
return $this->idMessage; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Set text |
81
|
|
|
* |
82
|
|
|
* @param string $text |
83
|
|
|
* @return GameMessage |
84
|
|
|
*/ |
85
|
|
|
public function setText($text) |
86
|
|
|
{ |
87
|
|
|
$this->text = $text; |
88
|
|
|
|
89
|
|
|
return $this; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Get text |
94
|
|
|
* |
95
|
|
|
* @return string |
96
|
|
|
*/ |
97
|
|
|
public function getText() |
98
|
|
|
{ |
99
|
|
|
return $this->text; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Set topic |
104
|
|
|
* @param GameTopic $topic |
105
|
|
|
* @return GameMessage |
106
|
|
|
*/ |
107
|
|
|
public function setTopic(GameTopic $topic = null) |
108
|
|
|
{ |
109
|
|
|
$this->topic = $topic; |
110
|
|
|
|
111
|
|
|
return $this; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Get topic |
116
|
|
|
* @return GameTopic |
117
|
|
|
*/ |
118
|
|
|
public function getTopic() |
119
|
|
|
{ |
120
|
|
|
return $this->topic; |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: