Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
ClassesToYuml.php
Go to the documentation of this file.
1<?php
2
4
8
24 private $manyToManys;
25 private $database;
26
27 public function __construct($databaseOffset = 'default', $displayProperties = true, $displayAssociations = true, $displayMethods = false, $displayMethodsParams = false, $displayPropertiesTypes = false) {
28 $this->database = $databaseOffset;
29 $this->displayProperties = $displayProperties;
30 $this->displayAssociations = $displayAssociations;
31 $this->displayMethods = $displayMethods;
32 $this->displayMethodsParams = $displayMethodsParams;
33 $this->displayPropertiesTypes = $displayPropertiesTypes;
34 $this->manyToManys = [ ];
35 }
36
41 public function parse() {
42 $yumlResult = [ ];
43 $config = Startup::getConfig ();
44 CacheManager::start ( $config );
45 $models = CacheManager::getModels ( $config, true, $this->database );
46 if (\count ( $models ) !== 0) {
47 foreach ( $models as $model ) {
48 $yumlR = new ClassToYuml ( $model, $this->displayProperties, false, $this->displayMethods, $this->displayMethodsParams, $this->displayPropertiesTypes, false );
49 $yumlR->loadManyToManys ();
50 $yumlResult [] = $yumlR;
51 }
52 if ($this->displayAssociations) {
53 $count = \count ( $models );
54 for($i = 0; $i < $count; $i ++) {
55 $this->checkManyToManys ( $yumlResult [$i]->getExtManyToManys (), $yumlResult [$i] );
56 }
57 for($i = 0; $i < $count; $i ++) {
58 $result = $yumlResult [$i]->oneToManyTostring ();
59 if (UString::isNotNull ( $result )) {
60 $yumlResult [] = $result;
61 }
62 $result = $yumlResult [$i]->manyToManyTostring ( false );
63 if (UString::isNotNull ( $result )) {
64 $yumlResult [] = $result;
65 }
66 }
67 }
68 }
69 $this->manyToManys = [ ];
70 return $yumlResult;
71 }
72
73 private function checkManyToManys($manyToManys, ClassToYuml $classToYuml) {
74 foreach ( $manyToManys as $targetClass => $class ) {
75 if (\array_search ( \md5 ( $class . '_' . $targetClass ), $this->manyToManys ) !== false || \array_search ( \md5 ( $targetClass . '_' . $class ), $this->manyToManys ) !== false) {
76 $classToYuml->removeManyToManyExt ( $targetClass );
77 } else {
78 $this->manyToManys [] = \md5 ( $class . '_' . $targetClass );
79 }
80 }
81 }
82
83 public function __toString() {
84 return \implode ( Yuml::$groupeSeparator, $this->parse () );
85 }
86}
Manager for caches (Router, Rest, models).
Starts the framework.
Definition Startup.php:19
String utilities.
Definition UString.php:15
yuml export tool for class Ubiquity\utils\yuml$ClassToYuml This class is part of Ubiquity
Generates Yuml code from models.
checkManyToManys($manyToManys, ClassToYuml $classToYuml)
__construct($databaseOffset='default', $displayProperties=true, $displayAssociations=true, $displayMethods=false, $displayMethodsParams=false, $displayPropertiesTypes=false)