Skip to content

Commit bee88a9

Browse files
committed
Clean up sandbox example documents
Don't use MD5 binary BSON type for storing MD5 strings, since they aren't raw bytes. Also, use ArrayCollection in lieu of arrays for default values of Reference/EmbedMany fields.
1 parent 48bea06 commit bee88a9

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

tools/sandbox/Documents/Account.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ public function getName()
3535

3636
public function __toString()
3737
{
38-
return $this->name;
38+
return (string) $this->name;
3939
}
4040
}

tools/sandbox/Documents/User.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Documents;
44

5+
use Doctrine\Common\Collections\ArrayCollection;
56
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
67

78
/** @ODM\Document(collection="users") */
@@ -13,7 +14,7 @@ class User
1314
/** @ODM\String */
1415
private $username;
1516

16-
/** @ODM\Bin(type="bin_md5") */
17+
/** @ODM\String */
1718
protected $password;
1819

1920
/** @ODM\EmbedOne(targetDocument="Address") */
@@ -23,7 +24,12 @@ class User
2324
protected $account;
2425

2526
/** @ODM\EmbedMany(targetDocument="Phonenumber") */
26-
protected $phonenumbers = array();
27+
protected $phonenumbers;
28+
29+
public function __construct()
30+
{
31+
$this->phonenumbers = new ArrayCollection();
32+
}
2733

2834
public function getId()
2935
{
@@ -47,7 +53,7 @@ public function setPassword($password)
4753

4854
public function checkPassword($password)
4955
{
50-
return $this->password === md5($password) ? true : false;
56+
return $this->password === md5($password);
5157
}
5258

5359
public function setAddress(Address $address)

0 commit comments

Comments
 (0)