Open liusvel opened 10 years ago
Hi liusvel, the project is based on Acceleo 3.
I am aware of the lacks of documentation about this concern but it is in my todo list. To summary : -> Only Class diagrams are supported -> Not all UML spec is handled. (I develop and use this tool to meet the design and workflow needs of another projet : https://github.com/TiBeN/Framework) -> However i think the most commons design needs are handled : UML -> PHP
Packages -> namespace
Dependency -> use statements (only if Dependency Class is in different Package)
Class -> class
Property -> class/interface attribute + getters setters. (The attributes are allways private but getters and setters visibility change accordingly to Property visibility. I admit this point is subjective.)
Operation -> class / interface Method
Handle Multiplicity by declaring a PHP array for * and adding default "= NULL" when 0
Handle Static attributes / methods by declaring them accordingly and referencing the class using "self"
Interface -> interface
Generalization -> extends
Association -> generate attributes in class
InterfaceRealisaton -> implements
Typing -> All parameters which are Object or array are typed in method signatures.
Interfaces wich are available in the SPL are not generated, but the extends of the InterfaceRealisation is generated.
RedefinableTemplateSignature and OwnedParameteredElements -> This was a little bit tricky one because of lacks of php typing. This is handled by some kind of "TypeHint" pattern. The type name of the class must be passed as a String in the construct method of this class. All methods of the class declaring a template parameter in their signature does a call to an integrated method "typeInt" which throw an Exception if the passed parameter does not fit the type when instantiate the object.
Constructors are not supported for now. Generic construct() and __destruct() are generated with the possibility to insert custom chunks of code. This could be a feature request but for my needs i've adopted a Factory methods design.
Feel free to browse the code of my project https://github.com/TiBeN/Framework and get the Papyrus model *.uml file which is in the "docs" path of the repository to get a better idea of the transformations and don't hesitate to comments here.
hi TiBeN I am currently working on my thesis project developing a php code generator plugin for eclipse using Acceleo and also using an UML profile focused on educational applications called ApeM-L I want to ask if there is any way to check once a code regeneration is made from a diagram, if the developer has not committed a violation of the metamodel established in the protected areas I have researched on this topic and apparently nobody validates metamodel possible violations in the protected areas of code thanks in advance and your project umltophp has been an invaluable help to me thanks one more time
Hi liusvel. I'm glad to know that my project helped you! I'm not sure to understand your question : did you mean -> A violation of the metal model (or OCL constraints) on the model ? -> A "handwrite" in the protected area of a generated class file ?
Will your thesis be publicly available ? Or some related materials ? i'll be interrested to read it :)
hi TiBeN excuse me if I could not express my doubts properly my English isn't the best I was referring to the hand-written violations of the restrictions defined in the meta model for example : in the meta model is defined that a view class can not be related to a class model(MVC pattern) but in the protected area of a view class the programmer creates an object of the class model violating the restrictions defined in the meta model.
my question is : How i can validate such violations(after a code regeneration) with acceleo ??? thks for your help !!!
once I finish the thesis project will be published and I'll give you the address ;)
I think (but not sure!) it is not possible because this is out of the scope of acceleo which is by nature a model to text generator, not a code analysis tool. Acceleo help you generate some text file using templates but, despite its source synchronisation system once you relaunch the generation, doesn't provide any semantic support of your output (excepted for Java which Acceleo seems to provide some extra features but i don't know more about this).
About your issue, because it is located inside an Operation/method it is implementation related. Without a custom code analysis tool which understand PHP code and has the knowledge of your constraint i don't think it is possible.
Hello TiBeN I would like to know which version of Acceleo you use to create this project and what rules of transformation you use to translate uml diagrams into php(?) code thks in advance ;)