-
-
Save beberlei/18db9f7d5f6157b817348a58fa2aee25 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
<<ORM\Entity(["repositoryClass" => "UserRepository"])>> | |
class User | |
{ | |
<<ORM\Id>> | |
<<ORM\Column(["type" => "string", "options" => ["default" => "1234"]])>> | |
<<ORM\GeneratedValue>> | |
private $id; | |
<<ORM\OneToMany(["targetEntity" => "Group", "joinColumns" => ["columnName" => "group_id", "referenceColumnName" => "id"]])>> | |
private $groups; | |
} | |
$reflClass = new ReflectionClass("User"); | |
var_dump($attributes); | |
// prints ["ORM\Entity" => [0 => ["repositoryClass" => "UserRepository"]]] | |
$idProperty = $reflClass->getProperty("id"); | |
var_dump($idProperty->getAttributes()); | |
/* prints | |
[ | |
"ORM\Id" => [], | |
"ORM\Column" => [0 => ["type" => "string", "options" => ["default" => "1234"]]], | |
"ORM\GeneratedValue" => [] | |
] | |
*/ | |
$groupProperty = $reflClass->getProperty("groups"); | |
var_dump($groupProperty->getAttributes()) | |
/* prints | |
[ | |
"ORM\OneToMany" => [ | |
[ | |
"targetEntity" => "Group", | |
"joinColumns" => ["columnName" => "group_id", "referenceColumnName" => "id"] | |
] | |
] | |
] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment