Giter VIP home page Giter VIP logo

Comments (14)

MacFJA avatar MacFJA commented on May 18, 2024

The list of Doctrine (DBAL) type is defined here: http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html#mapping-matrix
From code, the list of type can be retrieve from the function getTypesMap() of the class Doctrine\DBAL\Types\Type

$types = array_keys(\Doctrine\DBAL\Types\Type::getTypesMap());

The list of supported association of Doctrine (ORM) is available here:
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/association-mapping.html


Doctrine2 project defined a lot of models for testing purpose. But no fixtures (objects are generated per test)
But maybe models can be reused and we just have to create fixture for those models.

from easyadminbundle.

javiereguiluz avatar javiereguiluz commented on May 18, 2024

@MacFJA thanks for providing the exact references for types and associations.

In case anyone wants to work on this, what we're looking for is: The minimal set of Doctrine entities that use ALL the data types and define ALL the possible associations between them.

from easyadminbundle.

MacFJA avatar MacFJA commented on May 18, 2024

1) Check if Doctrine project defines that set of entities and fixtures and reuse it.

So far no fixture found, lots of entities, some of them cover a large part of possible association and field type

2) If not, check if SonataAdmin or any other existing admin generator bundle defines that set of entities and fixtures and reuse it.

I check sonata-project/SonataAdminBundle, Symfony's DoctrineBundle, Snowcap/SnowcapAdminBundle, mgiagnoni/LyraAdminBundle. But none of them have entities (that cover must of case) neither fixtures to generate a consistent database.

3) If none of the previous points succeed, create that set of entities + fixtures for EasyAdmin.

I just define a little UML diagram of an believable set of entities to have an overview
ecommerce
So, for now I have:

  • Association
    • ManyToMany (Category/Product + Product/Order)
    • Self referencing (Category/Category)
    • ManyToOne & OneToMany (Product/Image + Image/Product)
  • Field type
    • string
    • datetime
    • datetimetz
    • simple_array
    • bigint
    • boolean
    • integer
    • float
    • text
    • blob
    • binary
    • guid
    • date
    • json_array
    • time

Still missing some requirement

from easyadminbundle.

javiereguiluz avatar javiereguiluz commented on May 18, 2024

@MacFJA amazing! Thanks a lot for your work!

In the entity set that you've prepared, the only missing types that I see are: array, decimal, object and smallint. And the only missing association is one-to-one non-self-referencing.

Ii would be great if someone could help @MacFJA think about which fields to add to these entities to actually use every possible Doctrine type.

After that, it would be very helpful if you could export the UML diagram to actual Doctrine PHP entities. Then, I'll prepare the fixtures. Thanks!

from easyadminbundle.

Pierstoval avatar Pierstoval commented on May 18, 2024

Maybe a serialized non-stdclass object (like a non-entity class) ?

from easyadminbundle.

javiereguiluz avatar javiereguiluz commented on May 18, 2024

Here it is my proposal for adding the remaining data types and associations:

Relations

  • Create a new OrderItem entity with a one-to-many relation with Order (and move quantity from Product to OrderItem).
  • Add a many-to-one relation between Product and the new OrderItem entity.
  • Simplify relation between Product and Gallery to one-to-one relation.

Data types

  • In Product entity add a new features property of type array. Example: $features = array('feature_1_name' => 'feature_1_value', ...);
  • In the OrderItem entity, add a taxRate property of type decimal. Example 21.5 (%)
  • In OrderItem, replace the quantity type from integer to smallint
  • In Order, replace the incrementId type from bigint to int.
  • In Order, replace the shippingAddress property by shipment and replace its type from json_array to object type. Example: class Shipment { public $address; $public shippingCompany; public $cost; ... }

from easyadminbundle.

MacFJA avatar MacFJA commented on May 18, 2024

Here the version of the UML diagram:
ecommerce v2

from easyadminbundle.

javiereguiluz avatar javiereguiluz commented on May 18, 2024

@MacFJA great! I'm sure that some purists would scream if they see this schema ... but it's perfect for our purposes: all types and all associations using the minimal set of entities!

I wonder if it's easy to transform the UML diagram that you made into Doctrine entities. If you can, please email me those PHP files to [email protected]. Then, I'll prepare the fixtures to be able to test them in a real backend. Thanks!

from easyadminbundle.

Pierstoval avatar Pierstoval commented on May 18, 2024

Depending on the software it can be transposed to MySQL table definitions, like with JMerise or MysqlWorkbench. Then with the table def, you can use doctrine-reverse-mapping to generate a bunch of entities based on this diagram.

from easyadminbundle.

MacFJA avatar MacFJA commented on May 18, 2024

The diagram was created with ArgoUML, and lots of information are missing or not exact. I prefer make all the classes "by hand" to be sure that all convention in the doctrine documentation are respected. And some case must by handling manually (for instance the case of the ManyToMany association, which side is responsible of the creation: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/association-mapping.html#owning-and-inverse-side-on-a-manytomany-association)


Here the full test set: MacFJA/Doctrine-TestSet

(Fixtures for products and categories in preparation)

from easyadminbundle.

javiereguiluz avatar javiereguiluz commented on May 18, 2024

@MacFJA awesome! Thanks for working on this and for doing it so well. I'm really looking forward to use your entities to improve this bundle. Thanks.

from easyadminbundle.

javiereguiluz avatar javiereguiluz commented on May 18, 2024

@MacFJA I've prepared a demo Symfony backend which includes your entities: https://github.com/javiereguiluz/easy-admin-demo I'll use this project to work on adding support for associations: https://github.com/javiereguiluz/EasyAdminBundle/issues/124

Do you have some fixtures that we can use to fill in the backend or do you prefer if I prepare those fixtures? Thanks!

from easyadminbundle.

MacFJA avatar MacFJA commented on May 18, 2024

@javiereguiluz I just push fixtures for products, categories and images.
Still missing lots of contents 😞
I have to make fixtures for order's side (Order, OrderItem, Shipment) and add more features for products.

In my todo list I also have the packagist publication and a nicer way to import data (for now we have to call doctrine command line to create database, index.php to inject fixture)

from easyadminbundle.

javiereguiluz avatar javiereguiluz commented on May 18, 2024

Closing it as "fixed" in https://github.com/javiereguiluz/easy-admin-demo. It's still not completed, but we can close this issue because the initial work is done. Thanks @MacFJA for working on this.

from easyadminbundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.