Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
ClassToYumlRelationsTrait.php
Go to the documentation of this file.
1<?php
2
4
8
18 protected $oneToManys = [ ];
19 protected $manyToOne = [ ];
20 protected $manyToManys = [ ];
21 protected $extManyToManys = [ ];
22
23 protected function loadOneToManys() {
24 $oneToManys = OrmUtils::getAnnotationInfo ( $this->class, "#oneToMany" );
25 if ($oneToManys) {
26 foreach ( $oneToManys as $member => $array ) {
27 $this->oneToManys [$member] = $array ["className"];
28 }
29 }
30 }
31
32 public function loadManyToManys() {
33 $manyToManys = OrmUtils::getAnnotationInfo ( $this->class, "#manyToMany" );
34 if ($manyToManys) {
35 foreach ( $manyToManys as $member => $array ) {
36 if (isset ( $array ["targetEntity"] )) {
37 $this->manyToManys [$member] = $array ["targetEntity"];
38 $this->extManyToManys [$array ["targetEntity"]] = $this->class;
39 }
40 }
41 }
42 }
43
44 protected function loadManyToOne() {
45 $manyToOne = OrmUtils::getAnnotationInfo ( $this->class, "#manyToOne" );
46 if ($manyToOne) {
47 foreach ( $manyToOne as $member ) {
48 $joinColumn = OrmUtils::getAnnotationInfoMember ( $this->class, "#joinColumn", $member );
49 if ($joinColumn && isset ( $joinColumn ["className"] )) {
50 $this->manyToOne [$member] = $joinColumn ["className"];
51 }
52 }
53 }
54 }
55
56 protected function getShortClassName($class) {
57 $reflect = new \ReflectionClass ( $class );
58 return $reflect->getShortName ();
59 }
60
61 protected function _getYumlRelationsType($relations, $branche) {
62 $myClass = $this->getShortClassName ( $this->class );
63 $yumlRelations = [ ];
64 foreach ( $relations as $model ) {
65 $yumlRelations [] = Yuml::setClassContent ( $myClass ) . $branche . new ClassToYuml ( $model, $this->displayAssociationClassProperties, false );
66 }
67 return $yumlRelations;
68 }
69
70 protected function _getYumlManyToOne() {
71 return $this->_getYumlRelationsType ( $this->manyToOne, "0..*-1" );
72 }
73
74 protected function _getYumlOneToMany() {
75 return $this->_getYumlRelationsType ( $this->oneToManys, "1-0..*" );
76 }
77
78 protected function _getYumlManyToMany() {
79 return $this->_getYumlRelationsType ( $this->manyToManys, "0..*-0..*" );
80 }
81
86 public function getExtManyToManys() {
88 }
89
90 public function removeManyToManyExt($targetClass) {
91 $member = array_search ( $targetClass, $this->manyToManys );
92 if ($member !== false) {
93 unset ( $this->manyToManys [$member] );
94 }
95 }
96}
97
Object/relational mapping utilities.
Definition OrmUtils.php:17
yuml export tool for class Ubiquity\utils\yuml$ClassToYuml This class is part of Ubiquity
static setClassContent($content)
Definition Yuml.php:54
Ubiquity\utils\yuml\traits$ClassToYumlRelationsTrait This class is part of Ubiquity.