Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Refactor SchemaReader and object model #83

Open
wants to merge 14 commits into
base: master
from

Conversation

Projects
None yet
2 participants
@cristianoc72
Copy link
Member

cristianoc72 commented Jul 18, 2018

This PR starts from #61 , please read the discussion in that PR for further details.

  • Refactor Model classes, according to PR #61
  • Drop loadMapping() completely, use getters and setters
  • Externalize finalize() methods from the model into somewhere else => $whatever->finalize($schema)
  • Rewrite SchemaReader to make use of the new APIs and use something different like symfony config component to support multiple schema formats Symfony Config Component to load and process schemas. Supported schema formats are: xml, yaml, json, php. #69
  • Fix agnostic test suite (non-trivial operation: basically it means refactor managers and bilders to interact with new loaders and object model)

The new code is already PHP 7.1 strict.

Add schema loaders
Add classes to load schemas in different formats.
Now Propel supports xml, yaml, json and php formats for describing schema.
@cristianoc72

This comment has been minimized.

Copy link
Member Author

cristianoc72 commented Sep 1, 2018

@gossi question:

let's suppose to have a schema with external schemas. After loading and parsing, I have one Schema object with a collection of external Schema objects. Before building model classes, the external schemas are merged into their parent. Am I right?

If yes:
since I load schemas with Symfony Config loaders, I build the object models starting from an array, no more from an xml file. So, I could load and merge external schemas into their parent at "process" time, before building the object model (merging arrays is easier the objects).
I mean:

  1. load schema
  2. process schema to normalize and validate it
  3. loop into external schemas
    3.1 load external schema
    3.2 process external schema to normalize and validate it
  4. merge external schemas into their parent (array_merge_recursive or some other function)
  5. now build object model from the resulted array

The point 3 could be recursive (I could have an external schema into another external schema).

What do you think about?

@gossi

This comment has been minimized.

Copy link
Contributor

gossi commented Sep 2, 2018

There are two ways to handle external schemas:

  1. Merge them in and generate them as you mentioned
  2. Merge them in only for reference and only generate the models which are in the parent schema.
@cristianoc72

This comment has been minimized.

Copy link
Member Author

cristianoc72 commented Sep 21, 2018

Choose the second (I see, you prepared the Schema class for that).

Another question: I can't find domain in any schema nor into the documentation: should it be a tag under database? I.e.

<database name="my-db">
    <domain name="mydomain" type="........."  />
..........................................

cristianoc72 added some commits Oct 13, 2018

Fix Model tests
Fix Propel\Generator\Model tests.
Fix model
Several fixes, while running test suite.
Refactor Archivable behavior
Refactor Archivable behavior to work with the new object model.

@gossi gossi referenced this pull request Jan 23, 2019

Closed

Is Propel dead dead now? #86

@cristianoc72 cristianoc72 force-pushed the cristianoc72:schema-reader branch from be307ad to 92441f6 Feb 22, 2019

@cristianoc72

This comment has been minimized.

Copy link
Member Author

cristianoc72 commented Mar 4, 2019

@marcj @gossi any chance someone could review this huge PR? 😁

@gossi

This comment has been minimized.

Copy link
Contributor

gossi commented Mar 4, 2019

I try when I return from work later today. I started this beast it's cool to see it jump in 😃

@cristianoc72 cristianoc72 referenced this pull request Mar 8, 2019

Closed

Zend hydrator #88

@gossi
Copy link
Contributor

gossi left a comment

I got until src/Generator/Model/* ... but it's very heavily loaded ;)

@@ -1,7 +1,8 @@
language: php

php:
- 7.1
- 7.2

This comment has been minimized.

Copy link
@gossi

gossi Mar 12, 2019

Contributor

👍

Show resolved Hide resolved src/Propel/Generator/Behavior/Sortable/SortableBehavior.php Outdated
Show resolved Hide resolved src/Propel/Generator/Builder/DataModelBuilder.php
Show resolved Hide resolved src/Propel/Generator/Model/Domain.php Outdated
Show resolved Hide resolved src/Propel/Generator/Model/Domain.php Outdated
Show resolved Hide resolved src/Propel/Generator/Model/Entity.php Outdated
Show resolved Hide resolved src/Propel/Generator/Model/Field.php Outdated
Show resolved Hide resolved src/Propel/Generator/Model/Field.php Outdated
Model refactor completed
Refine model refactor and fix test suite. Agnostic tests are green.

@cristianoc72 cristianoc72 force-pushed the cristianoc72:schema-reader branch from 92441f6 to f2bbaf1 Mar 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.