-
Notifications
You must be signed in to change notification settings - Fork 0
/
serialise.php
50 lines (43 loc) · 1.12 KB
/
serialise.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
require_once('./vendor/autoload.php');
use Micronative\EntityPatcher\Patcher;
use Samples\Entity\Company;
use Samples\Entity\Role;
use Samples\Entity\User;
$patcher = new Patcher();
$company = new Company();
$company
->setId(1)
->setName('Micronative');
$role1 = new Role();
$role1
->setId(1)
->setType('Admin');
$role2 = new Role();
$role2
->setId(21)
->setType('Manager');
$user1 = new User();
$user1
->setId(2)
->setEmail('[email protected]')
->setFirstName('Ken')
->setLastName('Ngo')
->setCompany($company);
$role1->setUsers([$user1]);
$user1->setRoles([$role1, $role2]);
$user2 = new User();
$user2
->setId(3)
->setEmail('[email protected]')
->setFirstName('May')
->setLastName('Ngo')
->setCompany($company);
$role2->setUsers([$user2]);
$company->setUsers([$user1, $user2]);
# serialise to array KEYED_BY_PROPERTY
$companyArray = $patcher->serialise($company, Patcher::KEYED_BY_PROPERTY);
print_r($companyArray);
# serialise to array KEYED_BY_COLUMN
$companyArray = $patcher->serialise($company, Patcher::KEYED_BY_COLUMN);
print_r($companyArray);